From: Mark Mitchell Date: Sun, 1 Dec 2002 03:58:53 +0000 (+0000) Subject: re PR c++/8214 (character conversion problem) X-Git-Tag: releases/gcc-3.2.2~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1638ce7de1a3b33c660e2bf8fe14e2941b685ec2;p=thirdparty%2Fgcc.git re PR c++/8214 (character conversion problem) PR c++/8214 * g++.dg/init/string1.C: New test. PR c++/8214 * typeck.c (convert_for_assignment): Do not use decl_constant_value on the operand. From-SVN: r59671 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5a611ae98c9a..0af12ca3b5f4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-11-30 Mark Mitchell + + PR c++/8214 + * typeck.c (convert_for_assignment): Do not use + decl_constant_value on the operand. + 2002-11-19 Release Manager * GCC 3.2.1 Released. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b019d0a31b30..a38305f29d1c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6195,8 +6195,16 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) /* Simplify the RHS if possible. */ if (TREE_CODE (rhs) == CONST_DECL) rhs = DECL_INITIAL (rhs); - else if (coder != ARRAY_TYPE) - rhs = decl_constant_value (rhs); + + /* We do not use decl_constant_value here because of this case: + + const char* const s = "s"; + + The conversion rules for a string literal are more lax than for a + variable; in particular, a string literal can be converted to a + "char *" but the variable "s" cannot be converted in the same + way. If the conversion is allowed, the optimization should be + performed while creating the converted expression. */ /* [expr.ass] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b41c9ee71cc..3041068c9f32 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-11-30 Mark Mitchell + + PR c++/8214 + * g++.dg/init/string1.C: New test. + 2002-11-26 Neil Booth * gcc.dg/cpp/_Pragma5.c: New test.