blob: 972e68305bb902388d5265f4f55165e9137889a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// { dg-do compile }
// { dg-options "-Wmissing-attributes" }
#define ATTR(list) __attribute__ (list)
/* Type attributes are normally absent in template functions, and the
mere presence of any such attribute used to cause the
-Wmissing-attributes checks, that checked for attributes typically
associated with functions rather than types, to report any missing
attributes twice: once for the specialization attribute list, once
for its type attribute list.
This test uses both decl and type attributes to exercise the code
that avoids reporting duplicates, in ways that failed in the past
but that were not covered in other tests. */
typedef void* ATTR ((alloc_size (1))) f_type (int);
template <class T>
f_type
ATTR ((malloc))
missing_malloc; // { dg-message "missing primary template attribute .malloc." }
template <>
f_type
missing_malloc<char>; // { dg-warning "explicit specialization .\[^\n\r\]+. may be missing attributes" }
/* Check that even an attribute that appears in both lists (decl and
type) in a template declaration is reported as missing only
once. */
template <class T>
f_type
ATTR ((alloc_size (1))) // In both attr lists, decl's and type's.
missing_alloc_size; // { dg-message "missing primary template attribute .alloc_size." }
template <>
void *
missing_alloc_size<char>(int); // { dg-warning "explicit specialization .\[^\n\r\]+. may be missing attributes" }
/* Check that even an attribute that appears in both lists (decl and
type) is not reported as missing if it's present only in the type
list. */
template <class T>
f_type
ATTR ((alloc_size (1))) // In both attr lists, decl's and type's.
missing_nothing;
template <>
f_type
missing_nothing<char>;
/* For completeness, check that a type attribute is matched by a decl
attribute in the specialization. */
template <class T>
f_type
missing_nothing2;
template <>
void *
ATTR ((alloc_size (1)))
missing_nothing2<char>(int);
|