/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 May 2012 15:14:49 +0000 (15:14 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 May 2012 15:14:49 +0000 (15:14 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187542 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C
gcc/testsuite/g++.dg/warn/Wtype-limits.C

index 3575480..1de6250 100644 (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>
 
index f32a94a..f745365 100644 (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)))
index 3555be4..f469e2e 100644 (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.
index 051abb8..ec121ff 100644 (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;
       }
 
index 0c7e44a..9e72f3f 100644 (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.
index 9cbdbe5..f840f30 100644 (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) {
index 814c2a8..a352e7b 100644 (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) {