Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/warn/Wmismatched-tags-4.C @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
145:1830386684a0 | 152:2b5abeee2509 |
---|---|
1 /* PR c++/94078 - bogus and missing -Wmismatched-tags on an instance | |
2 of a template | |
3 Verify that -Wmismatched-tags is issued for redeclarations and | |
4 instances of the appropriate primary template or specialization. | |
5 { dg-do compile } | |
6 { dg-options "-Wmismatched-tags" } */ | |
7 | |
8 // Exercise explicit specialization. | |
9 template <class> class S1; | |
10 template <> struct S1<int>; | |
11 | |
12 template <class> class S1; | |
13 template <class> struct S1; // { dg-warning "\\\[-Wmismatched-tags" } | |
14 | |
15 template <> class S1<char>; | |
16 template <> struct S1<char>; // { dg-warning "\\\[-Wmismatched-tags" } | |
17 | |
18 template <> class S1<int>; // { dg-warning "\\\[-Wmismatched-tags" } | |
19 template <> struct S1<int>; | |
20 | |
21 extern S1<void> s1v; | |
22 extern class S1<void> s1v; | |
23 extern struct S1<void> s1v; // { dg-warning "\\\[-Wmismatched-tags" } | |
24 | |
25 extern S1<int> s1i; | |
26 extern class S1<int> s1i; // { dg-warning "\\\[-Wmismatched-tags" } | |
27 extern struct S1<int> s1i; | |
28 | |
29 extern S1<char> s1c; | |
30 extern class S1<char> s1c; | |
31 extern struct S1<char> s1c; // { dg-warning "\\\[-Wmismatched-tags" } | |
32 | |
33 | |
34 // Exercise partial specialization. | |
35 template <class> struct S2; | |
36 template <class T> class S2<const T>; | |
37 | |
38 template <class> class S2; // { dg-warning "\\\[-Wmismatched-tags" } | |
39 template <class> struct S2; | |
40 | |
41 template <class T> class S2<const T>; | |
42 template <class T> struct S2<const T>;// { dg-warning "\\\[-Wmismatched-tags" } | |
43 | |
44 extern S2<int> s2i; | |
45 extern class S2<int> s2i; // { dg-warning "\\\[-Wmismatched-tags" } | |
46 extern struct S2<int> s2i; | |
47 | |
48 extern S2<const int> s2ci; | |
49 extern class S2<const int> s2ci; | |
50 extern struct S2<const int> s2ci; // { dg-warning "\\\[-Wmismatched-tags" } | |
51 | |
52 | |
53 template <class> struct S3; | |
54 template <class T> class S3<T*>; | |
55 template <class T> struct S3<T&>; | |
56 | |
57 template <class> class S3; // { dg-warning "\\\[-Wmismatched-tags" } | |
58 template <class> struct S3; | |
59 | |
60 template <class T> class S3<T*>; | |
61 template <class T> struct S3<T*>; // { dg-warning "\\\[-Wmismatched-tags" } | |
62 | |
63 template <class T> class S3<T&>; // { dg-warning "\\\[-Wmismatched-tags" } | |
64 template <class T> struct S3<T&>; | |
65 | |
66 extern S3<int> s3i; | |
67 extern class S3<int> s3i; // { dg-warning "\\\[-Wmismatched-tags" } | |
68 extern struct S3<int> s3i; | |
69 | |
70 extern S3<int*> s3p; | |
71 extern class S3<int*> s3p; | |
72 extern struct S3<int*> s3p; // { dg-warning "\\\[-Wmismatched-tags" } | |
73 | |
74 extern S3<int&> s3r; | |
75 extern class S3<int&> s3r; // { dg-warning "\\\[-Wmismatched-tags" } | |
76 extern struct S3<int&> s3r; | |
77 | |
78 // Repeat exactly the same as above. | |
79 extern S3<int> s3i; | |
80 extern class S3<int> s3i; // { dg-warning "\\\[-Wmismatched-tags" } | |
81 extern struct S3<int> s3i; | |
82 | |
83 extern S3<int*> s3p; | |
84 extern class S3<int*> s3p; | |
85 extern struct S3<int*> s3p; // { dg-warning "\\\[-Wmismatched-tags" } | |
86 | |
87 extern S3<int&> s3r; | |
88 extern class S3<int&> s3r; // { dg-warning "\\\[-Wmismatched-tags" } | |
89 extern struct S3<int&> s3r; | |
90 | |
91 // Repeat the same as above just with different type. | |
92 extern S3<long> s3l; | |
93 extern class S3<long> s3l; // { dg-warning "\\\[-Wmismatched-tags" } | |
94 extern struct S3<long> s3l; | |
95 | |
96 extern S3<long*> s3lp; | |
97 extern class S3<long*> s3lp; | |
98 extern struct S3<long*> s3lp; // { dg-warning "\\\[-Wmismatched-tags" } | |
99 | |
100 extern S3<long&> s3lr; | |
101 extern class S3<long&> s3lr; // { dg-warning "\\\[-Wmismatched-tags" } | |
102 extern struct S3<long&> s3lr; | |
103 | |
104 // Repeat with the class-keys swapped. | |
105 extern S3<long> s3l; | |
106 extern struct S3<long> s3l; | |
107 extern class S3<long> s3l; // { dg-warning "\\\[-Wmismatched-tags" } | |
108 | |
109 extern S3<long*> s3lp; | |
110 extern struct S3<long*> s3lp; // { dg-warning "\\\[-Wmismatched-tags" } | |
111 extern class S3<long*> s3lp; | |
112 | |
113 extern S3<long&> s3lr; | |
114 extern struct S3<long&> s3lr; | |
115 extern class S3<long&> s3lr; // { dg-warning "\\\[-Wmismatched-tags" } | |
116 | |
117 | |
118 namespace N | |
119 { | |
120 template <class> struct A; | |
121 | |
122 extern class A<int> ai; // { dg-warning "\\\[-Wmismatched-tags" } | |
123 extern struct A<int> ai; | |
124 | |
125 typedef class A<int> AI; // { dg-warning "\\\[-Wmismatched-tags" } | |
126 typedef struct A<int> AI; | |
127 | |
128 template <class> struct B; | |
129 template <> class B<int>; | |
130 template <> struct B<char>; | |
131 | |
132 extern class B<int> bi; | |
133 extern struct B<int> bi; // { dg-warning "\\\[-Wmismatched-tags" } | |
134 | |
135 extern class B<char> bc; // { dg-warning "\\\[-Wmismatched-tags" } | |
136 extern struct B<char> bc; | |
137 | |
138 typedef class B<char> BC; // { dg-warning "\\\[-Wmismatched-tags" } | |
139 typedef struct B<char> BC; | |
140 | |
141 } |