]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/8214 (character conversion problem)
authorMark Mitchell <mark@codesourcery.com>
Sun, 1 Dec 2002 03:58:53 +0000 (03:58 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 1 Dec 2002 03:58:53 +0000 (03:58 +0000)
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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog

index 5a611ae98c9a41ace23c81e4056e84e27112b3ad..0af12ca3b5f4e2f495a4b963be8b33db62de1a5f 100644 (file)
@@ -1,3 +1,9 @@
+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-19  Release Manager
 
        * GCC 3.2.1 Released.
index b019d0a31b30ca458ad5ab9a42e1f2900361eb1b..a38305f29d1c0b38fb9e3d2fbbb68d863e0d1384 100644 (file)
@@ -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]
 
index 7b41c9ee71ccca0921b1a532a43a6faa1d60e079..3041068c9f3225860078af921383fc05fb2d155b 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-30  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/8214
+       * g++.dg/init/string1.C: New test.
+
 2002-11-26  Neil Booth  <neil@daikokuya.co.uk>
 
        * gcc.dg/cpp/_Pragma5.c: New test.