From: Douglas Gregor Date: Tue, 9 Aug 2011 01:55:14 +0000 (+0000) Subject: Make sure to canonicalize the argument type of a non-type template X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b63f551b183e14fab6ac51d6e5199c90b699035;p=clang 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 --- 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; + } + +}