re PR d/88958 (ICE in walk_aliased_vdefs_1, at tree-ssa-alias.c:2887)
authorIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 10 Mar 2019 16:29:48 +0000 (16:29 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 10 Mar 2019 16:29:48 +0000 (16:29 +0000)
    PR d/88958
d/dmd: Merge upstream dmd 0fc786f49

Backport fix to disallow passing functions as parameters.

Fixes https://gcc.gnu.org/PR88958

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

From-SVN: r269557

gcc/d/dmd/MERGE
gcc/d/dmd/expressionsem.c
gcc/testsuite/gdc.test/fail_compilation/test19608.d [new file with mode: 0644]

index 3f416dbfb7be3a30ef81b79abbd3ff3752e3cfba..98bf8254554091b0bfd32a3958465c819a183372 100644 (file)
@@ -1,4 +1,4 @@
-d517c0e6a10b548f44d82b71b3c079663cb94f8e
+0fc786f4908aa6bdd4220af87995333b1f24c3d7
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 3fd5c1fa33f251def51c061bd1e28138eea39d5d..bcc1ac9ed2f979ec08ded064d873e1f70be33942 100644 (file)
@@ -102,6 +102,12 @@ static bool preFunctionParameters(Scope *sc, Expressions *exps)
                 arg = new ErrorExp();
                 err = true;
             }
+            else if (arg->type->toBasetype()->ty == Tfunction)
+            {
+                arg->error("cannot pass type %s as a function argument", arg->toChars());
+                arg = new ErrorExp();
+                err = true;
+            }
             else if (checkNonAssignmentArrayOp(arg))
             {
                 arg = new ErrorExp();
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19608.d b/gcc/testsuite/gdc.test/fail_compilation/test19608.d
new file mode 100644 (file)
index 0000000..cea84a6
--- /dev/null
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=19608
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test19608.d(15): Error: cannot pass function `*& f` as a function argument
+---
+*/
+import core.stdc.stdarg;
+
+void f(int) {}
+void g(...) {}
+void h()
+{
+    g(&f);  // OK, function address
+    g(*&f); // ICE -> Error
+}