diff options
Diffstat (limited to 'gcc/d/dmd/expressionsem.d')
-rw-r--r-- | gcc/d/dmd/expressionsem.d | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d index 22a1f45f4e8..d4e96bb0f09 100644 --- a/gcc/d/dmd/expressionsem.d +++ b/gcc/d/dmd/expressionsem.d @@ -5216,13 +5216,30 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (s.ident) { VarDeclaration v = s.isVarDeclaration(); - if (v && !(sc.flags & SCOPE.Cfile)) + if (v) { - /* Do semantic() on initializer first so this will be illegal: - * int a = a; - */ - e.declaration.dsymbolSemantic(sc); - s.parent = sc.parent; + if (sc.flags & SCOPE.Cfile) + { + /* Do semantic() on the type before inserting v into the symbol table + */ + if (!v.originalType) + v.originalType = v.type.syntaxCopy(); + Scope* sc2 = sc.push(); + sc2.stc |= v.storage_class & STC.FUNCATTR; + sc2.linkage = LINK.c; // account for the extern(C) in front of the declaration + v.inuse++; + v.type = v.type.typeSemantic(v.loc, sc2); + v.inuse--; + sc2.pop(); + } + else + { + /* Do semantic() on initializer first so this will be illegal: + * int a = a; + */ + e.declaration.dsymbolSemantic(sc); + s.parent = sc.parent; + } } if (!sc.insert(s)) |