OSDN Git Service

* gcc.dg/cpp/19960224-2.c, 20000625-2.c, cxxcom2.c, directiv.c,
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cpp / directiv.c
1 /* Copyright (C) 2000 Free Software Foundation, Inc.  */
2
3 /* { dg-do preprocess } */
4 /* { dg-options -pedantic } */
5
6 /* Tests general directive syntax, and directive error recovery.  */
7
8
9 /* Test directive name is not expanded.  */
10 #define foo define
11 #foo EMPTY                      /* { dg-error "invalid" } */
12
13 /* Test # must be first on line.  */
14 EMPTY #define bar
15 #ifdef bar
16 #error bar is defined
17 #endif
18
19 /* Test form feed and vertical tab warn pedantically, see 6.10
20    paragraph 5.  Tab is OK.  */
21 #\fdefine something              /* { dg-warning "form feed" } */
22 #define \vsomething_else /* { dg-warning "vertical tab" } */
23 \f#define some   thing           /* Tab OK, as is form feed before #.  */
24
25 /* Our friend the null directive OK?  */
26 #
27
28 /* Check that directives always start a line, even if in middle of
29    macro expansion.  */
30 #define func(x) x
31 func (2         /* { dg-error "unterminated" "" { target *-*-* } 32 } */
32 #define foobar  /* { dg-error "directives may not" } */
33
34 /* For tidiness, I think the directive should still be processed
35    above.  Certainly, continuing to try to find the closing ')' can
36    lead to some really confusing error messages.  Hence this test.  */
37 #ifndef foobar
38 #error It is nice if the directive is processed!
39 #endif
40
41 /* Check newlines end directives, even in function-like macro
42    invocations.  6.10 paragraph 1.
43
44    Note that the #if is still treated as a conditional, so there
45    should be no errors about #endif without #if.  */
46 #if func (                      /* { dg-error "unterminated argument" } */
47 #endif