2013-05-22 Jason Merrill <jason@redhat.com>
+ PR c++/56930
+ * call.c (convert_like_real): Use cp_convert_and_check.
+ * cvt.c (cp_convert_and_check): Use maybe_constant_value.
+ * semantics.c (cxx_eval_constant_expression): Handle LTGT_EXPR.
+ (potential_constant_expression_1): Handle OMP_ATOMIC*.
+
PR c++/56915
* semantics.c (maybe_add_lambda_conv_op): Give up if the call op
isn't defined.
if (convs->check_narrowing)
check_narrowing (totype, expr);
- if (issue_conversion_warnings && (complain & tf_warning))
- expr = convert_and_check (totype, expr);
+ if (issue_conversion_warnings)
+ expr = cp_convert_and_check (totype, expr, complain);
else
- expr = convert (totype, expr);
+ expr = cp_convert (totype, expr, complain);
return expr;
}
result = cp_convert (type, expr, complain);
if ((complain & tf_warning)
- && c_inhibit_evaluation_warnings == 0
- && !TREE_OVERFLOW_P (expr)
- && result != error_mark_node)
- warnings_for_convert_and_check (type, expr, result);
+ && c_inhibit_evaluation_warnings == 0)
+ {
+ tree folded = maybe_constant_value (expr);
+ tree stripped = folded;
+ tree folded_result = cp_convert (type, folded, complain);
+
+ /* maybe_constant_value wraps an INTEGER_CST with TREE_OVERFLOW in a
+ NOP_EXPR so that it isn't TREE_CONSTANT anymore. */
+ STRIP_NOPS (stripped);
+
+ if (!TREE_OVERFLOW_P (stripped)
+ && folded_result != error_mark_node)
+ warnings_for_convert_and_check (type, folded, folded_result);
+ }
return result;
}
case UNGT_EXPR:
case UNGE_EXPR:
case UNEQ_EXPR:
+ case LTGT_EXPR:
case RANGE_EXPR:
case COMPLEX_EXPR:
r = cxx_eval_binary_expression (call, t, allow_non_constant, addr,
case THROW_EXPR:
case MODIFY_EXPR:
case MODOP_EXPR:
+ case OMP_ATOMIC:
+ case OMP_ATOMIC_READ:
+ case OMP_ATOMIC_CAPTURE_OLD:
+ case OMP_ATOMIC_CAPTURE_NEW:
/* GCC internal stuff. */
case VA_ARG_EXPR:
case OBJ_TYPE_REF:
--- /dev/null
+// PR c++/56930
+// { dg-require-effective-target c++11 }
+// { dg-options -Wconversion }
+
+int main()
+{
+ int x = sizeof(int);
+ int y { sizeof(int) };
+}
+