Home | History | Annotate | Download | only in Sema
      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