diff options
author | Marek Polacek <polacek@redhat.com> | 2018-03-01 17:08:35 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-03-01 17:08:35 +0000 |
commit | d8cff23f65befa76082b54bd478c0b9299255788 (patch) | |
tree | 2282e0c590013134b8aab0590d2d4d9ef06c97b7 /gcc | |
parent | 26a0cc94f32ed95616d1618857d35d2ef1506118 (diff) | |
download | gcc-d8cff23f65befa76082b54bd478c0b9299255788.zip gcc-d8cff23f65befa76082b54bd478c0b9299255788.tar.gz gcc-d8cff23f65befa76082b54bd478c0b9299255788.tar.bz2 |
re PR c++/84596 (internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression))
PR c++/84596
* constexpr.c (require_rvalue_constant_expression): New function.
* cp-tree.h: Declare it.
* semantics.c (finish_static_assert): Use it instead of
require_potential_rvalue_constant_expression.
* g++.dg/cpp0x/static_assert14.C: New test.
From-SVN: r258107
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 15 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/static_assert14.C | 7 |
6 files changed, 35 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a6deacb..acaabd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2018-03-01 Marek Polacek <polacek@redhat.com> + + PR c++/84596 + * constexpr.c (require_rvalue_constant_expression): New function. + * cp-tree.h: Declare it. + * semantics.c (finish_static_assert): Use it instead of + require_potential_rvalue_constant_expression. + 2018-03-01 Jason Merrill <jason@redhat.com> Alexandre Oliva <aoliva@redhat.com> diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 4bbdbf4..39e6cdfb 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -6047,7 +6047,8 @@ potential_rvalue_constant_expression (tree t) bool require_potential_constant_expression (tree t) { - return potential_constant_expression_1 (t, false, true, false, tf_warning_or_error); + return potential_constant_expression_1 (t, false, true, false, + tf_warning_or_error); } /* Cross product of the above. */ @@ -6055,7 +6056,17 @@ require_potential_constant_expression (tree t) bool require_potential_rvalue_constant_expression (tree t) { - return potential_constant_expression_1 (t, true, true, false, tf_warning_or_error); + return potential_constant_expression_1 (t, true, true, false, + tf_warning_or_error); +} + +/* Like above, but don't consider PARM_DECL a potential_constant_expression. */ + +bool +require_rvalue_constant_expression (tree t) +{ + return potential_constant_expression_1 (t, true, true, true, + tf_warning_or_error); } /* Like potential_constant_expression, but don't consider possible constexpr diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 743dd34..17d8c6d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7409,6 +7409,7 @@ extern bool is_static_init_expression (tree); extern bool potential_rvalue_constant_expression (tree); extern bool require_potential_constant_expression (tree); extern bool require_constant_expression (tree); +extern bool require_rvalue_constant_expression (tree); extern bool require_potential_rvalue_constant_expression (tree); extern tree cxx_constant_value (tree, tree = NULL_TREE); extern tree cxx_constant_init (tree, tree = NULL_TREE); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 35569d0..87c5c66 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8671,7 +8671,7 @@ finish_static_assert (tree condition, tree message, location_t location, else if (condition && condition != error_mark_node) { error ("non-constant condition for static assertion"); - if (require_potential_rvalue_constant_expression (condition)) + if (require_rvalue_constant_expression (condition)) cxx_constant_value (condition); } input_location = saved_loc; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a45412..bcb40ba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-01 Marek Polacek <polacek@redhat.com> + + PR c++/84596 + * g++.dg/cpp0x/static_assert14.C: New test. + 2018-03-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/79410 diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert14.C b/gcc/testsuite/g++.dg/cpp0x/static_assert14.C new file mode 100644 index 0000000..ee709f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert14.C @@ -0,0 +1,7 @@ +// PR c++/84596 +// { dg-do compile { target c++11 } } + +template<int x> +void b(int c) { + static_assert (c, "c"); // { dg-error "non-constant|not a constant" } +} |