p1.cpp
2.89 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// RUN: %clang_cc1 -std=c++11 -verify %s
// The implicit specialization of a class template specialuzation causes the
// implicit instantiation of the declarations, but not the definitions or
// default arguments, of:
// FIXME: Many omitted cases
// - scoped member enumerations
namespace ScopedEnum {
template<typename T> struct ScopedEnum1 {
enum class E {
e = T::error // expected-error {{'double' cannot be used prior to '::'}}
};
};
ScopedEnum1<int> se1; // ok
template<typename T> struct ScopedEnum2 {
enum class E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
e = 0
};
};
ScopedEnum2<void*> se2; // expected-note {{here}}
template<typename T> struct UnscopedEnum3 {
enum class E : T {
e = 4
};
int arr[(int)E::e];
};
UnscopedEnum3<int> ue3; // ok
ScopedEnum1<double>::E e1; // ok
ScopedEnum1<double>::E e2 = decltype(e2)::e; // expected-note {{in instantiation of enumeration 'ScopedEnum::ScopedEnum1<double>::E' requested here}}
// DR1484 specifies that enumerations cannot be separately instantiated,
// they will be instantiated with the rest of the template declaration.
template<typename T>
int f() {
enum class E {
e = T::error // expected-error {{has no members}}
};
return (int)E();
}
int test1 = f<int>(); // expected-note {{here}}
template<typename T>
int g() {
enum class E {
e = T::error // expected-error {{has no members}}
};
return E::e;
}
int test2 = g<int>(); // expected-note {{here}}
}
// - static data members
namespace StaticDataMembers {
template<typename T>
struct A {
static const int n = T::error; // expected-error {{has no members}}
static inline int m = T::error; // expected-warning {{extension}}
};
A<int> ai; // expected-note {{here}}
}
// And it cases the implicit instantiations of the definitions of:
// - unscoped member enumerations
namespace UnscopedEnum {
template<typename T> struct UnscopedEnum1 {
enum E {
e = T::error // expected-error {{'int' cannot be used prior to '::'}}
};
};
UnscopedEnum1<int> ue1; // expected-note {{here}}
template<typename T> struct UnscopedEnum2 {
enum E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
e = 0
};
};
UnscopedEnum2<void*> ue2; // expected-note {{here}}
template<typename T> struct UnscopedEnum3 {
enum E : T {
e = 4
};
int arr[E::e];
};
UnscopedEnum3<int> ue3; // ok
template<typename T>
int f() {
enum E {
e = T::error // expected-error {{has no members}}
};
return (int)E();
}
int test1 = f<int>(); // expected-note {{here}}
template<typename T>
int g() {
enum E {
e = T::error // expected-error {{has no members}}
};
return E::e;
}
int test2 = g<int>(); // expected-note {{here}}
}
// FIXME:
//- - member anonymous unions