Merged with mainline at revision 128810.
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / dir-only-1.c
blob3c2261683c90cc90f5caa1eb5cb330fbcf161108
1 /* Copyright 2007 Free Software Foundation, Inc.
2 Contributed by Ollie Wild <aaw@google.com>. */
4 /* { dg-do preprocess } */
5 /* { dg-options -fdirectives-only } */
7 /* Tests scan_translation_unit_directives_only()'s handling of corner cases. */
9 /* Ignore directives inside block comments...
10 #error directive inside block comment
13 // Escaped newline doesn't terminate line comment \
14 #error directive inside line comment
16 /* A comment canot start inside a string. */
17 const char *c1 = "/*";
18 #define NOT_IN_COMMENT
19 const char *c2 = "*/";
20 #ifndef NOT_IN_COMMENT
21 #error Comment started inside a string literal
22 #endif
24 /* Escaped newline handling. */
25 int i; \
26 #error ignored escaped newline
29 #define BOL
30 #ifndef BOL
31 #error escaped newline did not preserve beginning of line
32 #endif
34 /* Handles \\ properly at the end of a string. */
35 "string ends in \\"/*
36 #error Missed string terminator.
39 /* Handles macro expansion in preprocessing directives. */
40 #define HEADER "dir-only-1.h"
41 #include HEADER
42 #ifndef GOT_HEADER
43 #error Failed to include header.
44 #endif
48 #define IN_COMMENT
50 #ifdef IN_COMMENT
51 #error Escaped newline breaks block comment initiator.
52 #endif
57 #define NOT_IN_COMMENT2
58 /**/
59 #ifndef NOT_IN_COMMENT2
60 #error Escaped newline breaks block comment terminator.
61 #endif
63 /* Test escaped newline inside character escape sequence. */
64 "\\
65 \"/*
66 #error Missed string terminator
69 /* Block comments don't mask trailing preprocessing
70 directive. */ #define NOT_MASKED
71 #ifndef NOT_MASKED
72 #error Comment masks trailing directive.
73 #endif