+2012-03-12 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/52299
+ * pt.c (tsubst_copy_and_build, case COND_EXPR): Avoid bogus
+ division by zero warnings.
+
2012-03-08 Paolo Carlini <paolo.carlini@oracle.com>
* typeck.c (build_array_ref, cp_build_addr_expr_1, convert_ptrmem,
}
case COND_EXPR:
- return build_x_conditional_expr
- (RECUR (TREE_OPERAND (t, 0)),
- RECUR (TREE_OPERAND (t, 1)),
- RECUR (TREE_OPERAND (t, 2)),
- complain);
+ {
+ tree cond = RECUR (TREE_OPERAND (t, 0));
+ tree exp1, exp2;
+
+ if (TREE_CODE (cond) == INTEGER_CST)
+ {
+ if (integer_zerop (cond))
+ {
+ ++c_inhibit_evaluation_warnings;
+ exp1 = RECUR (TREE_OPERAND (t, 1));
+ --c_inhibit_evaluation_warnings;
+ exp2 = RECUR (TREE_OPERAND (t, 2));
+ }
+ else
+ {
+ exp1 = RECUR (TREE_OPERAND (t, 1));
+ ++c_inhibit_evaluation_warnings;
+ exp2 = RECUR (TREE_OPERAND (t, 2));
+ --c_inhibit_evaluation_warnings;
+ }
+ }
+ else
+ {
+ exp1 = RECUR (TREE_OPERAND (t, 1));
+ exp2 = RECUR (TREE_OPERAND (t, 2));
+ }
+
+ return build_x_conditional_expr (cond, exp1, exp2, complain);
+ }
case PSEUDO_DTOR_EXPR:
return finish_pseudo_destructor_expr
+2012-03-12 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/52299
+ * g++.dg/warn/Wdiv-by-zero-bogus.C: New.
+
2012-03-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/46728
* gcc.target/avr/torture/addr-space-0.h: New test.
* gcc.target/avr/torture/addr-space-1.h: New test.
* gcc.target/avr/torture/addr-space-x.h: New test.
-
+
2012-03-12 Andrew Pinski <apinski@cavium.com>
* gcc.dg/tree-ssa/phi-opt-7.c: New testcase.
--- /dev/null
+// PR c++/52299
+
+template<unsigned x>
+struct test0 {
+ static const unsigned a_
+ = x ? 10 / x : 10;
+};
+
+template<unsigned x>
+struct test1 {
+ static const unsigned a_
+ = !x ? 10 : 10 / x;
+};
+
+template<bool x>
+struct test2 {
+ static const unsigned a_
+ = x ? 10 / x : 10;
+};
+
+template<bool x>
+struct test3 {
+ static const unsigned a_
+ = !x ? 10 : 10 / x;
+};
+
+unsigned i0 = test0<0>::a_;
+unsigned i1 = test1<0>::a_;
+unsigned i2 = test2<false>::a_;
+unsigned i3 = test3<false>::a_;