/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 May 2013 19:19:44 +0000 (19:19 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 May 2013 19:19:44 +0000 (19:19 +0000)
2013-05-01  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/57132
* pt.c (tsubst_copy_and_build, MODOP_EXPR): Increase / decrease
c_inhibit_evaluation_warnings around build_x_modify_expr call.

/testsuite
2013-05-01  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/57132
* g++.dg/warn/Wdiv-by-zero-bogus-2.C: New.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C [new file with mode: 0644]

index 09f10df..e4996fb 100644 (file)
@@ -1,5 +1,11 @@
 2013-05-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
+       PR c++/57132
+       * pt.c (tsubst_copy_and_build, MODOP_EXPR): Increase / decrease
+       c_inhibit_evaluation_warnings around build_x_modify_expr call.
+
+2013-05-01  Paolo Carlini  <paolo.carlini@oracle.com>
+
        PR c++/57092
        * semantics.c (finish_decltype_type): Handle instantiated template
        non-type arguments.
index 57f65b3..33ab292 100644 (file)
@@ -13810,7 +13810,11 @@ tsubst_copy_and_build (tree t,
 
     case MODOP_EXPR:
       {
-       tree r = build_x_modify_expr
+       tree r;
+
+       ++c_inhibit_evaluation_warnings;
+
+       r = build_x_modify_expr
          (EXPR_LOCATION (t),
           RECUR (TREE_OPERAND (t, 0)),
           TREE_CODE (TREE_OPERAND (t, 1)),
@@ -13824,6 +13828,9 @@ tsubst_copy_and_build (tree t,
           here.  */
        if (TREE_NO_WARNING (t))
          TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+
+       --c_inhibit_evaluation_warnings;
+
        RETURN (r);
       }
 
index 939d459..bce4185 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-01  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/57132
+       * g++.dg/warn/Wdiv-by-zero-bogus-2.C: New.
+
 2013-05-01  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/57091
diff --git a/gcc/testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C b/gcc/testsuite/g++.dg/warn/Wdiv-by-zero-bogus-2.C
new file mode 100644 (file)
index 0000000..b7556ea
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/57132
+
+template<unsigned m, unsigned a>
+struct mod 
+{
+  static unsigned calc(unsigned x) {
+    unsigned res = a * x;
+    if (m)
+      res %= m;
+    return res;
+  }
+};
+
+int main()
+{
+  mod<3,2>::calc(7);
+  mod<0,2>::calc(7);
+}