aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2011-07-21 21:30:24 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-07-21 21:30:24 +0000
commit02614448c98bec25dacfe97635f05a04aa748676 (patch)
tree7addef770a5a423e51574d8ee986e8096f1cbd72 /gcc/c-family
parent1f1c0dbd36f67527f1efe575432e1fd7d4861eec (diff)
downloadgcc-02614448c98bec25dacfe97635f05a04aa748676.zip
gcc-02614448c98bec25dacfe97635f05a04aa748676.tar.gz
gcc-02614448c98bec25dacfe97635f05a04aa748676.tar.bz2
re PR middle-end/49705 (-Wstrict-overflow should not diagnose unevaluated expressions)
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. From-SVN: r176591
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-common.c40
2 files changed, 42 insertions, 7 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index c5f2306..8af431e 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 6078d94..96275ba 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);