121 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s2//3// This file contains typo correction tests which hit different code paths in C4// 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 8void PR21656(void) {9 float x;10 x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}11}12 13a = b ? : 0; // expected-error {{type specifier missing, defaults to 'int'}} \14 // expected-error {{use of undeclared identifier 'b'}}15 16int foobar; // expected-note {{'foobar' declared here}}17new_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 21struct ContainerStuct {22 enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}23};24 25void 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 32void banana(void); // expected-note {{'banana' declared here}}33int 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 38typedef long long __m128i __attribute__((__vector_size__(16)));39int 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 44void f(long *a, long b) {45 __atomic_or_fetch(a, b, c); // expected-error {{use of undeclared identifier 'c'}}46}47 48extern double cabs(_Complex double z);49void fn1(void) {50 cabs(errij); // expected-error {{use of undeclared identifier 'errij'}}51}52 53extern long afunction(int); // expected-note {{'afunction' declared here}} \54 expected-note {{passing argument to parameter here}}55void 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 61int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}62 63int fn_with_ids(void) { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}}64 65int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}}66 67void 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 conditional72// expression caused a crash in C mode.73//74// r272587 fixed a similar bug for binary operations. The same fix was needed for75// conditional expressions.76 77int g(int x, int y) {78 return x + y;79}80 81int 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 89void overloadable_callexpr(int arg) {90 func_overloadable(ar); //expected-error{{use of undeclared identifier}}91}92 93struct rdar38642201 {94 int fieldName;95};96 97void rdar38642201_callee(int x, int y);98void 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 107void PR40286_g(int x, int y);108void PR40286_h(int x, int y, int z);109void 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}112void 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}115void 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}118void 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}121