annotate gcc/testsuite/gcc.dg/cpp/tr-warn3.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for warnings about nontraditional directives inside the unused
kono
parents:
diff changeset
2 clauses of #if statements. Extensions do _not_ receive pedantic
kono
parents:
diff changeset
3 warnings inside unused clauses because they are often hidden this
kono
parents:
diff changeset
4 way on purpose. However they do still require indentation for K&R. */
kono
parents:
diff changeset
5 /* { dg-do preprocess } */
kono
parents:
diff changeset
6 /* { dg-options "-pedantic -Wtraditional" } */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 #if 1
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 /* Block 1: K+R directives should have the # indented to warn. */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 #define foo bar /* { dg-bogus "indented" "^#kandr" } */
kono
parents:
diff changeset
13 # define foo bar /* { dg-bogus "indented" "^# kandr" } */
kono
parents:
diff changeset
14 #define foo bar /* { dg-warning "indented" "^ #kandr" } */
kono
parents:
diff changeset
15 # define foo bar /* { dg-warning "indented" "^ # kandr" } */
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 /* Block 2: C89 directives should not have the # indented to warn. */
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 #pragma whatever /* { dg-warning "indented" "^#c89" } */
kono
parents:
diff changeset
20 # pragma whatever /* { dg-warning "indented" "^# c89" } */
kono
parents:
diff changeset
21 #pragma whatever /* { dg-bogus "indented" "^ #c89" } */
kono
parents:
diff changeset
22 # pragma whatever /* { dg-bogus "indented" "^ # c89" } */
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 /* Block 3: Extensions should not have the # indented to warn, _and_
kono
parents:
diff changeset
25 they should get a -pedantic warning. */
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 #assert foo(bar) /* { dg-warning "indented" "^#ext" } */
kono
parents:
diff changeset
28 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
kono
parents:
diff changeset
29 # assert bar(baz) /* { dg-warning "indented" "^# ext" } */
kono
parents:
diff changeset
30 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
kono
parents:
diff changeset
31 #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
kono
parents:
diff changeset
32 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
kono
parents:
diff changeset
33 # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
kono
parents:
diff changeset
34 /* { dg-warning "GCC extension" "extension warning" { target *-*-* } .-1 } */
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #else
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 /* Block 1: K+R directives should have the # indented to warn. */
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 #undef foo bar /* { dg-bogus "indented" "^#kandr" } */
kono
parents:
diff changeset
41 # undef foo bar /* { dg-bogus "indented" "^# kandr" } */
kono
parents:
diff changeset
42 #undef foo bar /* { dg-warning "indented" "^ #kandr" } */
kono
parents:
diff changeset
43 # undef foo bar /* { dg-warning "indented" "^ # kandr" } */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 /* Block 2: C89 directives should not have the # indented to warn. */
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 #error whatever /* { dg-warning "indented" "^#c89" } */
kono
parents:
diff changeset
48 # error whatever /* { dg-warning "indented" "^# c89" } */
kono
parents:
diff changeset
49 #error whatever /* { dg-bogus "indented" "^ #c89" } */
kono
parents:
diff changeset
50 # error whatever /* { dg-bogus "indented" "^ # c89" } */
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* Block 3: Extensions should not have the # indented to warn, and
kono
parents:
diff changeset
53 they should _not_ get a -pedantic warning. */
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 #unassert foo(bar) /* { dg-warning "indented" "^#ext" } */
kono
parents:
diff changeset
56 # unassert bar(baz) /* { dg-warning "indented" "^# ext" } */
kono
parents:
diff changeset
57 #unassert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
kono
parents:
diff changeset
58 # unassert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 #endif