aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-04-10 06:37:07 +0000
committerJakub Jelinek <jakub@redhat.com>2013-04-10 06:37:07 +0000
commit2d7f698fbe22184e3959cbef982a76dadb9808a2 (patch)
tree7517ea8f416a880cd3ce740afbc0a5f6ce768cb5 /gcc/cp
parent9b013ce81d898065a4e4c88bd16a2772cd6ffeda (diff)
PR c++/56895
* typeck.c (cp_build_binary_op): Call fold_non_dependent_expr_sfinae first before calling maybe_constant_value for warn_for_div_by_zero or invalid shift count warning purposes. * g++.dg/template/arrow3.C: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@197662 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c15
2 files changed, 18 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 39e83953850..04df55e728e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/56895
+ * typeck.c (cp_build_binary_op): Call fold_non_dependent_expr_sfinae
+ first before calling maybe_constant_value for warn_for_div_by_zero
+ or invalid shift count warning purposes.
+
2013-04-06 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_std_attribute): Treat [[noreturn]] like GNU
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 803f5c7e3fa..e5eceb76761 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4040,8 +4040,9 @@ cp_build_binary_op (location_t location,
|| code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
{
enum tree_code tcode0 = code0, tcode1 = code1;
+ tree cop1 = fold_non_dependent_expr_sfinae (op1, tf_none);
- warn_for_div_by_zero (location, maybe_constant_value (op1));
+ warn_for_div_by_zero (location, maybe_constant_value (cop1));
if (tcode0 == COMPLEX_TYPE || tcode0 == VECTOR_TYPE)
tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
@@ -4077,7 +4078,11 @@ cp_build_binary_op (location_t location,
case TRUNC_MOD_EXPR:
case FLOOR_MOD_EXPR:
- warn_for_div_by_zero (location, maybe_constant_value (op1));
+ {
+ tree cop1 = fold_non_dependent_expr_sfinae (op1, tf_none);
+
+ warn_for_div_by_zero (location, maybe_constant_value (cop1));
+ }
if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE
&& TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
@@ -4125,7 +4130,8 @@ cp_build_binary_op (location_t location,
}
else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
{
- tree const_op1 = maybe_constant_value (op1);
+ tree const_op1 = fold_non_dependent_expr_sfinae (op1, tf_none);
+ const_op1 = maybe_constant_value (const_op1);
if (TREE_CODE (const_op1) != INTEGER_CST)
const_op1 = op1;
result_type = type0;
@@ -4171,7 +4177,8 @@ cp_build_binary_op (location_t location,
}
else if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
{
- tree const_op1 = maybe_constant_value (op1);
+ tree const_op1 = fold_non_dependent_expr_sfinae (op1, tf_none);
+ const_op1 = maybe_constant_value (const_op1);
if (TREE_CODE (const_op1) != INTEGER_CST)
const_op1 = op1;
result_type = type0;