From 82e6ef7c6acc90c270f1e91ed74767a67f2c0a0c Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 15 May 2012 15:14:49 +0000 Subject: [PATCH] /cp 2012-05-15 Paolo Carlini PR c++/11586 * pt.c (tsubst_copy_and_build): Increase / decrease c_inhibit_evaluation_warnings around build_x_binary_op call. /c-family 2012-05-15 Paolo Carlini PR c++/11586 * c-common.c (shorten_compare): Check c_inhibit_evaluation_warnings. /testsuite 2012-05-15 Paolo Carlini PR c++/11586 * g++.dg/warn/Wtype-limits.C: Don't warn in templates. * g++.dg/warn/Wtype-limits-Wextra.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187542 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 8 ++++++-- gcc/c-family/c-common.c | 4 +++- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 9 ++++++++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C | 2 +- gcc/testsuite/g++.dg/warn/Wtype-limits.C | 2 +- 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 3575480..1de6250 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,7 +1,11 @@ +2012-05-15 Paolo Carlini + + PR c++/11586 + * c-common.c (shorten_compare): Check c_inhibit_evaluation_warnings. + 2012-05-14 Bernd Schmidt - * c-family/c-common.c (DEF_ATTR_STRING): Define and undefine as - necessary. + * c-common.c (DEF_ATTR_STRING): Define and undefine as necessary. 2012-05-14 Manuel López-Ibáñez diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f32a94a..f745365 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -3754,7 +3754,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, type = c_common_unsigned_type (type); } - if (TREE_CODE (primop0) != INTEGER_CST) + if (TREE_CODE (primop0) != INTEGER_CST + && c_inhibit_evaluation_warnings == 0) { if (val == truthvalue_false_node) warning_at (loc, OPT_Wtype_limits, @@ -3834,6 +3835,7 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, warning. */ bool warn = warn_type_limits && !in_system_header + && c_inhibit_evaluation_warnings == 0 && !(TREE_CODE (primop0) == INTEGER_CST && !TREE_OVERFLOW (convert (c_common_signed_type (type), primop0))) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3555be4..f469e2e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-05-15 Paolo Carlini + + PR c++/11586 + * pt.c (tsubst_copy_and_build): Increase / decrease + c_inhibit_evaluation_warnings around build_x_binary_op call. + 2012-05-12 Paolo Carlini * cp-tree.h (TYPE_PTRMEM_P): Rename to TYPE_PTRDATAMEM_P. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 051abb8..ec121ff 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13608,7 +13608,11 @@ tsubst_copy_and_build (tree t, case MEMBER_REF: case DOTSTAR_EXPR: { - tree r = build_x_binary_op + tree r; + + ++c_inhibit_evaluation_warnings; + + r = build_x_binary_op (input_location, TREE_CODE (t), RECUR (TREE_OPERAND (t, 0)), (TREE_NO_WARNING (TREE_OPERAND (t, 0)) @@ -13622,6 +13626,9 @@ tsubst_copy_and_build (tree t, complain); if (EXPR_P (r) && TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); + + --c_inhibit_evaluation_warnings; + return r; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c7e44a..9e72f3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-05-15 Paolo Carlini + + PR c++/11586 + * g++.dg/warn/Wtype-limits.C: Don't warn in templates. + * g++.dg/warn/Wtype-limits-Wextra.C: Likewise. + 2012-05-15 Olivier Hainque * g++.dg/eh/sighandle.C: New testcase. diff --git a/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C b/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C index 9cbdbe5..f840f30 100644 --- a/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C +++ b/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C @@ -66,7 +66,7 @@ int test (int x) template void f(Int x) { - assert(0 <= x and x <= D); // { dg-warning "comparison is always true due to limited range of data type" } + assert(0 <= x and x <= D); } int ff(void) { diff --git a/gcc/testsuite/g++.dg/warn/Wtype-limits.C b/gcc/testsuite/g++.dg/warn/Wtype-limits.C index 814c2a8..a352e7b 100644 --- a/gcc/testsuite/g++.dg/warn/Wtype-limits.C +++ b/gcc/testsuite/g++.dg/warn/Wtype-limits.C @@ -66,7 +66,7 @@ int test (int x) template void f(Int x) { - assert(0 <= x and x <= D); // { dg-warning "comparison is always true due to limited range of data type" } + assert(0 <= x and x <= D); } int ff(void) { -- 2.7.4