111
|
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" } */
|
|
7
|
|
8 #if 1
|
|
9
|
|
10 /* Block 1: K+R directives should have the # indented to warn. */
|
|
11
|
|
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" } */
|
|
16
|
|
17 /* Block 2: C89 directives should not have the # indented to warn. */
|
|
18
|
|
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" } */
|
|
23
|
|
24 /* Block 3: Extensions should not have the # indented to warn, _and_
|
|
25 they should get a -pedantic warning. */
|
|
26
|
|
27 #assert foo(bar) /* { dg-warning "indented" "^#ext" } */
|
|
28 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
|
|
29 # assert bar(baz) /* { dg-warning "indented" "^# ext" } */
|
|
30 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
|
|
31 #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
|
|
32 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
|
|
33 # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
|
|
34 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
|
|
35
|
|
36 #else
|
|
37
|
|
38 /* Block 1: K+R directives should have the # indented to warn. */
|
|
39
|
|
40 #undef foo bar /* { dg-bogus "indented" "^#kandr" } */
|
|
41 # undef foo bar /* { dg-bogus "indented" "^# kandr" } */
|
|
42 #undef foo bar /* { dg-warning "indented" "^ #kandr" } */
|
|
43 # undef foo bar /* { dg-warning "indented" "^ # kandr" } */
|
|
44
|
|
45 /* Block 2: C89 directives should not have the # indented to warn. */
|
|
46
|
|
47 #error whatever /* { dg-warning "indented" "^#c89" } */
|
|
48 # error whatever /* { dg-warning "indented" "^# c89" } */
|
|
49 #error whatever /* { dg-bogus "indented" "^ #c89" } */
|
|
50 # error whatever /* { dg-bogus "indented" "^ # c89" } */
|
|
51
|
|
52 /* Block 3: Extensions should not have the # indented to warn, and
|
|
53 they should _not_ get a -pedantic warning. */
|
|
54
|
|
55 #unassert foo(bar) /* { dg-warning "indented" "^#ext" } */
|
|
56 # unassert bar(baz) /* { dg-warning "indented" "^# ext" } */
|
|
57 #unassert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
|
|
58 # unassert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
|
|
59
|
|
60 #endif
|