1 /* Copyright (C) 2001 Free Software Foundation, Inc.
2 Contributed by Nathan Sidwell 8 May 2001 <nathan@codesourcery.com> */
3
4 /* Test of prohibition on directives which result from macro expansion.
5 See also direct2s.c */
6
7 /*
8 { dg-options "-ftrack-macro-expansion=0" }
9 { dg-do compile } */
10
11 #define HASH #
12 #define HASHDEFINE #define
13 #define HASHINCLUDE #include
14
15 HASH include "somerandomfile" /*{ dg-error "stray" "non-include" }*/
16 /*{ dg-bogus "No such" "don't execute non-include" { target *-*-* } .-1 }*/
17 int resync_parser_1; /*{ dg-error "parse|syntax|expected" "" { target *-*-* } .-2 }*/
18
19 HASHINCLUDE <somerandomfile> /*{ dg-error "stray|expected" "non-include 2" }*/
20 /*{ dg-bogus "No such" "don't execute non-include 2" { target *-*-* } .-1 }*/
21 int resync_parser_2;
22
g1()23 void g1 ()
24 {
25 HASH define X 1 /* { dg-error "stray|unknown|expected" "# from macro" } */
26 int resync_parser_3;
27 }
28
g2()29 void g2 ()
30 {
31 HASHDEFINE Y 1 /* { dg-error "stray|unknown|expected" "#define from macro" } */
32 int resync_parser_4;
33 }
34
35 #pragma GCC dependency "direct2.c"
36 #
37
f()38 void f ()
39 {
40 int i = X; /* { dg-error "undeclared|for each" "no macro X" } */
41 int j = Y; /* { dg-error "undeclared|for each" "no macro Y" } */
42 }
43
44 #define slashstar /##*
45 #define starslash *##/
46
47 slashstar starslash /* { dg-error "parse error|syntax error|expected" "not a comment" } */
48 /* { dg-error "does not give" "paste warning(s)" { target *-*-* } .-1 } */
49