xref: /llvm-project/flang/test/Driver/w-option.f90 (revision eba6160deec5a32e4b31c2a446172d0e388195c9)
1! Test the default setting. Emit warnings only.
2! RUN: %flang -c %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
3
4! Test that the warnings are not generated with `-w` option.
5! RUN: %flang -c -w %s 2>&1 | FileCheck --allow-empty %s -check-prefix=WARNING
6
7! Test that the warnings are not generated with `--no-warnings` option.
8! RUN: %flang -c --no-warnings %s 2>&1 | FileCheck --allow-empty %s -check-prefix=WARNING
9
10! Test that warnings are portability messages are generated.
11! RUN: %flang -c -pedantic %s 2>&1 | FileCheck %s -check-prefixes=DEFAULT,PORTABILITY
12
13! Test that warnings and portability messages are not generated.
14! TODO: Support the last flag wins behaviour.
15! RUN: %flang -c -pedantic -w %s 2>&1 | FileCheck --allow-empty %s -check-prefixes=WARNING,PORTABILITY-WARNING
16! RUN: %flang -c -w -pedantic %s 2>&1 | FileCheck --allow-empty %s -check-prefixes=WARNING,PORTABILITY-WARNING
17! DEFAULT: warning: Label '40' is in a construct that should not be used as a branch target here
18! DEFAULT: warning: Label '50' is in a construct that should not be used as a branch target here
19! WARNING-NOT: warning
20! PORTABILITY: portability: Statement function 'sf1' should not contain an array constructor
21! PORTABILITY-WARNING-NOT: portability
22
23subroutine sub01(n)
24  integer n
25  GOTO (40,50,60) n
26  if (n .eq. 1) then
2740   print *, "xyz"
2850 end if
2960 continue
30end subroutine sub01
31
32subroutine sub02
33  sf1(n) = sum([(j,j=1,n)])
34end subroutine sub02
35