summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-26 04:08:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-26 04:08:46 +0000
commit4ca93d9978aac02b01814b4f749d6903a1f87ee5 (patch)
tree567afc5124dbf52e1714409bb2b19751ad52a874 /test/SemaCXX
parentb3dcbbda59a24a5c72483d00f16c5e3f2b328495 (diff)
Delay checking of dependent underlying types for redeclarations of member
enumerations in templates until the template is instantiated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/enum-scoped.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp
index 44394296e3..c842dcde84 100644
--- a/test/SemaCXX/enum-scoped.cpp
+++ b/test/SemaCXX/enum-scoped.cpp
@@ -195,8 +195,29 @@ namespace test8 {
enum A : int; // expected-note {{here}}
enum class B; // expected-note {{here}}
enum class C : int; // expected-note {{here}}
+ enum class D : int; // expected-note {{here}}
};
template<typename T> enum S<T>::A { a }; // expected-error {{previously declared with fixed underlying type}}
template<typename T> enum class S<T>::B : char { b }; // expected-error {{redeclared with different underlying}}
template<typename T> enum S<T>::C : int { c }; // expected-error {{previously declared as scoped}}
+ template<typename T> enum class S<T>::D : char { d }; // expected-error {{redeclared with different underlying}}
+}
+
+namespace test9 {
+ template<typename T> struct S {
+ enum class ET : T; // expected-note 2{{here}}
+ enum class Eint : int; // expected-note 2{{here}}
+ };
+ template<> enum class S<int>::ET : int {};
+ template<> enum class S<char>::ET : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<int>::Eint : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<char>::Eint : int {};
+
+ template<typename T> enum class S<T>::ET : int {}; // expected-error {{different underlying type 'int' (was 'short')}}
+ template<typename T> enum class S<T>::Eint : T {}; // expected-error {{different underlying type 'short' (was 'int')}}
+
+ // The implicit instantiation of S<short> causes the implicit instantiation of
+ // all declarations of member enumerations, so is ill-formed, even though we
+ // never instantiate the definitions of S<short>::ET nor S<short>::Eint.
+ S<short> s; // expected-note {{in instantiation of}}
}