From: Jason Merrill Date: Thu, 23 Jun 2011 16:52:41 +0000 (-0400) Subject: re PR c++/49395 (Non-class prvalues seem to have cv-qualification with GCC) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ece620047b5ef8033e0c066c73c857a4d820d507;p=gcc.git re PR c++/49395 (Non-class prvalues seem to have cv-qualification with GCC) PR c++/49395 * init.c (build_zero_init_1): Strip cv-quals from scalar types. From-SVN: r175339 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 64a5807260c..a8fbf7ba179 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-06-23 Jason Merrill + PR c++/49395 + * init.c (build_zero_init_1): Strip cv-quals from scalar types. + PR c++/36435 * pt.c (most_specialized_instantiation): Do check return types. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3c347a4521f..62b68f2b9ea 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -176,7 +176,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, initialized are initialized to zero. */ ; else if (SCALAR_TYPE_P (type)) - init = convert (type, integer_zero_node); + init = convert (cv_unqualified (type), integer_zero_node); else if (CLASS_TYPE_P (type)) { tree field; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c1f8865026..dda6cfffecc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-06-23 Jason Merrill + PR c++/49395 + * g++.dg/init/ref18.C: New. + PR c++/36435 * g++.dg/template/partial9.C: New. diff --git a/gcc/testsuite/g++.dg/init/ref18.C b/gcc/testsuite/g++.dg/init/ref18.C new file mode 100644 index 00000000000..e704077c26b --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ref18.C @@ -0,0 +1,12 @@ +// PR c++/49395 + +volatile int foo(); +struct A { volatile int i; }; +typedef volatile int vi; + +volatile int i; + +const int& ir1 = foo(); +//const int& ir2 = A().i; // line 8 +const int& ir3 = static_cast(i); +const int& ir4 = vi(); // line 10