[cfe-commits] r86052 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/temp_arg_nontype.cpp

Douglas Gregor dgregor at apple.com
Wed Nov 4 13:50:47 PST 2009


Author: dgregor
Date: Wed Nov  4 15:50:46 2009
New Revision: 86052

URL: http://llvm.org/viewvc/llvm-project?rev=86052&view=rev
Log:
Fix a little canonical-types issue with non-type template arguments.
Fixes PR5349. 

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=86052&r1=86051&r2=86052&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Nov  4 15:50:46 2009
@@ -1995,7 +1995,7 @@
       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()) {

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=86052&r1=86051&r2=86052&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Wed Nov  4 15:50:46 2009
@@ -136,3 +136,19 @@
   
   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.  
+}
+





More information about the cfe-commits mailing list