Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / diagnostic-token-ranges.c
blob31085be14211214d136db3d1bbb6a546752768e2
1 /* { dg-options "-fdiagnostics-show-caret -Wc++-compat -std=c11 -pedantic" } */
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" } */
13 { dg-begin-multiline-output "" }
14 name;
15 ^~~~
16 { dg-end-multiline-output "" }
20 void unknown_type_name (void)
22 foo bar; /* { dg-error "unknown type name 'foo'" } */
24 { dg-begin-multiline-output "" }
25 foo bar;
26 ^~~
27 { dg-end-multiline-output "" }
30 qux *baz; /* { dg-error "unknown type name 'qux'" } */
32 { dg-begin-multiline-output "" }
33 qux *baz;
34 ^~~
35 { dg-end-multiline-output "" }
39 void test_identifier_conflicts_with_cplusplus (void)
41 int new; /* { dg-warning "identifier 'new' conflicts with" } */
43 { dg-begin-multiline-output "" }
44 int new;
45 ^~~
46 { dg-end-multiline-output "" }
50 extern void
51 bogus_varargs (...); /* { dg-warning "ISO C requires a named argument before '...'" } */
53 { dg-begin-multiline-output "" }
54 bogus_varargs (...);
55 ^~~
56 { dg-end-multiline-output "" }
59 extern void
60 foo (unknown_type param); /* { dg-error "unknown type name 'unknown_type'" } */
62 { dg-begin-multiline-output "" }
63 foo (unknown_type param);
64 ^~~~~~~~~~~~
65 { dg-end-multiline-output "" }
68 void wide_string_literal_in_asm (void)
70 __asm (L"nop"); /* { dg-error "a wide string is invalid in this context" } */
72 { dg-begin-multiline-output "" }
73 __asm (L"nop");
74 ^~~~~~
75 { dg-end-multiline-output "" }
79 void break_and_continue_in_wrong_places (void)
81 if (0)
82 break; /* { dg-error "break statement not within loop or switch" } */
83 /* { dg-begin-multiline-output "" }
84 break;
85 ^~~~~
86 { dg-end-multiline-output "" } */
88 if (1)
90 else
91 continue; /* { dg-error "continue statement not within a loop" } */
92 /* { dg-begin-multiline-output "" }
93 continue;
94 ^~~~~~~~
95 { dg-end-multiline-output "" } */
98 /* Various examples of bad type decls. */
100 int float bogus; /* { dg-error "two or more data types in declaration specifiers" } */
101 /* { dg-begin-multiline-output "" }
102 int float bogus;
103 ^~~~~
104 { dg-end-multiline-output "" } */
106 long long long bogus2; /* { dg-error "'long long long' is too long for GCC" } */
107 /* { dg-begin-multiline-output "" }
108 long long long bogus2;
109 ^~~~
110 { dg-end-multiline-output "" } */
112 long short bogus3; /* { dg-error "both 'long' and 'short' in declaration specifiers" } */
113 /* { dg-begin-multiline-output "" }
114 long short bogus3;
115 ^~~~~
116 { dg-end-multiline-output "" } */
118 signed unsigned bogus4; /* { dg-error "both 'signed' and 'unsigned' in declaration specifiers" } */
119 /* { dg-begin-multiline-output "" }
120 signed unsigned bogus4;
121 ^~~~~~~~
122 { dg-end-multiline-output "" } */