[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gcc.dg / diagnostic-token-ranges.c
blob2ef7a01c48e113e59a9ec5541291bef33c2b2455
1 /* { dg-options "-fdiagnostics-show-caret -Wc++-compat -std=c11" } */
3 /* Verify that various diagnostics show source code ranges. */
5 long double nanl (const char *);
7 /* These ones merely use token ranges; they don't use tree ranges. */
9 void undeclared_identifier (void)
11 name; /* { dg-error "'name' undeclared .first use in this function.; did you mean .nanl." } */
13 { dg-begin-multiline-output "" }
14 name;
15 ^~~~
16 nanl
17 { dg-end-multiline-output "" }
21 void unknown_type_name (void)
23 foo bar; /* { dg-error "unknown type name 'foo'" } */
25 { dg-begin-multiline-output "" }
26 foo bar;
27 ^~~
28 { dg-end-multiline-output "" }
31 qux *baz; /* { dg-error "unknown type name 'qux'" } */
33 { dg-begin-multiline-output "" }
34 qux *baz;
35 ^~~
36 { dg-end-multiline-output "" }
40 void test_identifier_conflicts_with_cplusplus (void)
42 int new; /* { dg-warning "identifier 'new' conflicts with" } */
44 { dg-begin-multiline-output "" }
45 int new;
46 ^~~
47 { dg-end-multiline-output "" }
51 extern void
52 bogus_varargs (...); /* { dg-error "ISO C requires a named argument before '...'" } */
54 { dg-begin-multiline-output "" }
55 bogus_varargs (...);
56 ^~~
57 { dg-end-multiline-output "" }
60 extern void
61 foo (unknown_type param); /* { dg-error "unknown type name 'unknown_type'" } */
63 { dg-begin-multiline-output "" }
64 foo (unknown_type param);
65 ^~~~~~~~~~~~
66 { dg-end-multiline-output "" }
69 void wide_string_literal_in_asm (void)
71 __asm (L"nop"); /* { dg-error "wide string literal in 'asm'" } */
73 { dg-begin-multiline-output "" }
74 __asm (L"nop");
75 ^~~~~~
76 { dg-end-multiline-output "" }
80 void break_and_continue_in_wrong_places (void)
82 if (0)
83 break; /* { dg-error "break statement not within loop or switch" } */
84 /* { dg-begin-multiline-output "" }
85 break;
86 ^~~~~
87 { dg-end-multiline-output "" } */
89 if (1)
91 else
92 continue; /* { dg-error "continue statement not within a loop" } */
93 /* { dg-begin-multiline-output "" }
94 continue;
95 ^~~~~~~~
96 { dg-end-multiline-output "" } */
99 /* Various examples of bad type decls. */
101 int float bogus; /* { dg-error "two or more data types in declaration specifiers" } */
102 /* { dg-begin-multiline-output "" }
103 int float bogus;
104 ^~~~~
105 { dg-end-multiline-output "" } */
107 long long long bogus2; /* { dg-error "'long long long' is too long for GCC" } */
108 /* { dg-begin-multiline-output "" }
109 long long long bogus2;
110 ^~~~
111 { dg-end-multiline-output "" } */
113 long short bogus3; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */
114 /* { dg-begin-multiline-output "" }
115 long short bogus3;
116 ^~~~~
117 { dg-end-multiline-output "" } */
119 signed unsigned bogus4; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */
120 /* { dg-begin-multiline-output "" }
121 signed unsigned bogus4;
122 ^~~~~~~~
123 { dg-end-multiline-output "" } */