This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/31339] [4.3 regression] ICE on invalid use of complex constant



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-05-23 00:48 -------
The patch which I am testing:
Index: testsuite/gcc.dg/boolcomplex-1.c
===================================================================
--- testsuite/gcc.dg/boolcomplex-1.c    (revision 0)
+++ testsuite/gcc.dg/boolcomplex-1.c    (revision 0)
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+_Bool b = --0i == 0; /* { dg-error "lvalue required as decrement operand" } */
Index: testsuite/g++.dg/ext/boolcomplex-1.c
===================================================================
--- testsuite/g++.dg/ext/boolcomplex-1.c        (revision 0)
+++ testsuite/g++.dg/ext/boolcomplex-1.c        (revision 0)
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+bool b = --0i == 0; /* { dg-error "lvalue required as decrement operand" } */
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 124926)
+++ cp/typeck.c (working copy)
@@ -4221,8 +4221,11 @@ build_unary_op (enum tree_code code, tre
          arg = stabilize_reference (arg);
          real = build_unary_op (REALPART_EXPR, arg, 1);
          imag = build_unary_op (IMAGPART_EXPR, arg, 1);
+         real = build_unary_op (code, real, 1);
+         if (real == error_mark_node || imag == error_mark_node)
+           return error_mark_node;
          return build2 (COMPLEX_EXPR, TREE_TYPE (arg),
-                        build_unary_op (code, real, 1), imag);
+                        real, imag);
        }

       /* Report invalid types.  */
Index: c-typeck.c
===================================================================
--- c-typeck.c  (revision 124926)
+++ c-typeck.c  (working copy)
@@ -2908,8 +2908,11 @@ build_unary_op (enum tree_code code, tre
          arg = stabilize_reference (arg);
          real = build_unary_op (REALPART_EXPR, arg, 1);
          imag = build_unary_op (IMAGPART_EXPR, arg, 1);
+         real = build_unary_op (code, real, 1);
+         if (real == error_mark_node || imag == error_mark_node)
+           return error_mark_node;
          return build2 (COMPLEX_EXPR, TREE_TYPE (arg),
-                        build_unary_op (code, real, 1), imag);
+                        real, imag);
        }

       /* Report invalid types.  */




Instead of ever creating a COMPLEX_EXPR with an error_mark, just return an
error_mark_node.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31339


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]