aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-09 01:55:14 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-09 01:55:14 +0000
commit6b63f551b183e14fab6ac51d6e5199c90b699035 (patch)
treeec0d05c365dded0e22f1f90adb6ce18ce16999b4
parent3f86ce1dc64a46d9cd3675787b8af32c9158abe6 (diff)
Make sure to canonicalize the argument type of a non-type template
argument of enumeration type when checking template arguments. Fixes PR10579. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137101 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaTemplate.cpp5
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp57
2 files changed, 60 insertions, 2 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 006017f5a4..e960452e06 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -3820,8 +3820,9 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
}
Converted = TemplateArgument(Value,
- ParamType->isEnumeralType() ? ParamType
- : IntegerType);
+ ParamType->isEnumeralType()
+ ? Context.getCanonicalType(ParamType)
+ : IntegerType);
return Owned(Arg);
}
diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp
index 5be5a13031..f90bb11f71 100644
--- a/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/test/SemaTemplate/temp_arg_nontype.cpp
@@ -263,3 +263,60 @@ namespace PR9227 {
void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>}}
void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>}}
}
+
+namespace PR10579 {
+ namespace fcppt
+ {
+ namespace container
+ {
+ namespace bitfield
+ {
+
+ template<
+ typename Enum,
+ Enum Size
+ >
+ class basic;
+
+ template<
+ typename Enum,
+ Enum Size
+ >
+ class basic
+ {
+ public:
+ basic()
+ {
+ }
+ };
+
+ }
+ }
+ }
+
+ namespace
+ {
+
+ namespace testenum
+ {
+ enum type
+ {
+ foo,
+ bar,
+ size
+ };
+ }
+
+ }
+
+ int main()
+ {
+ typedef fcppt::container::bitfield::basic<
+ testenum::type,
+ testenum::size
+ > bitfield_foo;
+
+ bitfield_foo obj;
+ }
+
+}