| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-std=gnu99" { target c } } */ |
| 3 |
/* { dg-options "-std=c++11" { target c++ } } */ |
| 4 |
|
| 5 |
/* Test that multi-line raw strings are lexed OK for all preprocessing |
| 6 |
directives where one could appear. Test raw-string-directive-2.c |
| 7 |
checks that #define is also processed properly. */ |
| 8 |
|
| 9 |
/* Note that in cases where we cause GCC to produce a multi-line error |
| 10 |
message, we construct the string so that the second line looks enough |
| 11 |
like an error message for DejaGNU to process it as such, so that we |
| 12 |
can use dg-warning or dg-error directives to check for it. */ |
| 13 |
|
| 14 |
#warning R"delim(line1 /* { dg-warning "line1" } */ |
| 15 |
file:15:1: warning: line2)delim" /* { dg-warning "line2" } */ |
| 16 |
|
| 17 |
#error R"delim(line3 /* { dg-error "line3" } */ |
| 18 |
file:18:1: error: line4)delim" /* { dg-error "line4" } */ |
| 19 |
|
| 20 |
#define X1 R"(line 5 |
| 21 |
line 6 |
| 22 |
line 7 |
| 23 |
line 8 |
| 24 |
/* |
| 25 |
// |
| 26 |
line 9)" R"delim( |
| 27 |
line10)delim" |
| 28 |
|
| 29 |
#define X2(a) X1 #a R"(line 11 |
| 30 |
/* |
| 31 |
line12 |
| 32 |
)" |
| 33 |
|
| 34 |
#if R"(line 13 /* { dg-error "line13" } */ |
| 35 |
file:35:1: error: line14)" |
| 36 |
#endif R"(line 15 /* { dg-warning "extra tokens at end of '#endif'" } */ |
| 37 |
\ |
| 38 |
line16)" "" |
| 39 |
|
| 40 |
#ifdef XYZ R"(line17 /* { dg-warning "extra tokens at end of '#ifdef'" } */ |
| 41 |
\ |
| 42 |
\ |
| 43 |
line18)" |
| 44 |
#endif |
| 45 |
|
| 46 |
#if 1 |
| 47 |
#else R"(line23 /* { dg-warning "extra tokens at end of '#else'" } */ |
| 48 |
\ |
| 49 |
|
| 50 |
line24)" |
| 51 |
#endif |
| 52 |
|
| 53 |
#if 0 |
| 54 |
#elif R"(line 25 /* { dg-error "line25" } */ |
| 55 |
file:55:1: error: line26)" |
| 56 |
#endif |
| 57 |
|
| 58 |
#line 60 R"(file:60:1: warning: this file has a space |
| 59 |
in it!)" |
| 60 |
#warning "line27" /* { dg-warning "line27" } */ |
| 61 |
/* { dg-warning "this file has a space" "#line check" { target *-*-* } 60 } */ |
| 62 |
#line 63 "file" |
| 63 |
|
| 64 |
#undef X1 R"(line28 /* { dg-warning "extra tokens at end of '#undef'" } */ |
| 65 |
line29 |
| 66 |
\ |
| 67 |
)" |
| 68 |
|
| 69 |
#ident R"(line30 |
| 70 |
line31)" R"(line 32 /* { dg-warning "extra tokens at end of '#ident'" } */ |
| 71 |
line 33)" |
| 72 |
|
| 73 |
#pragma GCC diagnostic ignored R"(-Woption /* { dg-warning "-Wpragmas" } */ |
| 74 |
-with-a-newline)" |