]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR d/90863
authoribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:50:31 +0000 (07:50 +0000)
committeribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:50:31 +0000 (07:50 +0000)
d/dmd: Merge upstream dmd 6e44734cc

Fixes segmentation fault in StatementSemanticVisitor::visit.

Reviewed-on: https://github.com/dlang/dmd/pull/10033

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272352 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/d/dmd/MERGE
gcc/d/dmd/blockexit.c
gcc/d/dmd/statementsem.c
gcc/testsuite/gdc.test/fail_compilation/fail19955.d [new file with mode: 0644]

index 4111fc97044b943ef638bf03f336c19c36d5f6ed..0620a5ba5564442b8d149f0474739a6edf4ad10c 100644 (file)
@@ -1,4 +1,4 @@
-7afcc60c30554e452eacdfbefc4951ebf601fccd
+6e44734ccbeb78252a52e129a67fefb313679948
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index e9d3f105429b6a3fe311f37860bcebac4dc75a19..c3b60b88216b1ab908063fed87c3051b248ef9e3 100644 (file)
@@ -496,6 +496,8 @@ int blockExit(Statement *s, FuncDeclaration *func, bool mustNotThrow)
         }
     };
 
+    if (!s)
+        return BEfallthru;
     BlockExit be(func, mustNotThrow);
     s->accept(&be);
     return be.result;
index 167836c0478ed79be74e4097679a3e7a150c739d..143864dc666aee7a651c2c8a6cd405ca351005f4 100644 (file)
@@ -2035,7 +2035,7 @@ public:
         ss->_body = semantic(ss->_body, sc);
         sc->noctor--;
 
-        if (conditionError || ss->_body->isErrorStatement())
+        if (conditionError || (ss->_body && ss->_body->isErrorStatement()))
             goto Lerror;
 
         // Resolve any goto case's with exp
@@ -2111,7 +2111,7 @@ public:
         {
             ss->hasNoDefault = 1;
 
-            if (!ss->isFinal && !ss->_body->isErrorStatement())
+            if (!ss->isFinal && (!ss->_body || !ss->_body->isErrorStatement()))
                 ss->error("switch statement without a default; use 'final switch' or add 'default: assert(0);' or add 'default: break;'");
 
             // Generate runtime error if the default is hit
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19955.d b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d
new file mode 100644 (file)
index 0000000..7cdce2c
--- /dev/null
@@ -0,0 +1,8 @@
+// PERMUTE_ARGS:
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19955.d(8): Error: `switch` statement without a `default`; use `final switch` or add `default: assert(0);` or add `default: break;`
+---
+*/
+void f() { switch(1) static assert(1); }