public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH PR d/89042] Committed fix for ICE when compiling void initialized enums
@ 2019-01-26 22:01 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2019-01-26 22:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

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.

---

[-- Attachment #2: pr89042.patch --]
[-- Type: text/x-patch, Size: 1099 bytes --]

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-26 21:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 22:01 [PATCH PR d/89042] Committed fix for ICE when compiling void initialized enums Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).