mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-12 09:41:26 +00:00
caa33d36fb
- Removed fix-it hints from template instaniations since changes to the templates are rarely helpful. - Changed the caret in template instaniations from the class/struct name to the class/struct keyword, matching the other warnings. - Do not offer fix-it hints when multiple declarations disagree. Warnings are still given. - Once a definition is found, offer a fix-it hint to all previous declarations with wrong tag. - Declarations that disagree with a previous definition will get a fix-it hint to change the declaration. llvm-svn: 132831
165 lines
5.9 KiB
C++
165 lines
5.9 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s
|
|
// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s
|
|
class X; // expected-note 2{{here}}
|
|
typedef struct X * X_t; // expected-warning{{previously declared}}
|
|
union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}}
|
|
|
|
template<typename T> struct Y; // expected-note{{did you mean class here?}}
|
|
template<class U> class Y { }; // expected-warning{{previously declared}}
|
|
|
|
class A;
|
|
class A; // expected-note{{previous use is here}}
|
|
struct A; // expected-warning{{struct 'A' was previously declared as a class}}
|
|
|
|
class B; // expected-note{{did you mean struct here?}}
|
|
class B; // expected-note{{previous use is here}}\
|
|
// expected-note{{did you mean struct here?}}
|
|
struct B; // expected-warning{{struct 'B' was previously declared as a class}}
|
|
struct B {}; // expected-warning{{'B' defined as a struct here but previously declared as a class}}
|
|
|
|
class C; // expected-note{{previous use is here}}
|
|
struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
|
|
// expected-note{{previous use is here}}\
|
|
// expected-note{{did you mean class here?}}
|
|
class C; // expected-warning{{class 'C' was previously declared as a struct}}\
|
|
// expected-note{{previous use is here}}
|
|
struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
|
|
// expected-note{{did you mean class here?}}
|
|
class C {}; // expected-warning{{'C' defined as a class here but previously declared as a struct}}
|
|
|
|
struct D {}; // expected-note{{previous definition is here}}\
|
|
// expected-note{{previous use is here}}
|
|
class D {}; // expected-error{{redefinition of 'D'}}
|
|
struct D;
|
|
class D; // expected-warning{{class 'D' was previously declared as a struct}}\
|
|
// expected-note{{did you mean struct here?}}
|
|
|
|
class E;
|
|
class E;
|
|
class E {};
|
|
class E;
|
|
|
|
struct F;
|
|
struct F;
|
|
struct F {};
|
|
struct F;
|
|
|
|
template<class U> class G; // expected-note{{previous use is here}}\
|
|
// expected-note{{did you mean struct here?}}
|
|
template<class U> struct G; // expected-warning{{struct template 'G' was previously declared as a class template}}
|
|
template<class U> struct G {}; // expected-warning{{'G' defined as a struct template here but previously declared as a class template}}
|
|
|
|
/*
|
|
*** 'X' messages ***
|
|
CHECK: warning: struct 'X' was previously declared as a class
|
|
CHECK: {{^}}typedef struct X * X_t;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class X;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: error: use of 'X' with tag type that does not match previous declaration
|
|
CHECK: {{^}}union X { int x; float y; };
|
|
CHECK: {{^}}^~~~~{{$}}
|
|
CHECK: {{^}}class{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class X;
|
|
CHECK: {{^}} ^{{$}}
|
|
*** 'Y' messages ***
|
|
CHECK: warning: 'Y' defined as a class template here but
|
|
previously declared as a struct template
|
|
CHECK: {{^}}template<class U> class Y { };
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: did you mean class here?
|
|
CHECK: {{^}}template<typename T> struct Y;
|
|
CHECK: {{^}} ^~~~~~{{$}}
|
|
CHECK: {{^}} class{{$}}
|
|
*** 'A' messages ***
|
|
CHECK: warning: struct 'A' was previously declared as a class
|
|
CHECK: {{^}}struct A;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class A;
|
|
CHECK: {{^}} ^{{$}}
|
|
*** 'B' messages ***
|
|
CHECK: warning: struct 'B' was previously declared as a class
|
|
CHECK: {{^}}struct B;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class B;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: 'B' defined as a struct here but previously declared as a class
|
|
CHECK: {{^}}struct B {};
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: did you mean struct here?
|
|
CHECK: {{^}}class B;
|
|
CHECK: {{^}}^~~~~{{$}}
|
|
CHECK: {{^}}struct{{$}}
|
|
CHECK: note: did you mean struct here?
|
|
CHECK: {{^}}class B;
|
|
CHECK: {{^}}^~~~~{{$}}
|
|
CHECK: {{^}}struct{{$}}
|
|
*** 'C' messages ***
|
|
CHECK: warning: struct 'C' was previously declared as a class
|
|
CHECK: {{^}}struct C;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class C;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: warning: class 'C' was previously declared as a struct
|
|
CHECK: {{^}}class C;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}struct C;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: warning: struct 'C' was previously declared as a class
|
|
CHECK: {{^}}struct C;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}class C;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: warning: 'C' defined as a class here but previously declared as a struct
|
|
CHECK: {{^}}class C {};
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: did you mean class here?
|
|
CHECK: {{^}}struct C;
|
|
CHECK: {{^}}^~~~~~{{$}}
|
|
CHECK: {{^}}class{{$}}
|
|
CHECK: note: did you mean class here?
|
|
CHECK: {{^}}struct C;
|
|
CHECK: {{^}}^~~~~~{{$}}
|
|
CHECK: {{^}}class{{$}}
|
|
*** 'D' messages ***
|
|
CHECK: error: redefinition of 'D'
|
|
CHECK: {{^}}class D {};
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: previous definition is here
|
|
CHECK: {{^}}struct D {};
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: warning: class 'D' was previously declared as a struct
|
|
CHECK: {{^}}class D;
|
|
CHECK: {{^}}^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}struct D {};
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: did you mean struct here?
|
|
CHECK: {{^}}class D;
|
|
CHECK: {{^}}^~~~~{{$}}
|
|
CHECK: {{^}}struct{{$}}
|
|
*** 'E' messages ***
|
|
*** 'F' messages ***
|
|
*** 'G' messages ***
|
|
CHECK: warning: struct template 'G' was previously declared as a class template
|
|
CHECK: {{^}}template<class U> struct G;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: previous use is here
|
|
CHECK: {{^}}template<class U> class G;
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: warning: 'G' defined as a struct template here but previously declared as a class template
|
|
CHECK: {{^}}template<class U> struct G {};
|
|
CHECK: {{^}} ^{{$}}
|
|
CHECK: note: did you mean struct here?
|
|
CHECK: {{^}}template<class U> class G;
|
|
CHECK: {{^}} ^~~~~
|
|
CHECK: {{^}} struct
|
|
*/
|