diff options
author | Jason Merrill <jason@redhat.com> | 2013-05-22 23:47:35 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-05-22 23:47:35 -0400 |
commit | da834cfcb0c8e59936cf3697b81b2693e5eb2ed0 (patch) | |
tree | f559f205ee21dd8d310cbaaaf0b783b7b4d16527 /gcc | |
parent | 2701664a0266af935d5fea7c5586a5686fe32365 (diff) | |
download | gcc-da834cfcb0c8e59936cf3697b81b2693e5eb2ed0.zip gcc-da834cfcb0c8e59936cf3697b81b2693e5eb2ed0.tar.gz gcc-da834cfcb0c8e59936cf3697b81b2693e5eb2ed0.tar.bz2 |
re PR c++/56930 (pointless -Wconversion warning with sizeof)
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*.
From-SVN: r199232
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 18 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist71.C | 10 |
5 files changed, 38 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cd58d70..7025f34 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 71a1589d..0b6a83f 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6199,10 +6199,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, 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; } diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 93be76a..d9e905e 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -624,10 +624,20 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain) 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; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5b36337..c115d23 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8045,6 +8045,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, 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, @@ -8620,6 +8621,10 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) 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: diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist71.C b/gcc/testsuite/g++.dg/cpp0x/initlist71.C new file mode 100644 index 0000000..1d14390 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist71.C @@ -0,0 +1,10 @@ +// PR c++/56930 +// { dg-require-effective-target c++11 } +// { dg-options -Wconversion } + +int main() +{ + int x = sizeof(int); + int y { sizeof(int) }; +} + |