Commit 81012684 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/92343 ([[likely]]/[[unlikely]] prevent method from being a constant expression)

	PR c++/92343
	* constexpr.c (potential_constant_expression_1): Return true rather
	than false for PREDICT_EXPR.

	* g++.dg/cpp2a/attr-likely6.C: New test.

From-SVN: r277819
parent 8f119c55
2019-11-05 Jakub Jelinek <jakub@redhat.com> 2019-11-05 Jakub Jelinek <jakub@redhat.com>
PR c++/92343
* constexpr.c (potential_constant_expression_1): Return true rather
than false for PREDICT_EXPR.
* decl.c (omp_declare_variant_finalize_one): Call * decl.c (omp_declare_variant_finalize_one): Call
declare_simd_adjust_this not just on the context, but also on the declare_simd_adjust_this not just on the context, but also on the
variant-id expression for methods. Don't call variant-id expression for methods. Don't call
......
...@@ -6493,6 +6493,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, ...@@ -6493,6 +6493,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
case LABEL_DECL: case LABEL_DECL:
case LABEL_EXPR: case LABEL_EXPR:
case CASE_LABEL_EXPR: case CASE_LABEL_EXPR:
case PREDICT_EXPR:
case CONST_DECL: case CONST_DECL:
case SIZEOF_EXPR: case SIZEOF_EXPR:
case ALIGNOF_EXPR: case ALIGNOF_EXPR:
...@@ -7354,7 +7355,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, ...@@ -7354,7 +7355,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
return true; return true;
case EMPTY_CLASS_EXPR: case EMPTY_CLASS_EXPR:
case PREDICT_EXPR:
return false; return false;
case GOTO_EXPR: case GOTO_EXPR:
......
2019-11-05 Jakub Jelinek <jakub@redhat.com>
PR c++/92343
* g++.dg/cpp2a/attr-likely6.C: New test.
2019-11-05 Martin Liska <mliska@suse.cz> 2019-11-05 Martin Liska <mliska@suse.cz>
PR c++/92339 PR c++/92339
......
// PR c++/92343
// { dg-do compile { target c++14 } }
constexpr bool
foo (bool x)
{
if (x)
[[unlikely]] return true;
else
[[likely]] return false;
}
static_assert (foo (true), "");
static_assert (!foo (false), "");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment