From 1ebc0da31b6711110dbd28bdf6c7d996ced2e40d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 19 Dec 2003 15:23:39 -0500 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) 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; -- 2.47.2