diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-21 21:30:24 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-21 21:30:24 +0000 |
commit | fc501191fdad86559ab06dc4d6dccd6970fe67b4 (patch) | |
tree | 7addef770a5a423e51574d8ee986e8096f1cbd72 /gcc/c-family | |
parent | 20cbba22ce21aaf58be3fb1b438436d5ffbbd94d (diff) | |
download | gcc-fc501191fdad86559ab06dc4d6dccd6970fe67b4.tar.gz |
gcc/c-family:
PR middle-end/49705
* c-common.c (c_disable_warnings): New static function.
(c_enable_warnings): New static function.
(c_fully_fold_internal): Change local unused_p to bool. Call
c_disable_warnings and c_enable_warnings rather than change
c_inhibit_evaluation_warnings.
gcc/testsuite:
PR middle-end/49705
* gcc.dg/pr49705.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176591 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 40 |
2 files changed, 42 insertions, 7 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c5f2306ca62..8af431e2930 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2011-07-21 Ian Lance Taylor <iant@google.com> + + PR middle-end/49705 + * c-common.c (c_disable_warnings): New static function. + (c_enable_warnings): New static function. + (c_fully_fold_internal): Change local unused_p to bool. Call + c_disable_warnings and c_enable_warnings rather than change + c_inhibit_evaluation_warnings. + 2011-07-20 Jason Merrill <jason@redhat.com> PR c++/6709 (DR 743) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 6078d948ae4..96275bac70a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -963,6 +963,32 @@ fix_string_type (tree value) return value; } +/* If DISABLE is true, stop issuing warnings. This is used when + parsing code that we know will not be executed. This function may + be called multiple times, and works as a stack. */ + +static void +c_disable_warnings (bool disable) +{ + if (disable) + { + ++c_inhibit_evaluation_warnings; + fold_defer_overflow_warnings (); + } +} + +/* If ENABLE is true, reenable issuing warnings. */ + +static void +c_enable_warnings (bool enable) +{ + if (enable) + { + --c_inhibit_evaluation_warnings; + fold_undefer_and_ignore_overflow_warnings (); + } +} + /* Fully fold EXPR, an expression that was not folded (beyond integer constant expressions and null pointer constants) when being built up. If IN_INIT, this is in a static initializer and certain @@ -1029,7 +1055,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, bool op0_const = true, op1_const = true, op2_const = true; bool op0_const_self = true, op1_const_self = true, op2_const_self = true; bool nowarning = TREE_NO_WARNING (expr); - int unused_p; + bool unused_p; /* This function is not relevant to C++ because C++ folds while parsing, and may need changes to be correct for C++ when C++ @@ -1278,10 +1304,10 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, unused_p = (op0 == (code == TRUTH_ANDIF_EXPR ? truthvalue_false_node : truthvalue_true_node)); - c_inhibit_evaluation_warnings += unused_p; + c_disable_warnings (unused_p); op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); STRIP_TYPE_NOPS (op1); - c_inhibit_evaluation_warnings -= unused_p; + c_enable_warnings (unused_p); if (op0 != orig_op0 || op1 != orig_op1 || in_init) ret = in_init @@ -1313,15 +1339,15 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op0 = c_fully_fold_internal (op0, in_init, &op0_const, &op0_const_self); STRIP_TYPE_NOPS (op0); - c_inhibit_evaluation_warnings += (op0 == truthvalue_false_node); + c_disable_warnings (op0 == truthvalue_false_node); op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); STRIP_TYPE_NOPS (op1); - c_inhibit_evaluation_warnings -= (op0 == truthvalue_false_node); + c_enable_warnings (op0 == truthvalue_false_node); - c_inhibit_evaluation_warnings += (op0 == truthvalue_true_node); + c_disable_warnings (op0 == truthvalue_true_node); op2 = c_fully_fold_internal (op2, in_init, &op2_const, &op2_const_self); STRIP_TYPE_NOPS (op2); - c_inhibit_evaluation_warnings -= (op0 == truthvalue_true_node); + c_enable_warnings (op0 == truthvalue_true_node); if (op0 != orig_op0 || op1 != orig_op1 || op2 != orig_op2) ret = fold_build3_loc (loc, code, TREE_TYPE (expr), op0, op1, op2); |