]> granicus.if.org Git - clang/commitdiff
Implement [temp.param]p5: the top-level cv-qualifiers on a non-type template
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 13 Mar 2012 07:21:50 +0000 (07:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 13 Mar 2012 07:21:50 +0000 (07:21 +0000)
parameter's declaration are ignored when determining the parameter's type.

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

lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.param/p5.cpp [new file with mode: 0644]

index e76a2538693a94d0eb60976e970fc7d8570d2b1d..37c7cefb0da46edc1036e1050392c738d6334ef5 100644 (file)
@@ -643,8 +643,12 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
       T->isNullPtrType() ||
       // If T is a dependent type, we can't do the check now, so we
       // assume that it is well-formed.
-      T->isDependentType())
-    return T;
+      T->isDependentType()) {
+    // C++ [temp.param]p5: The top-level cv-qualifiers on the template-parameter
+    // are ignored when determining its type.
+    return T.getUnqualifiedType();
+  }
+
   // C++ [temp.param]p8:
   //
   //   A non-type template-parameter of type "array of T" or
diff --git a/test/CXX/temp/temp.param/p5.cpp b/test/CXX/temp/temp.param/p5.cpp
new file mode 100644 (file)
index 0000000..3cbb3b7
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s -std=c++11
+
+template<const int I> struct S {
+  decltype(I) n;
+  int &&r = I;
+};
+S<5> s;
+
+template<typename T, T v> struct U {
+  decltype(v) n;
+  int &&r = v;
+};
+U<const int, 6> u;