]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix ICE during error recovery in semantic pass
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 23 Jun 2020 20:43:27 +0000 (22:43 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 26 Jun 2020 13:45:39 +0000 (15:45 +0200)
Fixes a regression caused by an incomplete backport of converting the
Expression semantic pass to a Visitor.

gcc/d/ChangeLog:

PR d/95250
* dmd/expressionsem.c (class ExpressionSemanticVisitor): Return early
if error occurred during semantic of DivExp.

gcc/testsuite/ChangeLog:

PR d/95250
* gdc.dg/pr95250.d: New test.

(cherry picked from commit 1d19c9cd3dd99ba8885c0fc93223918399f73939)

gcc/d/dmd/expressionsem.c
gcc/testsuite/gdc.dg/pr95250.d [new file with mode: 0644]

index 629768aaf067b8ef9d9cb27048ab1fe83a9f215f..3221a8ae1121cfd3f07e4994ec56e82a53f9b186 100644 (file)
@@ -6887,6 +6887,7 @@ public:
         if (Expression *ex = binSemanticProp(exp, sc))
         {
             result = ex;
+            return;
         }
         Expression *e = exp->op_overload(sc);
         if (e)
diff --git a/gcc/testsuite/gdc.dg/pr95250.d b/gcc/testsuite/gdc.dg/pr95250.d
new file mode 100644 (file)
index 0000000..dfb8abb
--- /dev/null
@@ -0,0 +1,18 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95250
+// { dg-do compile }
+
+template Unsigned(T)
+{
+    static assert(false, "Type " ~ T.stringof ~
+                  " does not have an Unsigned counterpart");
+}
+
+
+void* f(T)(T a, T b)
+{
+        alias UnsignedVoid = Unsigned!(T);
+        return cast(T)(cast(T)(cast(UnsignedVoid)(a-b) / 2));
+}
+
+static assert(is(typeof(f!(void*)(null, null)) == void*));
+// { dg-error "static assert  \(.*\) is false" "" { target *-*-* } .-1 }