Fix ICE when handling void initialized manifest constants.
authorIain Buclaw <ibuclaw@gdcproject.org>
Sat, 26 Jan 2019 21:07:15 +0000 (21:07 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sat, 26 Jan 2019 21:07:15 +0000 (21:07 +0000)
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.

From-SVN: r268304

gcc/d/ChangeLog
gcc/d/decl.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gdc.dg/pr89042a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr89042b.d [new file with mode: 0644]

index 7014b215f5a6415adab857b8b6dae5cb5077e566..151fe1c6ab1f62b2d6e9fce860dda8f577b8d680 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2019-01-21  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        * d-frontend.cc (Compiler::paintAsType): Update for new signature.
index aba1abbf89157d10439e25d87d71f5df851da619..7edfe523d3e92be0276a0806ec00c3b39b5e07a4 100644 (file)
@@ -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
index d6f6e0f266f31a7a9df4fade2a1836d2d6648c26..f1e89d56010e2237b6fb6046f6db522f5f6619cd 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-26  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+       PR d/89042
+       * gdc.dg/pr89042a.d: New test.
+       * gdc.dg/pr89042b.d: New test.
+
 2019-01-26  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/57553
diff --git a/gcc/testsuite/gdc.dg/pr89042a.d b/gcc/testsuite/gdc.dg/pr89042a.d
new file mode 100644 (file)
index 0000000..42e05ae
--- /dev/null
@@ -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 (file)
index 0000000..73a1c6e
--- /dev/null
@@ -0,0 +1,2 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89042
+enum void[2] a = void;