Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/ext/attr-warning.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 // Bug c++/83871 - wrong code due to attributes on distinct template | |
2 // specializations | |
3 // Test to verify that an explicit template specifialization does not | |
4 // "inherit" attribute warning from a primary template declared with | |
5 // it. | |
6 // { dg-do compile } | |
7 // { dg-options "-Wall" } | |
8 | |
9 struct Special; | |
10 | |
11 // Primary has no attributes here. | |
12 template <class T> | |
13 void fwarn_primary (); | |
14 | |
15 // Uses of the primary template, including declarations of its | |
16 // specializations, should not be diagnosed until after it has | |
17 // been redeclared with attribute warning. | |
18 template <> | |
19 void fwarn_primary<Special> (); | |
20 | |
21 void use_primary_before_warning () | |
22 { | |
23 // Verify that uses of the primary are not diagnosed. | |
24 fwarn_primary<char>(); | |
25 fwarn_primary<short>(); | |
26 } | |
27 | |
28 // Redeclare the primary with attribute warning. | |
29 template <class T> | |
30 void __attribute__ ((warning ("primary"))) | |
31 fwarn_primary (); | |
32 | |
33 // Attribute warning is special in that it only warns for functions | |
34 // that are actually used, not those that are only declared. | |
35 template <> | |
36 void fwarn_primary<double> (); | |
37 | |
38 void use_primary_after_warning () | |
39 { | |
40 // Verify that uses of the redeclared primary are diagnosed. | |
41 fwarn_primary<int>(); // { dg-warning "primary" } | |
42 fwarn_primary<long>(); // { dg-warning "primary" } | |
43 } | |
44 | |
45 void use_special () | |
46 { | |
47 // Verify that the use of the specializatoin is not diagnosed. | |
48 fwarn_primary<Special>(); | |
49 } |