diff options
author | Mark Mitchell <mark@codesourcery.com> | 2002-12-01 02:11:05 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2002-12-01 02:11:05 +0000 |
commit | c17707f1d1d23a434065e94d44221c44d5faf303 (patch) | |
tree | bc3c86a00bd620357711015c94ea2da7682bb0cf /gcc/cp | |
parent | 65f8b0fbafee3584579c96a9a0efc27ff6ea4519 (diff) | |
download | gcc-c17707f1d1d23a434065e94d44221c44d5faf303.zip gcc-c17707f1d1d23a434065e94d44221c44d5faf303.tar.gz gcc-c17707f1d1d23a434065e94d44221c44d5faf303.tar.bz2 |
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: r59668
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3a586ae..87cfabe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2002-11-30 Mark Mitchell <mark@codesourcery.com> + PR c++/8214 + * typeck.c (convert_for_assignment): Do not use + decl_constant_value on the operand. + +2002-11-30 Mark Mitchell <mark@codesourcery.com> + PR c++/8511 * pt.c (instantiate_decl): Handle template friends defined outside of the class correctly. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1366ea0..6a0ec18 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5859,8 +5859,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] |