]> granicus.if.org Git - clang/commitdiff
Fix the type of a enum non-type template argument within the instantiation.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 27 May 2009 19:21:29 +0000 (19:21 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 27 May 2009 19:21:29 +0000 (19:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72489 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/enum-argument.cpp [new file with mode: 0644]

index 97eca48b9f60c4ed258ec3f5746a477ee85d341a..b15ce295ea2c94ddfa48de4defbad37df45bd7f8 100644 (file)
@@ -1494,7 +1494,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       } 
 
       Converted->push_back(TemplateArgument(StartLoc, Value,
-                                   Context.getCanonicalType(IntegerType)));
+                      ParamType->isEnumeralType() ? ParamType : IntegerType));
     }
 
     return false;
diff --git a/test/SemaTemplate/enum-argument.cpp b/test/SemaTemplate/enum-argument.cpp
new file mode 100644 (file)
index 0000000..101a1d0
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+enum Enum { val = 1 };
+template <Enum v> struct C {
+  typedef C<v> Self;
+};
+template struct C<val>;