| 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() { |
| 9 | float x; |
| 10 | x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}} |
| 11 | } |
| 12 | |
| 13 | a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \ |
| 14 | // expected-error {{use of undeclared identifier 'b'}} |
| 15 | |
| 16 | int foobar; // expected-note {{'foobar' declared here}} |
| 17 | a = goobar ?: 4; // expected-warning {{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-warning {{implicit declaration of function 'foo'}} \ |
| 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() { |
| 50 | cabs(errij); // expected-error {{use of undeclared identifier 'errij'}} |
| 51 | } |
| 52 | |
| 53 | extern long afunction(int); // expected-note {{'afunction' declared here}} |
| 54 | void fn2() { |
| 55 | f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}} |
| 56 | afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}} |
| 57 | } |
| 58 | |
| 59 | int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}} |
| 60 | |
| 61 | int fn_with_ids() { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}} |
| 62 | |
| 63 | int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}} |
| 64 | |
| 65 | void fn_with_unknown(int a, int b) { |
| 66 | fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}} |
| 67 | } |
| 68 | |
| 69 | // Two typos in a parenthesized expression or argument list with a conditional |
| 70 | // expression caused a crash in C mode. |
| 71 | // |
| 72 | // r272587 fixed a similar bug for binary operations. The same fix was needed for |
| 73 | // conditional expressions. |
| 74 | |
| 75 | int g(int x, int y) { |
| 76 | return x + y; |
| 77 | } |
| 78 | |
| 79 | int h() { |
| 80 | g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}} |
| 81 | (x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}} |
| 82 | } |
| 83 | |
| 84 | __attribute__((overloadable)) void func_overloadable(int); |
| 85 | __attribute__((overloadable)) void func_overloadable(float); |
| 86 | |
| 87 | void overloadable_callexpr(int arg) { |
| 88 | func_overloadable(ar); //expected-error{{use of undeclared identifier}} |
| 89 | } |
| 90 | |
| 91 | // rdar://problem/38642201 |
| 92 | struct rdar38642201 { |
| 93 | int fieldName; |
| 94 | }; |
| 95 | |
| 96 | void rdar38642201_callee(int x, int y); |
| 97 | void rdar38642201_caller() { |
| 98 | struct rdar38642201 structVar; |
| 99 | rdar38642201_callee( |
| 100 | structVar1.fieldName1.member1, //expected-error{{use of undeclared identifier 'structVar1'}} |
| 101 | structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}} |
| 102 | } |
| 103 | |
| 104 | void PR40286_g(int x, int y); |
| 105 | void PR40286_h(int x, int y, int z); |
| 106 | void PR40286_1(int the_value) { |
| 107 | PR40286_g(the_walue); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 108 | } |
| 109 | void PR40286_2(int the_value) { |
| 110 | PR40286_h(the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 111 | } |
| 112 | void PR40286_3(int the_value) { |
| 113 | PR40286_h(the_walue); // expected-error {{use of undeclared identifier 'the_walue'}} |
| 114 | } |
| 115 | void PR40286_4(int the_value) { // expected-note {{'the_value' declared here}} |
| 116 | PR40286_h(the_value, the_value, the_walue); // expected-error {{use of undeclared identifier 'the_walue'; did you mean 'the_value'?}} |
| 117 | } |
| 118 | |