@Override public Expression semantic(Scope sc, SemanticContext context) { if (type != null) { return this; } /* This is here to support extern(linkage) declaration, * where the extern(linkage) winds up being an AttribDeclaration * wrapper. */ Dsymbol s = declaration; AttribDeclaration ad = declaration.isAttribDeclaration(); if (ad != null) { if (ad.decl != null && ad.decl.size() == 1) { s = ad.decl.get(0); } } if (s.isVarDeclaration() != null) { // Do semantic() on initializer first, so: // int a = a; // will be illegal. declaration.semantic(sc, context); s.parent = sc.parent; } // Insert into both local scope and function scope. // Must be unique in both. if (s.ident != null) { if (sc.insert(s) == null) { if (context.acceptsErrors()) { context.acceptProblem( Problem.newSemanticTypeErrorLoc( IProblem.DeclarationIsAlreadyDefined, s, s.toChars(context))); } } else if (sc.func != null) { // VarDeclaration v = s.isVarDeclaration(); if ((s.isFuncDeclaration() != null /*|| v && v.storage_class & STCstatic*/) && sc.func.localsymtab.insert(s) == null) { if (context.acceptsErrors()) { context.acceptProblem( Problem.newSemanticTypeError( IProblem.DeclarationIsAlreadyDefinedInAnotherScope, this, s.toPrettyChars(context), sc.func.toChars(context))); } } else if (!context.global.params.useDeprecated) { // Disallow shadowing for (Scope scx = sc.enclosing; scx != null && scx.func == sc.func; scx = scx.enclosing) { Dsymbol s2; if (scx.scopesym != null && scx.scopesym.symtab != null && (s2 = scx.scopesym.symtab.lookup(s.ident)) != null && s != s2) { if (context.acceptsErrors()) { context.acceptProblem( Problem.newSemanticTypeErrorLoc( IProblem.ShadowingDeclarationIsDeprecated, s, s.toPrettyChars(context))); } } } } } } if (s.isVarDeclaration() == null) { declaration.semantic(sc, context); s.parent = sc.parent; } // Commented this for Descent: we want semantic even if there are errors // if (context.global.errors == 0) { declaration.semantic2(sc, context); // if (context.global.errors == 0) { declaration.semantic3(sc, context); // } // } type = Type.tvoid; return this; }