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# assert bar(baz)	/* { dg-warning "indented" "^# ext"   } */
29 #assert baz(quux)	/* { dg-bogus "indented" "^ #ext"     } */
30 # assert quux(weeble)	/* { dg-bogus "indented" "^ # ext"    } */
31
32#else
33
34/* Block 1: K+R directives should have the # indented to warn.  */
35
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" } */
40
41/* Block 2: C89 directives should not have the # indented to warn.  */
42
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"     } */
47
48/* Block 3: Extensions should not have the # indented to warn, and
49   they should _not_ get a -pedantic warning. */
50
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"    } */
55
56#endif
57
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 } */
62