re PR c++/85134 (ICE with invalid constexpr in 'shared' OpenMP clause)

PR c++/85134
	* decl.c (cp_finish_decl): If ensure_literal_type_for_constexpr_object
	fails, after clearing DECL_DECLARED_CONSTEXPR_P don't return early,
	instead for static data members clear init and set DECL_EXTERNAL.

	* g++.dg/gomp/pr85134.C: New test.
	* g++.dg/cpp0x/constexpr-ice19.C: Expect one further error.

From-SVN: r259038
This commit is contained in:
Jakub Jelinek 2018-04-03 18:20:02 +02:00 committed by Jakub Jelinek
parent 4304d6180a
commit b0493acbe6
5 changed files with 29 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR c++/85134
* decl.c (cp_finish_decl): If ensure_literal_type_for_constexpr_object
fails, after clearing DECL_DECLARED_CONSTEXPR_P don't return early,
instead for static data members clear init and set DECL_EXTERNAL.
2018-04-02 Jason Merrill <jason@redhat.com>
PR c++/64095 - auto... parameter pack.

View File

@ -6923,11 +6923,14 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
}
if (ensure_literal_type_for_constexpr_object (decl)
== error_mark_node)
if (ensure_literal_type_for_constexpr_object (decl) == error_mark_node)
{
DECL_DECLARED_CONSTEXPR_P (decl) = 0;
return;
if (VAR_P (decl) && DECL_CLASS_SCOPE_P (decl))
{
init = NULL_TREE;
DECL_EXTERNAL (decl) = 1;
}
}
if (VAR_P (decl)

View File

@ -1,5 +1,9 @@
2018-04-03 Jakub Jelinek <jakub@redhat.com>
PR c++/85134
* g++.dg/gomp/pr85134.C: New test.
* g++.dg/cpp0x/constexpr-ice19.C: Expect one further error.
PR target/85169
* gcc.c-torture/execute/pr85169.c: New test.
* gcc.target/i386/avx512f-pr85169.c: New test.

View File

@ -9,5 +9,5 @@ struct A
struct B
{
static constexpr A a {}; // { dg-error "not literal" }
static constexpr A a {}; // { dg-error "not literal|in-class initialization" }
};

View File

@ -0,0 +1,11 @@
// PR c++/85134
// { dg-do compile }
// { dg-options "-std=c++14 -fopenmp" }
void
foo (int i)
{
constexpr int x[i] = {}; // { dg-error "'constexpr' variable 'x' has variably-modified type" }
#pragma omp parallel shared(x)
;
}