]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix infinite loop in isAliasThisTuple
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 8 Apr 2025 14:36:15 +0000 (16:36 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 8 Apr 2025 14:36:15 +0000 (16:36 +0200)
This reverts a change in the upstream D implementation of the compiler,
as the refactoring introduced a regression.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 51816cd01d.

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

gcc/d/dmd/MERGE
gcc/d/dmd/expressionsem.d
gcc/testsuite/gdc.test/compilable/test21153.d [new file with mode: 0644]

index bd297b612c4e16bd6b548277b32042cd873ebb02..a05a50eefb8d413d54dffb5ec53938f391cd1ef3 100644 (file)
@@ -1,4 +1,4 @@
-ed17b3e95dc3fc3264a4c91843da824f5541f3e1
+51816cd01deee5cc1d7d2c6e1e24788ec655b73e
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index b0278cbaca1b10d8efdfecc521face0474d3902a..19111e31baa086b276722f1ecb4177a181d83583 100644 (file)
@@ -641,21 +641,25 @@ TupleDeclaration isAliasThisTuple(Expression e)
     Type t = e.type.toBasetype();
     while (true)
     {
-        Dsymbol s = t.toDsymbol(null);
-        if (!s)
-            return null;
-        auto ad = s.isAggregateDeclaration();
-        if (!ad)
-            return null;
-        s = ad.aliasthis ? ad.aliasthis.sym : null;
-        if (s && s.isVarDeclaration())
+        if (Dsymbol s = t.toDsymbol(null))
         {
-            TupleDeclaration td = s.isVarDeclaration().toAlias().isTupleDeclaration();
-            if (td && td.isexp)
-                return td;
+            if (auto ad = s.isAggregateDeclaration())
+            {
+                s = ad.aliasthis ? ad.aliasthis.sym : null;
+                if (s && s.isVarDeclaration())
+                {
+                    TupleDeclaration td = s.isVarDeclaration().toAlias().isTupleDeclaration();
+                    if (td && td.isexp)
+                        return td;
+                }
+                if (Type att = t.aliasthisOf())
+                {
+                    t = att;
+                    continue;
+                }
+            }
         }
-        if (Type att = t.aliasthisOf())
-            t = att;
+        return null;
     }
 }
 
diff --git a/gcc/testsuite/gdc.test/compilable/test21153.d b/gcc/testsuite/gdc.test/compilable/test21153.d
new file mode 100644 (file)
index 0000000..cd92a31
--- /dev/null
@@ -0,0 +1,8 @@
+// https://github.com/dlang/dmd/issues/21153
+alias AliasSeq(TList...) = TList;
+class DataClass;
+void reduce(DataClass[] r)
+{
+    alias Args = AliasSeq!(DataClass);
+    Args result = r[0];
+}