]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13371 (infinite loop with packed struct and inlining)
authorJason Merrill <jason@redhat.com>
Fri, 19 Dec 2003 20:23:39 +0000 (15:23 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 19 Dec 2003 20:23:39 +0000 (15:23 -0500)
        PR c++/13371
        * typeck.c (build_modify_expr): Stabilize lhs if we're narrowing.

From-SVN: r74845

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

index c8479b60516c95355e30d6b07f5f484ad636d298..6dcd17080cef09c4ea2b4b92bfa65563068ebb24 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/13371
+       * typeck.c (build_modify_expr): Stabilize lhs if we're narrowing.
+
 2003-12-18  Jason Merrill  <jason@redhat.com>
 
        PR c++/12253
index 4b36cc2ceaa6796b28d5ccd0f2ab235ef291941e..a306b17c2982d31901d6dec22fe2a81df5bb8e9f 100644 (file)
@@ -5210,7 +5210,7 @@ build_modify_expr (lhs, modifycode, rhs)
   tree newrhs = rhs;
   tree lhstype = TREE_TYPE (lhs);
   tree olhstype = lhstype;
-  tree olhs = lhs;
+  tree olhs = NULL_TREE;
 
   /* Avoid duplicate error messages from operands that had errors.  */
   if (lhs == error_mark_node || rhs == error_mark_node)
@@ -5446,6 +5446,15 @@ build_modify_expr (lhs, modifycode, rhs)
 
       if (lhstype != TREE_TYPE (lhs))
        {
+         /* Avoid warnings converting integral types back into enums for
+            enum bit fields.  */
+         if (TREE_CODE (lhstype) == INTEGER_TYPE
+             && TREE_CODE (olhstype) == ENUMERAL_TYPE)
+           {
+             if (TREE_SIDE_EFFECTS (lhs))
+               lhs = stabilize_reference (lhs);
+             olhs = lhs;
+           }
          lhs = copy_node (lhs);
          TREE_TYPE (lhs) = lhstype;
        }
@@ -5518,10 +5527,7 @@ build_modify_expr (lhs, modifycode, rhs)
 
   if (olhstype == TREE_TYPE (result))
     return result;
-  /* Avoid warnings converting integral types back into enums
-     for enum bit fields.  */
-  if (TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE
-      && TREE_CODE (olhstype) == ENUMERAL_TYPE)
+  if (olhs)
     {
       result = build (COMPOUND_EXPR, olhstype, result, olhs);
       TREE_NO_UNUSED_WARNING (result) = 1;