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

Douglas Gregor dgregor at apple.com
Mon Aug 8 18:55:14 PDT 2011


Author: dgregor
Date: Mon Aug  8 20:55:14 2011
New Revision: 137101

URL: http://llvm.org/viewvc/llvm-project?rev=137101&view=rev
Log:
Make sure to canonicalize the argument type of a non-type template
argument of enumeration type when checking template arguments. Fixes PR10579.

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=137101&r1=137100&r2=137101&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Aug  8 20:55:14 2011
@@ -3820,8 +3820,9 @@
     }
 
     Converted = TemplateArgument(Value,
-                                 ParamType->isEnumeralType() ? ParamType
-                                                             : IntegerType);
+                                 ParamType->isEnumeralType() 
+                                   ? Context.getCanonicalType(ParamType)
+                                   : IntegerType);
     return Owned(Arg);
   }
 

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=137101&r1=137100&r2=137101&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Mon Aug  8 20:55:14 2011
@@ -263,3 +263,60 @@
   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;
+  }
+
+}





More information about the cfe-commits mailing list