]> granicus.if.org Git - clang/commitdiff
Make sure to canonicalize the argument type of a non-type template
authorDouglas Gregor <dgregor@apple.com>
Tue, 9 Aug 2011 01:55:14 +0000 (01:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 9 Aug 2011 01:55:14 +0000 (01:55 +0000)
argument of enumeration type when checking template arguments. Fixes PR10579.

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

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

index 006017f5a47d92615ee5e454a216ca1141036766..e960452e06a04348a4d40d426db44e6bb838fd4a 100644 (file)
@@ -3820,8 +3820,9 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     }
 
     Converted = TemplateArgument(Value,
-                                 ParamType->isEnumeralType() ? ParamType
-                                                             : IntegerType);
+                                 ParamType->isEnumeralType() 
+                                   ? Context.getCanonicalType(ParamType)
+                                   : IntegerType);
     return Owned(Arg);
   }
 
index 5be5a1303136dd55ed67207d0367d8746ff9f760..f90bb11f716ddb90d9b9c099c6e21347279d2e55 100644 (file)
@@ -263,3 +263,60 @@ namespace PR9227 {
   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;
+  }
+
+}