2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / tr-warn3.c
blobe802b4dd0f754b12636674dff488d48e398aee60
1 /* Test for warnings about nontraditional directives inside the unused
2 clauses of #if statements. Extensions do _not_ receive pedantic
3 warnings inside unused clauses because they are often hidden this
4 way on purpose. However they do still require indentation for K&R. */
5 /* { dg-do preprocess } */
6 /* { dg-options "-pedantic -Wtraditional -fno-show-column" } */
8 #if 1
10 /* Block 1: K+R directives should have the # indented to warn. */
12 #define foo bar /* { dg-bogus "indented" "^#kandr" } */
13 # define foo bar /* { dg-bogus "indented" "^# kandr" } */
14 #define foo bar /* { dg-warning "indented" "^ #kandr" } */
15 # define foo bar /* { dg-warning "indented" "^ # kandr" } */
17 /* Block 2: C89 directives should not have the # indented to warn. */
19 #pragma whatever /* { dg-warning "indented" "^#c89" } */
20 # pragma whatever /* { dg-warning "indented" "^# c89" } */
21 #pragma whatever /* { dg-bogus "indented" "^ #c89" } */
22 # pragma whatever /* { dg-bogus "indented" "^ # c89" } */
24 /* Block 3: Extensions should not have the # indented to warn, _and_
25 they should get a -pedantic warning. */
27 #assert foo(bar) /* { dg-warning "indented" "^#ext" } */
28 # assert bar(baz) /* { dg-warning "indented" "^# ext" } */
29 #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
30 # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
32 #else
34 /* Block 1: K+R directives should have the # indented to warn. */
36 #undef foo bar /* { dg-bogus "indented" "^#kandr" } */
37 # undef foo bar /* { dg-bogus "indented" "^# kandr" } */
38 #undef foo bar /* { dg-warning "indented" "^ #kandr" } */
39 # undef foo bar /* { dg-warning "indented" "^ # kandr" } */
41 /* Block 2: C89 directives should not have the # indented to warn. */
43 #error whatever /* { dg-warning "indented" "^#c89" } */
44 # error whatever /* { dg-warning "indented" "^# c89" } */
45 #error whatever /* { dg-bogus "indented" "^ #c89" } */
46 # error whatever /* { dg-bogus "indented" "^ # c89" } */
48 /* Block 3: Extensions should not have the # indented to warn, and
49 they should _not_ get a -pedantic warning. */
51 #unassert foo(bar) /* { dg-warning "indented" "^#ext" } */
52 # unassert bar(baz) /* { dg-warning "indented" "^# ext" } */
53 #unassert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
54 # unassert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
56 #endif
58 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } 27 } */
59 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } 28 } */
60 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } 29 } */
61 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } 30 } */