diff options
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/temp_arg_nontype.cpp | 16 |
2 files changed, 17 insertions, 1 deletions
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<bool(ns::Foo<int>::value)> x; } + +// PR5349 +namespace ns { + enum E { k }; + + template <E e> + struct Baz {}; + + Baz<k> f1; // This works. + Baz<E(0)> f2; // This too. + Baz<static_cast<E>(0)> f3; // And this. + + Baz<ns::E(0)> b1; // This doesn't work. + Baz<static_cast<ns::E>(0)> b2; // This neither. +} + |