From 293678445f2f62406fabf6a70c2bdbae4e8346f3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 21 Jun 2011 15:05:25 -0400 Subject: [PATCH] re PR c++/49418 (G++ discards cv-quals from template parameter types) 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 | 6 ++++++ gcc/cp/call.c | 2 -- gcc/cp/semantics.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/param3.C | 12 ++++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/param3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 97bead8f0af..558e756fe55 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-06-21 Jason Merrill + + 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 * semantics.c: Add sync_ or SYNC__ to builtin names. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index caf95b077ce..3ac7a8e3f54 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1c9d70ab286..594d239f4ea 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f03f2ad508..b2040700cda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-21 Jason Merrill + + PR c++/49418 + * g++.dg/template/param3.C: New. + 2011-06-21 Bernd Schmidt * 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 index 00000000000..0c1e70326fa --- /dev/null +++ b/gcc/testsuite/g++.dg/template/param3.C @@ -0,0 +1,12 @@ +// PR c++/49418 + +template +void f (const T t) +{ + t = 1; // { dg-error "" } +} + +int main() +{ + f(1); +}