]> granicus.if.org Git - clang/commitdiff
Fix a little canonical-types issue with non-type template arguments.
authorDouglas Gregor <dgregor@apple.com>
Wed, 4 Nov 2009 21:50:46 +0000 (21:50 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 4 Nov 2009 21:50:46 +0000 (21:50 +0000)
Fixes PR5349.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86052 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/temp_arg_nontype.cpp

index 3c56358d5a944c727597766b1aa579da70b5e8d4..5ef370104dd9d3eff287800649ebdf05e416001a 100644 (file)
@@ -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()) {
index 814801ccff99777e3e9b30af871716089285a7c4..a6611582f17077a90be138cdd7db2e4430feb73d 100644 (file)
@@ -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.  
+}
+