From e4e13e261060dde55de4f7135fe09a816a51f929 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sat, 26 Jan 2019 21:07:15 +0000 Subject: [PATCH] Fix ICE when handling void initialized manifest constants. gcc/d/ChangeLog: 2019-01-26 Iain Buclaw PR d/89042 * decl.cc (DeclVisitor::visit(VarDeclaration)): Don't assert if handling a void initialized manifest constant. gcc/testsuite/ChangeLog: 2019-01-26 Iain Buclaw PR d/89042 * gdc.dg/pr89042a.d: New test. * gdc.dg/pr89042b.d: New test. From-SVN: r268304 --- gcc/d/ChangeLog | 6 ++++++ gcc/d/decl.cc | 5 ++++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gdc.dg/pr89042a.d | 2 ++ gcc/testsuite/gdc.dg/pr89042b.d | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gdc.dg/pr89042a.d create mode 100644 gcc/testsuite/gdc.dg/pr89042b.d diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index 7014b215f5a..151fe1c6ab1 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,9 @@ +2019-01-26 Iain Buclaw + + PR d/89042 + * decl.cc (DeclVisitor::visit(VarDeclaration)): Don't assert if + handling a void initialized manifest constant. + 2019-01-21 Iain Buclaw * d-frontend.cc (Compiler::paintAsType): Update for new signature. diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index aba1abbf891..7edfe523d3e 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -593,8 +593,11 @@ public: if (d->isInstantiated ()) return; + /* Cannot make an expression out of a void initializer. */ + if (!d->_init || d->_init->isVoidInitializer ()) + return; + tree decl = get_symbol_decl (d); - gcc_assert (d->_init && !d->_init->isVoidInitializer ()); Expression *ie = initializerToExpression (d->_init); /* CONST_DECL was initially intended for enumerals and may be used for diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6f6e0f266f..f1e89d56010 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-01-26 Iain Buclaw + + PR d/89042 + * gdc.dg/pr89042a.d: New test. + * gdc.dg/pr89042b.d: New test. + 2019-01-26 Harald Anlauf PR fortran/57553 diff --git a/gcc/testsuite/gdc.dg/pr89042a.d b/gcc/testsuite/gdc.dg/pr89042a.d new file mode 100644 index 00000000000..42e05aee181 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr89042a.d @@ -0,0 +1,2 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89042 +enum void[] a = void; diff --git a/gcc/testsuite/gdc.dg/pr89042b.d b/gcc/testsuite/gdc.dg/pr89042b.d new file mode 100644 index 00000000000..73a1c6eff2d --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr89042b.d @@ -0,0 +1,2 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89042 +enum void[2] a = void; -- 2.30.2