From b0493acbe61a7c51771c6a1e1abc8c568341c498 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 3 Apr 2018 18:20:02 +0200 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl.c | 9 ++++++--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C | 2 +- gcc/testsuite/g++.dg/gomp/pr85134.C | 11 +++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr85134.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e97442a5bea..6404a74c363 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-04-03 Jakub Jelinek + + 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 PR c++/64095 - auto... parameter pack. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ba456737e0e..6ddbe2343f4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a53d46b6bac..bcc0714d107 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2018-04-03 Jakub Jelinek + 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. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C index 7066eabdfc7..f62a0d995c2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C @@ -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" } }; diff --git a/gcc/testsuite/g++.dg/gomp/pr85134.C b/gcc/testsuite/g++.dg/gomp/pr85134.C new file mode 100644 index 00000000000..9872ae53a92 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr85134.C @@ -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) + ; +} -- 2.30.2