From: Jason Merrill Date: Fri, 19 Dec 2003 20:23:39 +0000 (-0500) Subject: re PR c++/13371 (infinite loop with packed struct and inlining) X-Git-Tag: releases/gcc-3.3.3~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ebc0da31b6711110dbd28bdf6c7d996ced2e40d;p=thirdparty%2Fgcc.git re PR c++/13371 (infinite loop with packed struct and inlining) PR c++/13371 * typeck.c (build_modify_expr): Stabilize lhs if we're narrowing. From-SVN: r74845 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c8479b60516c..6dcd17080cef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-12-19 Jason Merrill + + PR c++/13371 + * typeck.c (build_modify_expr): Stabilize lhs if we're narrowing. + 2003-12-18 Jason Merrill PR c++/12253 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 4b36cc2ceaa6..a306b17c2982 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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;