[PR,d/89042] Committed fix for ICE when compiling void initialized enums

Message ID CABOHX+e5MCnpNhssGBVrYNjZ+p-2M9Awks-dYXfbGpEP51ESSw@mail.gmail.com
State New
Headers show
Series
  • [PR,d/89042] Committed fix for ICE when compiling void initialized enums
Related show

Commit Message

Iain Buclaw Jan. 26, 2019, 9:08 p.m.
Hi,

This patch changes an assertion into an early return condition, fixing
PR d/89042.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r268304.

-- 
Iain
---
gcc/d/ChangeLog:

2019-01-26  Iain Buclaw  <ibuclaw@gdcproject.org>

        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  <ibuclaw@gdcproject.org>

        PR d/89042
        * gdc.dg/pr89042a.d: New test.
        * gdc.dg/pr89042b.d: New test.

---

Patch

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/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;