From: Douglas Gregor Date: Wed, 4 Nov 2009 21:50:46 +0000 (+0000) Subject: Fix a little canonical-types issue with non-type template arguments. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff5243981e2f6fb4a11ab7b81bf7accc226f2647;p=clang Fix a little canonical-types issue with non-type template arguments. Fixes PR5349. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86052 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 3c56358d5a..5ef370104d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1995,7 +1995,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ArgType = Context.getCanonicalType(ArgType).getUnqualifiedType(); // Try to convert the argument to the parameter's type. - if (ParamType == ArgType) { + if (Context.hasSameType(ParamType, ArgType)) { // Okay: no conversion necessary } else if (IsIntegralPromotion(Arg, ArgType, ParamType) || !ParamType->isEnumeralType()) { diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index 814801ccff..a6611582f1 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -136,3 +136,19 @@ namespace ns { Bar::value)> x; } + +// PR5349 +namespace ns { + enum E { k }; + + template + struct Baz {}; + + Baz f1; // This works. + Baz f2; // This too. + Baz(0)> f3; // And this. + + Baz b1; // This doesn't work. + Baz(0)> b2; // This neither. +} +