1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s 2*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s 3*f4a2713aSLionel Sambuc class X; // expected-note 2{{here}} 4*f4a2713aSLionel Sambuc typedef struct X * X_t; // expected-warning{{previously declared}} 5*f4a2713aSLionel Sambuc union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}} 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc template<typename T> struct Y; // expected-note{{did you mean class here?}} 8*f4a2713aSLionel Sambuc template<class U> class Y { }; // expected-warning{{previously declared}} 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc class A; 11*f4a2713aSLionel Sambuc class A; // expected-note{{previous use is here}} 12*f4a2713aSLionel Sambuc struct A; // expected-warning{{struct 'A' was previously declared as a class}} 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc class B; // expected-note{{did you mean struct here?}} 15*f4a2713aSLionel Sambuc class B; // expected-note{{previous use is here}}\ 16*f4a2713aSLionel Sambuc // expected-note{{did you mean struct here?}} 17*f4a2713aSLionel Sambuc struct B; // expected-warning{{struct 'B' was previously declared as a class}} 18*f4a2713aSLionel Sambuc struct B {}; // expected-warning{{'B' defined as a struct here but previously declared as a class}} 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc class C; // expected-note{{previous use is here}} 21*f4a2713aSLionel Sambuc struct C; // expected-warning{{struct 'C' was previously declared as a class}}\ 22*f4a2713aSLionel Sambuc // expected-note{{previous use is here}}\ 23*f4a2713aSLionel Sambuc // expected-note{{did you mean class here?}} 24*f4a2713aSLionel Sambuc class C; // expected-warning{{class 'C' was previously declared as a struct}}\ 25*f4a2713aSLionel Sambuc // expected-note{{previous use is here}} 26*f4a2713aSLionel Sambuc struct C; // expected-warning{{struct 'C' was previously declared as a class}}\ 27*f4a2713aSLionel Sambuc // expected-note{{did you mean class here?}} 28*f4a2713aSLionel Sambuc class C {}; // expected-warning{{'C' defined as a class here but previously declared as a struct}} 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc struct D {}; // expected-note{{previous definition is here}}\ 31*f4a2713aSLionel Sambuc // expected-note{{previous use is here}} 32*f4a2713aSLionel Sambuc class D {}; // expected-error{{redefinition of 'D'}} 33*f4a2713aSLionel Sambuc struct D; 34*f4a2713aSLionel Sambuc class D; // expected-warning{{class 'D' was previously declared as a struct}}\ 35*f4a2713aSLionel Sambuc // expected-note{{did you mean struct here?}} 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc class E; 38*f4a2713aSLionel Sambuc class E; 39*f4a2713aSLionel Sambuc class E {}; 40*f4a2713aSLionel Sambuc class E; 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc struct F; 43*f4a2713aSLionel Sambuc struct F; 44*f4a2713aSLionel Sambuc struct F {}; 45*f4a2713aSLionel Sambuc struct F; 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc template<class U> class G; // expected-note{{previous use is here}}\ 48*f4a2713aSLionel Sambuc // expected-note{{did you mean struct here?}} 49*f4a2713aSLionel Sambuc template<class U> struct G; // expected-warning{{struct template 'G' was previously declared as a class template}} 50*f4a2713aSLionel Sambuc template<class U> struct G {}; // expected-warning{{'G' defined as a struct template here but previously declared as a class template}} 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuc /* 53*f4a2713aSLionel Sambuc *** 'X' messages *** 54*f4a2713aSLionel Sambuc CHECK: warning: struct 'X' was previously declared as a class 55*f4a2713aSLionel Sambuc CHECK: {{^}}typedef struct X * X_t; 56*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 57*f4a2713aSLionel Sambuc CHECK: note: previous use is here 58*f4a2713aSLionel Sambuc CHECK: {{^}}class X; 59*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 60*f4a2713aSLionel Sambuc CHECK: error: use of 'X' with tag type that does not match previous declaration 61*f4a2713aSLionel Sambuc CHECK: {{^}}union X { int x; float y; }; 62*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~{{$}} 63*f4a2713aSLionel Sambuc CHECK: {{^}}class{{$}} 64*f4a2713aSLionel Sambuc CHECK: note: previous use is here 65*f4a2713aSLionel Sambuc CHECK: {{^}}class X; 66*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 67*f4a2713aSLionel Sambuc *** 'Y' messages *** 68*f4a2713aSLionel Sambuc CHECK: warning: 'Y' defined as a class template here but 69*f4a2713aSLionel Sambuc previously declared as a struct template 70*f4a2713aSLionel Sambuc CHECK: {{^}}template<class U> class Y { }; 71*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 72*f4a2713aSLionel Sambuc CHECK: note: did you mean class here? 73*f4a2713aSLionel Sambuc CHECK: {{^}}template<typename T> struct Y; 74*f4a2713aSLionel Sambuc CHECK: {{^}} ^~~~~~{{$}} 75*f4a2713aSLionel Sambuc CHECK: {{^}} class{{$}} 76*f4a2713aSLionel Sambuc *** 'A' messages *** 77*f4a2713aSLionel Sambuc CHECK: warning: struct 'A' was previously declared as a class 78*f4a2713aSLionel Sambuc CHECK: {{^}}struct A; 79*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 80*f4a2713aSLionel Sambuc CHECK: note: previous use is here 81*f4a2713aSLionel Sambuc CHECK: {{^}}class A; 82*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 83*f4a2713aSLionel Sambuc *** 'B' messages *** 84*f4a2713aSLionel Sambuc CHECK: warning: struct 'B' was previously declared as a class 85*f4a2713aSLionel Sambuc CHECK: {{^}}struct B; 86*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 87*f4a2713aSLionel Sambuc CHECK: note: previous use is here 88*f4a2713aSLionel Sambuc CHECK: {{^}}class B; 89*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 90*f4a2713aSLionel Sambuc CHECK: 'B' defined as a struct here but previously declared as a class 91*f4a2713aSLionel Sambuc CHECK: {{^}}struct B {}; 92*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 93*f4a2713aSLionel Sambuc CHECK: note: did you mean struct here? 94*f4a2713aSLionel Sambuc CHECK: {{^}}class B; 95*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~{{$}} 96*f4a2713aSLionel Sambuc CHECK: {{^}}struct{{$}} 97*f4a2713aSLionel Sambuc CHECK: note: did you mean struct here? 98*f4a2713aSLionel Sambuc CHECK: {{^}}class B; 99*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~{{$}} 100*f4a2713aSLionel Sambuc CHECK: {{^}}struct{{$}} 101*f4a2713aSLionel Sambuc *** 'C' messages *** 102*f4a2713aSLionel Sambuc CHECK: warning: struct 'C' was previously declared as a class 103*f4a2713aSLionel Sambuc CHECK: {{^}}struct C; 104*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 105*f4a2713aSLionel Sambuc CHECK: note: previous use is here 106*f4a2713aSLionel Sambuc CHECK: {{^}}class C; 107*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 108*f4a2713aSLionel Sambuc CHECK: warning: class 'C' was previously declared as a struct 109*f4a2713aSLionel Sambuc CHECK: {{^}}class C; 110*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 111*f4a2713aSLionel Sambuc CHECK: note: previous use is here 112*f4a2713aSLionel Sambuc CHECK: {{^}}struct C; 113*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 114*f4a2713aSLionel Sambuc CHECK: warning: struct 'C' was previously declared as a class 115*f4a2713aSLionel Sambuc CHECK: {{^}}struct C; 116*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 117*f4a2713aSLionel Sambuc CHECK: note: previous use is here 118*f4a2713aSLionel Sambuc CHECK: {{^}}class C; 119*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 120*f4a2713aSLionel Sambuc CHECK: warning: 'C' defined as a class here but previously declared as a struct 121*f4a2713aSLionel Sambuc CHECK: {{^}}class C {}; 122*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 123*f4a2713aSLionel Sambuc CHECK: note: did you mean class here? 124*f4a2713aSLionel Sambuc CHECK: {{^}}struct C; 125*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~~{{$}} 126*f4a2713aSLionel Sambuc CHECK: {{^}}class{{$}} 127*f4a2713aSLionel Sambuc CHECK: note: did you mean class here? 128*f4a2713aSLionel Sambuc CHECK: {{^}}struct C; 129*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~~{{$}} 130*f4a2713aSLionel Sambuc CHECK: {{^}}class{{$}} 131*f4a2713aSLionel Sambuc *** 'D' messages *** 132*f4a2713aSLionel Sambuc CHECK: error: redefinition of 'D' 133*f4a2713aSLionel Sambuc CHECK: {{^}}class D {}; 134*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 135*f4a2713aSLionel Sambuc CHECK: note: previous definition is here 136*f4a2713aSLionel Sambuc CHECK: {{^}}struct D {}; 137*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 138*f4a2713aSLionel Sambuc CHECK: warning: class 'D' was previously declared as a struct 139*f4a2713aSLionel Sambuc CHECK: {{^}}class D; 140*f4a2713aSLionel Sambuc CHECK: {{^}}^{{$}} 141*f4a2713aSLionel Sambuc CHECK: note: previous use is here 142*f4a2713aSLionel Sambuc CHECK: {{^}}struct D {}; 143*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 144*f4a2713aSLionel Sambuc CHECK: note: did you mean struct here? 145*f4a2713aSLionel Sambuc CHECK: {{^}}class D; 146*f4a2713aSLionel Sambuc CHECK: {{^}}^~~~~{{$}} 147*f4a2713aSLionel Sambuc CHECK: {{^}}struct{{$}} 148*f4a2713aSLionel Sambuc *** 'E' messages *** 149*f4a2713aSLionel Sambuc *** 'F' messages *** 150*f4a2713aSLionel Sambuc *** 'G' messages *** 151*f4a2713aSLionel Sambuc CHECK: warning: struct template 'G' was previously declared as a class template 152*f4a2713aSLionel Sambuc CHECK: {{^}}template<class U> struct G; 153*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 154*f4a2713aSLionel Sambuc CHECK: note: previous use is here 155*f4a2713aSLionel Sambuc CHECK: {{^}}template<class U> class G; 156*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 157*f4a2713aSLionel Sambuc CHECK: warning: 'G' defined as a struct template here but previously declared as a class template 158*f4a2713aSLionel Sambuc CHECK: {{^}}template<class U> struct G {}; 159*f4a2713aSLionel Sambuc CHECK: {{^}} ^{{$}} 160*f4a2713aSLionel Sambuc CHECK: note: did you mean struct here? 161*f4a2713aSLionel Sambuc CHECK: {{^}}template<class U> class G; 162*f4a2713aSLionel Sambuc CHECK: {{^}} ^~~~~ 163*f4a2713aSLionel Sambuc CHECK: {{^}} struct 164*f4a2713aSLionel Sambuc */ 165