Fix the type of a enum non-type template argument within the instantiation.

llvm-svn: 72489
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 97eca48..b15ce29 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1494,7 +1494,7 @@
       } 
 
       Converted->push_back(TemplateArgument(StartLoc, Value,
-                                   Context.getCanonicalType(IntegerType)));
+                      ParamType->isEnumeralType() ? ParamType : IntegerType));
     }
 
     return false;
diff --git a/clang/test/SemaTemplate/enum-argument.cpp b/clang/test/SemaTemplate/enum-argument.cpp
new file mode 100644
index 0000000..101a1d0
--- /dev/null
+++ b/clang/test/SemaTemplate/enum-argument.cpp
@@ -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>;