This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/32643] [4.3 Regression] Wrong error message with unsigned char a = uchar&512
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jul 2007 09:43:24 -0000
- Subject: [Bug c/32643] [4.3 Regression] Wrong error message with unsigned char a = uchar&512
- References: <bug-32643-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pinskia at gcc dot gnu dot org 2007-07-06 09:43 -------
This quick hack fixes the problem for both testcases (the fold-const part is
the only part required to fix the second testcase);
Index: fold-const.c
===================================================================
--- fold-const.c (revision 126396)
+++ fold-const.c (working copy)
@@ -3278,7 +3278,7 @@
{
tree t = fold_convert (type, result);
- if (TREE_SIDE_EFFECTS (omitted))
+ if (folding_initializer || TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
return non_lvalue (t);
@@ -3291,7 +3291,7 @@
{
tree t = fold_convert (type, result);
- if (TREE_SIDE_EFFECTS (omitted))
+ if (folding_initializer || TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
return pedantic_non_lvalue (t);
@@ -14438,6 +14438,10 @@
tree
fold_ignored_result (tree t)
{
+ /* Just for now, if this is an initializer. */
+ if (folding_initializer)
+ return t;
+
if (!TREE_SIDE_EFFECTS (t))
return integer_zero_node;
Index: c-typeck.c
===================================================================
--- c-typeck.c (revision 126396)
+++ c-typeck.c (working copy)
@@ -3783,7 +3783,8 @@
enum tree_code coder;
tree rname = NULL_TREE;
bool objc_ok = false;
-
+ int old_folding_initializer;
+
if (errtype == ic_argpass || errtype == ic_argpass_nonproto)
{
tree selector;
@@ -3918,13 +3919,29 @@
&& (coder == INTEGER_TYPE || coder == REAL_TYPE
|| coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
|| coder == BOOLEAN_TYPE))
- return convert_and_check (type, rhs);
+ {
+ tree new;
+ old_folding_initializer = folding_initializer;
+ if (errtype == ic_init)
+ folding_initializer = 1;
+ new = convert_and_check (type, rhs);
+ folding_initializer = old_folding_initializer;
+ return new;
+ }
/* Aggregates in different TUs might need conversion. */
if ((codel == RECORD_TYPE || codel == UNION_TYPE)
&& codel == coder
&& comptypes (type, rhstype))
- return convert_and_check (type, rhs);
+ {
+ tree new;
+ old_folding_initializer = folding_initializer;
+ if (errtype == ic_init)
+ folding_initializer = 1;
+ new = convert_and_check (type, rhs);
+ folding_initializer = old_folding_initializer;
+ return new;
+ }
/* Conversion to a transparent union from its member types.
This applies only to function arguments. */
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32643