re PR c++/49418 (G++ discards cv-quals from template parameter types)
authorJason Merrill <jason@redhat.com>
Tue, 21 Jun 2011 19:05:25 +0000 (15:05 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 21 Jun 2011 19:05:25 +0000 (15:05 -0400)
PR c++/49418
* call.c (cxx_type_promotes_to): Don't strip cv-quals.
* semantics.c (lambda_return_type): Strip them here.

From-SVN: r175271

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/param3.C [new file with mode: 0644]

index 97bead8f0afb4ca7736ab8acd15c92e1e80d7918..558e756fe553b150f6be8f77704dfdcf16908f56 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49418
+       * call.c (cxx_type_promotes_to): Don't strip cv-quals.
+       * semantics.c (lambda_return_type): Strip them here.
+
 2011-06-21  Andrew MacLeod  <amacleod@redhat.com>
 
        * semantics.c: Add sync_ or SYNC__ to builtin names.
index caf95b077ce4b8d7883644c73244d7bfe07b215f..3ac7a8e3f5445a365d36119c3a1f4dd4f06b367d 100644 (file)
@@ -2640,8 +2640,6 @@ type_decays_to (tree type)
     return build_pointer_type (TREE_TYPE (type));
   if (TREE_CODE (type) == FUNCTION_TYPE)
     return build_pointer_type (type);
-  if (!MAYBE_CLASS_TYPE_P (type))
-    type = cv_unqualified (type);
   return type;
 }
 
index 1c9d70ab28696394f8102af2091be4eee4d23f9e..594d239f4ea131057489aa307e27bbf1e79527bd 100644 (file)
@@ -8177,7 +8177,7 @@ lambda_return_type (tree expr)
       SET_TYPE_STRUCTURAL_EQUALITY (type);
     }
   else
-    type = type_decays_to (unlowered_expr_type (expr));
+    type = cv_unqualified (type_decays_to (unlowered_expr_type (expr)));
   return type;
 }
 
index 2f03f2ad508515a43f6ca1ba0f3da161c19ef914..b2040700cdaaffdbaf01949b1d938cdfea3981e3 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/49418
+       * g++.dg/template/param3.C: New.
+
 2011-06-21  Bernd Schmidt  <bernds@codesourcery.com>
 
        * gcc.c-torture/excute/builtin-bitops-1.c (MAKE_FUNS): Make
diff --git a/gcc/testsuite/g++.dg/template/param3.C b/gcc/testsuite/g++.dg/template/param3.C
new file mode 100644 (file)
index 0000000..0c1e703
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/49418
+
+template <class T>
+void f (const T t)
+{
+  t = 1;                       // { dg-error "" }
+}
+
+int main()
+{
+  f(1);
+}