From 5767d76f8f1ee56b68e794ccb65a720a8a3581c7 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 16 Jun 2019 07:50:31 +0000 Subject: [PATCH] re PR d/90863 (ICE in StatementSemanticVisitor::visit, at d/dmd/statementsem.c:1992) PR d/90863 d/dmd: Merge upstream dmd 6e44734cc Fixes segmentation fault in StatementSemanticVisitor::visit. Reviewed-on: https://github.com/dlang/dmd/pull/10033 From-SVN: r272352 --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/blockexit.c | 2 ++ gcc/d/dmd/statementsem.c | 4 ++-- gcc/testsuite/gdc.test/fail_compilation/fail19955.d | 8 ++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gdc.test/fail_compilation/fail19955.d diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 4111fc97044..0620a5ba556 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -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. diff --git a/gcc/d/dmd/blockexit.c b/gcc/d/dmd/blockexit.c index e9d3f105429..c3b60b88216 100644 --- a/gcc/d/dmd/blockexit.c +++ b/gcc/d/dmd/blockexit.c @@ -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; diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c index 167836c0478..143864dc666 100644 --- a/gcc/d/dmd/statementsem.c +++ b/gcc/d/dmd/statementsem.c @@ -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 index 00000000000..7cdce2c676a --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail19955.d @@ -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); } -- 2.30.2