96 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2typedef int INT;3typedef INT REALLY_INT; // expected-note {{previous definition is here}}4typedef REALLY_INT REALLY_REALLY_INT;5typedef REALLY_INT BOB;6typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT' (aka 'int'))}}7 8struct X {9 typedef int result_type; // expected-note {{previous definition is here}}10 typedef INT result_type; // expected-error {{redefinition of 'result_type'}}11};12 13struct Y; // expected-note{{previous definition is here}}14typedef int Y; // expected-error{{typedef redefinition with different types ('int' vs 'Y')}}15 16typedef int Y2; // expected-note{{declared here}}17struct Y2; // expected-error{{definition of type 'Y2' conflicts with typedef of the same name}}18 19void f(); // expected-note{{previous definition is here}}20typedef int f; // expected-error{{redefinition of 'f' as different kind of symbol}}21 22typedef int f2; // expected-note{{previous definition is here}}23void f2(); // expected-error{{redefinition of 'f2' as different kind of symbol}}24 25typedef struct s s; 26typedef int I; 27typedef int I; 28typedef I I; 29 30struct s { };31 32// PR587433namespace test1 {34 typedef int foo;35 namespace a { using test1::foo; };36 typedef int foo;37 using namespace a; 38 foo x;39}40 41namespace PR6923 {42 struct A;43 44 extern "C" {45 struct A;46 typedef struct A A;47 }48 49 struct A;50}51 52namespace PR7462 {53 struct A {};54 typedef int operator! (A); // expected-error{{typedef name must be an identifier}}55 int i = !A(); // expected-error{{invalid argument type}}56}57 58template<typename T>59typedef T f(T t) { return t; } // expected-error {{function definition declared 'typedef'}}60int k = f(0);61int k2 = k;62 63namespace PR11630 {64 template <class T>65 struct S66 {67 static const unsigned C = 1;68 static void f()69 {70 typedef int q[C == 1 ? 1 : -1]; // expected-note{{previous definition is here}}71 typedef int q[C >= 1 ? 2 : -2]; // expected-error{{typedef redefinition with different types ('int[2]' vs 'int[1]')}}72 typedef int n[C == 1 ? 1 : -1];73 typedef int n[C >= 1 ? 1 : -1];74 }75 };76 77 template <int T>78 struct S279 {80 static void f()81 {82 typedef int q[1]; // expected-note{{previous definition is here}}83 typedef int q[T]; // expected-error{{typedef redefinition with different types ('int[2]' vs 'int[1]')}}84 }85 };86 87 void f() {88 S<int> a;89 a.f();90 S2<1> b;91 b.f();92 S2<2> b2;93 b2.f(); // expected-note{{in instantiation of member function 'PR11630::S2<2>::f' requested here}}94 }95}96