]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/d/dmd/dtemplate.c
PR d/90603
[thirdparty/gcc.git] / gcc / d / dmd / dtemplate.c
index 0173ee401b685c9a2b52602554e8014042c8eb31..b5e3662a9e30b855fb181731009aa7b8d1ef78f1 100644 (file)
@@ -685,6 +685,7 @@ void TemplateDeclaration::semantic(Scope *sc)
     /* BUG: should check:
      *  o no virtual functions or non-static data members of classes
      */
+    semanticRun = PASSsemanticdone;
 }
 
 const char *TemplateDeclaration::kind() const
@@ -2169,12 +2170,14 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc,
             if (tiargs && tiargs->dim > 0)
                 return 0;
 
-            if (fd->semanticRun == PASSinit && fd->_scope)
+            // constructors need a valid scope in order to detect semantic errors
+            if (!fd->isCtorDeclaration() &&
+                fd->semanticRun < PASSsemanticdone)
             {
                 Ungag ungag = fd->ungagSpeculative();
-                fd->semantic(fd->_scope);
+                fd->semantic(NULL);
             }
-            if (fd->semanticRun == PASSinit)
+            if (fd->semanticRun < PASSsemanticdone)
             {
                 ::error(loc, "forward reference to template %s", fd->toChars());
                 return 1;