re PR c++/11856 (unsigned warning in template)

/cp
2012-05-15  Paolo Carlini  <paolo.carlini@oracle.com>

	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  <paolo.carlini@oracle.com>

	PR c++/11586
	* c-common.c (shorten_compare): Check c_inhibit_evaluation_warnings.

/testsuite
2012-05-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/11586
	* g++.dg/warn/Wtype-limits.C: Don't warn in templates.
	* g++.dg/warn/Wtype-limits-Wextra.C: Likewise.

From-SVN: r187542
This commit is contained in:
Paolo Carlini 2012-05-15 15:14:49 +00:00
parent 7d67c380fa
commit a1bde5afcf
7 changed files with 31 additions and 6 deletions

View file

@ -1,7 +1,11 @@
2012-05-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/11586
* c-common.c (shorten_compare): Check c_inhibit_evaluation_warnings.
2012-05-14 Bernd Schmidt <bernds@codesourcery.com>
* 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 <manu@gcc.gnu.org>

View file

@ -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)))

View file

@ -1,3 +1,9 @@
2012-05-15 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
* cp-tree.h (TYPE_PTRMEM_P): Rename to TYPE_PTRDATAMEM_P.

View file

@ -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;
}

View file

@ -1,3 +1,9 @@
2012-05-15 Paolo Carlini <paolo.carlini@oracle.com>
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 <hainque@adacore.com>
* g++.dg/eh/sighandle.C: New testcase.

View file

@ -66,7 +66,7 @@ int test (int x)
template <typename Int, Int D>
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) {

View file

@ -66,7 +66,7 @@ int test (int x)
template <typename Int, Int D>
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) {