| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
// |
| 3 |
// This file contains typo correction tests which hit different code paths in C |
| 4 |
// than in C++ and may exhibit different behavior as a result. |
| 5 |
|
| 6 |
__typeof__(struct F*) var[invalid]; // expected-error-re {{use of undeclared identifier 'invalid'{{$}}}} |
| 7 |
|
| 8 |
void PR21656(void) { |
| 9 |
float x; |
| 10 |
x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}} |
| 11 |
} |
| 12 |
|
| 13 |
a = b ? : 0; // expected-error {{type specifier missing, defaults to 'int'}} \ |
| 14 |
// expected-error {{use of undeclared identifier 'b'}} |
| 15 |
|
| 16 |
int foobar; // expected-note {{'foobar' declared here}} |
| 17 |
new_a = goobar ?: 4; // expected-error {{type specifier missing, defaults to 'int'}} \ |
| 18 |
// expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \ |
| 19 |
// expected-error {{initializer element is not a compile-time constant}} |
| 20 |
|
| 21 |
struct ContainerStuct { |
| 22 |
enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}} |
| 23 |
}; |
| 24 |
|
| 25 |
void func(int arg) { |
| 26 |
switch (arg) { |
| 27 |
case SOME_ENUM_: // expected-error {{use of undeclared identifier 'SOME_ENUM_'; did you mean 'SOME_ENUM'}} |
| 28 |
; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
void banana(void); // expected-note {{'banana' declared here}} |
| 33 |
int c11Generic(int arg) { |
| 34 |
_Generic(hello, int : banana)(); // expected-error-re {{use of undeclared identifier 'hello'{{$}}}} |
| 35 |
_Generic(arg, int : bandana)(); // expected-error {{use of undeclared identifier 'bandana'; did you mean 'banana'?}} |
| 36 |
} |
| 37 |
|
| 38 |
typedef long long __m128i __attribute__((__vector_size__(16))); |
| 39 |
int PR23101(__m128i __x) { |
| 40 |
return foo((__v2di)__x); // expected-error {{call to undeclared function 'foo'; ISO C99 and later do not support implicit function declarations}} \ |
| 41 |
// expected-error {{use of undeclared identifier '__v2di'}} |
| 42 |
} |
| 43 |
|
| 44 |
void f(long *a, long b) { |
| 45 |
__atomic_or_fetch(a, b, c); // expected-error {{use of undeclared identifier 'c'}} |
| 46 |
} |
| 47 |
|
| 48 |
extern double cabs(_Complex double z); |
| 49 |
void fn1(void) { |
| 50 |
cabs(errij); // expected-error {{use of undeclared identifier 'errij'}} |
| 51 |
} |
| 52 |
|
| 53 |
extern long afunction(int); // expected-note {{'afunction' declared here}} \ |
| 54 |
expected-note {{passing argument to parameter here}} |
| 55 |
void fn2(void) { |
| 56 |
f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}} |
| 57 |
afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'}} \ |
| 58 |
expected-error {{incompatible pointer to integer conversion passing 'long (int)' to parameter of type 'int'}} |
| 59 |
} |
| 60 |
|
| 61 |
int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}} |
| 62 |
|
| 63 |
int fn_with_ids(void) { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}} |
| 64 |
|
| 65 |
int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}} |
| 66 |
|
| 67 |
void fn_with_unknown(int a, int b) { |
| 68 |
fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}} |
| 69 |
} |
| 70 |
|
| 71 |
// Two typos in a parenthesized expression or argument list with a conditional |
| 72 |
// expression caused a crash in C mode. |
| 73 |
// |
| 74 |
// r272587 fixed a similar bug for binary operations. The same fix was needed for |
| 75 |
// conditional expressions. |
| 76 |
|
| 77 |
int g(int x, int y) { |
| 78 |
return x + y; |
| 79 |
} |
| 80 |
|
| 81 |
int h(void) { |
| 82 |
g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}} |
| 83 |
(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}} |
| 84 |
} |
| 85 |
|
| 86 |
__attribute__((overloadable)) void func_overloadable(int); |
| 87 |
__attribute__((overloadable)) void func_overloadable(float); |
| 88 |
|
| 89 |
void overloadable_callexpr(int arg) { |
| 90 |
func_overloadable(ar); //expected-error{{use of undeclared identifier}} |
| 91 |
} |
| 92 |
|
| 93 |
struct rdar38642201 { |
| 94 |
int fieldName; |
| 95 |
}; |
| 96 |
|
| 97 |
void rdar38642201_callee(int x, int y); |
| 98 |
void rdar38642201_caller(void) { |
| 99 |
struct rdar38642201 structVar; // expected-note 2{{'structVar' declared here}} |
| 100 |
rdar38642201_callee( |
| 101 |
structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'}} \ |
| 102 |
expected-error{{no member named 'fieldName1' in 'struct rdar38642201'}} |
| 103 |
structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}} \ |
| 104 |
expected-error{{no member named 'fieldName2' in 'struct rdar38642201'}} |
| 105 |
} |
| 106 |
|
| 107 |
void PR40286_g(int x, int y); |
| 108 |
void PR40286_h(int x, int y, int z); |
| 109 |
void PR40286_1(int the_value) { // expected-note {{'the_value' declared here}} |
| 110 |
PR40286_g(the_walue, 0); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 111 |
} |
| 112 |
void PR40286_2(int the_value) { // expected-note {{'the_value' declared here}} |
| 113 |
PR40286_h(the_value, the_walue, 0); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 114 |
} |
| 115 |
void PR40286_3(int the_value) { // expected-note {{'the_value' declared here}} |
| 116 |
PR40286_h(the_walue, 0, 0); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 117 |
} |
| 118 |
void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}} |
| 119 |
PR40286_h(the_value, the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'?}} |
| 120 |
} |