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