From patchwork Sun Jun 7 23:03:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1304903 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=RtWzyn7I; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49gBlS0RVxz9sRK for ; Mon, 8 Jun 2020 09:04:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 759403851C33; Sun, 7 Jun 2020 23:03:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 759403851C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591571038; bh=MeEYl4Z6EzgG+cO+C8rFCnargQfmI6/su+up2Cm+WpY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RtWzyn7IIzBQQHx1wK7M1VyBVLYl4gb4StXBi/d+JkUnMR5oZHBrCvHJfJp+iCLiL AWmK7lupSl8ikexnRHOojMRzRrYPf15w30s8EXYLMunh9E+D73LW7DXS30HIgEFWFF Sq+wAG0LHzX1/fbxgGkcxrlVFcKERujkM5aO8a4U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id E01C53851C24 for ; Sun, 7 Jun 2020 23:03:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E01C53851C24 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 49gBlD21sLzQlBt; Mon, 8 Jun 2020 01:03:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id fGIUWuHK0bt9; Mon, 8 Jun 2020 01:03:46 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Merge upstream dmd 73d8e2fec. Date: Mon, 8 Jun 2020 01:03:44 +0200 Message-Id: <20200607230344.29631-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2F6BF1739 X-Rspamd-Score: 1.18 / 15.00 / 15.00 X-Spam-Status: No, score=-17.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch merges the D front-end implementation with upstream dmd 73d8e2fec. Renames the enum PROTKIND to Prot::Kind, updates all uses of the original enum accordingly. Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards Iain. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 73d8e2fec. * decl.cc (get_symbol_decl): Use new Prot::Kind enum. * modules.cc (get_internal_fn): Likewise. --- gcc/d/decl.cc | 4 +-- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/access.c | 64 +++++++++++++++++++-------------------- gcc/d/dmd/arrayop.c | 2 +- gcc/d/dmd/attrib.c | 8 ++--- gcc/d/dmd/dclass.c | 4 +-- gcc/d/dmd/declaration.c | 8 ++--- gcc/d/dmd/denum.c | 4 +-- gcc/d/dmd/dimport.c | 2 +- gcc/d/dmd/dmodule.c | 2 +- gcc/d/dmd/doc.c | 16 +++++----- gcc/d/dmd/dscope.c | 6 ++-- gcc/d/dmd/dstruct.c | 8 ++--- gcc/d/dmd/dsymbol.c | 24 +++++++-------- gcc/d/dmd/dsymbol.h | 29 +++++++++--------- gcc/d/dmd/dtemplate.c | 6 ++-- gcc/d/dmd/expressionsem.c | 2 +- gcc/d/dmd/func.c | 24 +++++++-------- gcc/d/dmd/hdrgen.c | 18 +++++------ gcc/d/dmd/json.c | 4 +-- gcc/d/dmd/mtype.c | 2 +- gcc/d/dmd/nspace.c | 2 +- gcc/d/dmd/parse.c | 34 ++++++++++----------- gcc/d/modules.cc | 2 +- 24 files changed, 138 insertions(+), 139 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index a2a21428a26..bcee0b21e7d 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1325,9 +1325,9 @@ get_symbol_decl (Declaration *decl) TREE_THIS_VOLATILE (decl->csym) = 1; /* Protection attributes are used by the debugger. */ - if (decl->protection.kind == PROTprivate) + if (decl->protection.kind == Prot::private_) TREE_PRIVATE (decl->csym) = 1; - else if (decl->protection.kind == PROTprotected) + else if (decl->protection.kind == Prot::protected_) TREE_PROTECTED (decl->csym) = 1; /* Likewise, so could the deprecated attribute. */ diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 96d579b90fc..f71d20cf462 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -108ca1bcde2096a2c6173c567a204d749538dd74 +73d8e2fecb9e73422464b4cbf71f2b2967c9a75d The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/access.c b/gcc/d/dmd/access.c index 89ea487b106..f79eaeb8690 100644 --- a/gcc/d/dmd/access.c +++ b/gcc/d/dmd/access.c @@ -39,7 +39,7 @@ static Dsymbol *mostVisibleOverload(Dsymbol *s); */ Prot getAccess(AggregateDeclaration *ad, Dsymbol *smember) { - Prot access_ret = Prot(PROTnone); + Prot access_ret = Prot(Prot::none); assert(ad->isStructDeclaration() || ad->isClassDeclaration()); if (smember->toParent() == ad) @@ -59,20 +59,20 @@ Prot getAccess(AggregateDeclaration *ad, Dsymbol *smember) Prot access = getAccess(b->sym, smember); switch (access.kind) { - case PROTnone: + case Prot::none: break; - case PROTprivate: - access_ret = Prot(PROTnone); // private members of base class not accessible + case Prot::private_: + access_ret = Prot(Prot::none); // private members of base class not accessible break; - case PROTpackage: - case PROTprotected: - case PROTpublic: - case PROTexport: + case Prot::package_: + case Prot::protected_: + case Prot::public_: + case Prot::export_: // If access is to be tightened - if (PROTpublic < access.kind) - access = Prot(PROTpublic); + if (Prot::public_ < access.kind) + access = Prot(Prot::public_); // Pick path with loosest access if (access_ret.isMoreRestrictiveThan(access)) @@ -114,7 +114,7 @@ static bool isAccessible( { BaseClass *b = (*cdthis->baseclasses)[i]; Prot access = getAccess(b->sym, smember); - if (access.kind >= PROTprotected || + if (access.kind >= Prot::protected_ || isAccessible(smember, sfunc, b->sym, cdscope)) { return true; @@ -164,17 +164,17 @@ bool checkAccess(AggregateDeclaration *ad, Loc loc, Scope *sc, Dsymbol *smember) if (smemberparent == ad) { access = smember->prot(); - result = access.kind >= PROTpublic || + result = access.kind >= Prot::public_ || hasPrivateAccess(ad, f) || isFriendOf(ad, cdscope) || - (access.kind == PROTpackage && hasPackageAccess(sc, smember)) || + (access.kind == Prot::package_ && hasPackageAccess(sc, smember)) || ad->getAccessModule() == sc->_module; } - else if ((access = getAccess(ad, smember)).kind >= PROTpublic) + else if ((access = getAccess(ad, smember)).kind >= Prot::public_) { result = true; } - else if (access.kind == PROTpackage && hasPackageAccess(sc, ad)) + else if (access.kind == Prot::package_ && hasPackageAccess(sc, ad)) { result = true; } @@ -343,8 +343,8 @@ bool checkAccess(Loc loc, Scope *sc, Expression *e, Declaration *d) } if (!e) { - if ((d->prot().kind == PROTprivate && d->getAccessModule() != sc->_module) || - (d->prot().kind == PROTpackage && !hasPackageAccess(sc, d))) + if ((d->prot().kind == Prot::private_ && d->getAccessModule() != sc->_module) || + (d->prot().kind == Prot::package_ && !hasPackageAccess(sc, d))) { error(loc, "%s %s is not accessible from module %s", d->kind(), d->toPrettyChars(), sc->_module->toChars()); @@ -392,7 +392,7 @@ bool checkAccess(Loc loc, Scope *sc, Package *p) return false; for (; sc; sc = sc->enclosing) { - if (sc->scopesym && sc->scopesym->isPackageAccessible(p, Prot(PROTprivate))) + if (sc->scopesym && sc->scopesym->isPackageAccessible(p, Prot(Prot::private_))) return false; } const char *name = p->toPrettyChars(); @@ -418,18 +418,18 @@ bool symbolIsVisible(Module *mod, Dsymbol *s) switch (s->prot().kind) { - case PROTundefined: + case Prot::undefined: return true; - case PROTnone: + case Prot::none: return false; // no access - case PROTprivate: + case Prot::private_: return s->getAccessModule() == mod; - case PROTpackage: + case Prot::package_: return s->getAccessModule() == mod || hasPackageAccess(mod, s); - case PROTprotected: + case Prot::protected_: return s->getAccessModule() == mod; - case PROTpublic: - case PROTexport: + case Prot::public_: + case Prot::export_: return true; default: assert(0); @@ -459,18 +459,18 @@ bool symbolIsVisible(Scope *sc, Dsymbol *s) switch (s->prot().kind) { - case PROTundefined: + case Prot::undefined: return true; - case PROTnone: + case Prot::none: return false; // no access - case PROTprivate: + case Prot::private_: return sc->_module == s->getAccessModule(); - case PROTpackage: + case Prot::package_: return sc->_module == s->getAccessModule() || hasPackageAccess(sc->_module, s); - case PROTprotected: + case Prot::protected_: return hasProtectedAccess(sc, s); - case PROTpublic: - case PROTexport: + case Prot::public_: + case Prot::export_: return true; default: assert(0); diff --git a/gcc/d/dmd/arrayop.c b/gcc/d/dmd/arrayop.c index 3beba9a206b..72abd5e9b30 100644 --- a/gcc/d/dmd/arrayop.c +++ b/gcc/d/dmd/arrayop.c @@ -70,7 +70,7 @@ FuncDeclaration *buildArrayOp(Identifier *ident, BinExp *exp, Scope *sc) //printf("fd: %s %s\n", ident->toChars(), ftype->toChars()); FuncDeclaration *fd = new FuncDeclaration(Loc(), Loc(), ident, STCundefined, ftype); fd->fbody = fbody; - fd->protection = Prot(PROTpublic); + fd->protection = Prot(Prot::public_); fd->linkage = LINKc; fd->isArrayOp = 1; diff --git a/gcc/d/dmd/attrib.c b/gcc/d/dmd/attrib.c index 81b2da11e56..5445b9e5968 100644 --- a/gcc/d/dmd/attrib.c +++ b/gcc/d/dmd/attrib.c @@ -596,7 +596,7 @@ ProtDeclaration::ProtDeclaration(Loc loc, Identifiers* pkg_identifiers, Dsymbols : AttribDeclaration(decl) { this->loc = loc; - this->protection.kind = PROTpackage; + this->protection.kind = Prot::package_; this->protection.pkg = NULL; this->pkg_identifiers = pkg_identifiers; } @@ -604,7 +604,7 @@ ProtDeclaration::ProtDeclaration(Loc loc, Identifiers* pkg_identifiers, Dsymbols Dsymbol *ProtDeclaration::syntaxCopy(Dsymbol *s) { assert(!s); - if (protection.kind == PROTpackage) + if (protection.kind == Prot::package_) return new ProtDeclaration(this->loc, pkg_identifiers, Dsymbol::arraySyntaxCopy(decl)); else return new ProtDeclaration(this->loc, protection, Dsymbol::arraySyntaxCopy(decl)); @@ -629,7 +629,7 @@ void ProtDeclaration::addMember(Scope *sc, ScopeDsymbol *sds) pkg_identifiers = NULL; } - if (protection.kind == PROTpackage && protection.pkg && sc->_module) + if (protection.kind == Prot::package_ && protection.pkg && sc->_module) { Module *m = sc->_module; Package* pkg = m->parent ? m->parent->isPackage() : NULL; @@ -648,7 +648,7 @@ const char *ProtDeclaration::kind() const const char *ProtDeclaration::toPrettyChars(bool) { - assert(protection.kind > PROTundefined); + assert(protection.kind > Prot::undefined); OutBuffer buf; buf.writeByte('\''); diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c index 3d6f6227eb3..73e571b4da9 100644 --- a/gcc/d/dmd/dclass.c +++ b/gcc/d/dmd/dclass.c @@ -867,7 +867,7 @@ Lancestorsdone: { VarDeclaration *vd = fields[i]; if (!vd->isThisDeclaration() && - !vd->prot().isMoreRestrictiveThan(Prot(PROTpublic))) + !vd->prot().isMoreRestrictiveThan(Prot(Prot::public_))) { vd->error("Field members of a synchronized class cannot be %s", protectionToChars(vd->prot().kind)); @@ -988,7 +988,7 @@ Dsymbol *ClassDeclaration::search(const Loc &loc, Identifier *ident, int flags) continue; else if (s == this) // happens if s is nested in this and derives from this s = NULL; - else if (!(flags & IgnoreSymbolVisibility) && !(s->prot().kind == PROTprotected) && !symbolIsVisible(this, s)) + else if (!(flags & IgnoreSymbolVisibility) && !(s->prot().kind == Prot::protected_) && !symbolIsVisible(this, s)) s = NULL; else break; diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c index aa48195794b..08b295070b2 100644 --- a/gcc/d/dmd/declaration.c +++ b/gcc/d/dmd/declaration.c @@ -75,7 +75,7 @@ Declaration::Declaration(Identifier *id) type = NULL; originalType = NULL; storage_class = STCundefined; - protection = Prot(PROTundefined); + protection = Prot(Prot::undefined); linkage = LINKdefault; inuse = 0; mangleOverride = NULL; @@ -1830,12 +1830,12 @@ bool VarDeclaration::needThis() bool VarDeclaration::isExport() const { - return protection.kind == PROTexport; + return protection.kind == Prot::export_; } bool VarDeclaration::isImportedSymbol() const { - if (protection.kind == PROTexport && !_init && + if (protection.kind == Prot::export_ && !_init && (storage_class & STCstatic || parent->isModule())) return true; return false; @@ -2218,7 +2218,7 @@ TypeInfoDeclaration::TypeInfoDeclaration(Type *tinfo) { this->tinfo = tinfo; storage_class = STCstatic | STCgshared; - protection = Prot(PROTpublic); + protection = Prot(Prot::public_); linkage = LINKc; alignment = target.ptrsize; } diff --git a/gcc/d/dmd/denum.c b/gcc/d/dmd/denum.c index f96380f572a..b881fb6df15 100644 --- a/gcc/d/dmd/denum.c +++ b/gcc/d/dmd/denum.c @@ -37,7 +37,7 @@ EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype) defaultval = NULL; sinit = NULL; isdeprecated = false; - protection = Prot(PROTundefined); + protection = Prot(Prot::undefined); parent = NULL; added = false; inuse = 0; @@ -550,7 +550,7 @@ void EnumMember::semantic(Scope *sc) semanticRun = PASSsemantic; - protection = ed->isAnonymous() ? ed->protection : Prot(PROTpublic); + protection = ed->isAnonymous() ? ed->protection : Prot(Prot::public_); linkage = LINKd; storage_class = STCmanifest; userAttribDecl = ed->isAnonymous() ? ed->userAttribDecl : NULL; diff --git a/gcc/d/dmd/dimport.c b/gcc/d/dmd/dimport.c index 32602d27e6c..4b969d4dd60 100644 --- a/gcc/d/dmd/dimport.c +++ b/gcc/d/dmd/dimport.c @@ -35,7 +35,7 @@ Import::Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *alias this->id = id; this->aliasId = aliasId; this->isstatic = isstatic; - this->protection = Prot(PROTprivate); // default to private + this->protection = Prot(Prot::private_); // default to private this->pkg = NULL; this->mod = NULL; diff --git a/gcc/d/dmd/dmodule.c b/gcc/d/dmd/dmodule.c index f9f59a20224..102bcdc32b6 100644 --- a/gcc/d/dmd/dmodule.c +++ b/gcc/d/dmd/dmodule.c @@ -884,7 +884,7 @@ bool Module::isPackageAccessible(Package *p, Prot protection, int flags) if (insearch) // don't follow import cycles return false; if (flags & IgnorePrivateImports) - protection = Prot(PROTpublic); // only consider public imports + protection = Prot(Prot::public_); // only consider public imports insearch = true; bool r = ScopeDsymbol::isPackageAccessible(p, protection); insearch = false; diff --git a/gcc/d/dmd/doc.c b/gcc/d/dmd/doc.c index afe5c4bc00b..35ce2f6b7f8 100644 --- a/gcc/d/dmd/doc.c +++ b/gcc/d/dmd/doc.c @@ -732,7 +732,7 @@ void emitMemberComments(ScopeDsymbol *sds, OutBuffer *buf, Scope *sc) void emitProtection(OutBuffer *buf, Prot prot) { - if (prot.kind != PROTundefined && prot.kind != PROTpublic) + if (prot.kind != Prot::undefined && prot.kind != Prot::public_) { protectionToBuffer(buf, prot); buf->writeByte(' '); @@ -833,7 +833,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) return; if (!d->type && !d->isCtorDeclaration() && !d->isAliasDeclaration()) return; - if (d->protection.kind == PROTprivate || sc->protection.kind == PROTprivate) + if (d->protection.kind == Prot::private_ || sc->protection.kind == Prot::private_) return; } if (!com) @@ -855,7 +855,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) } else { - if (ad->prot().kind == PROTprivate || sc->protection.kind == PROTprivate) + if (ad->prot().kind == Prot::private_ || sc->protection.kind == Prot::private_) return; if (!ad->comment) return; @@ -869,7 +869,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) void visit(TemplateDeclaration *td) { //printf("TemplateDeclaration::emitComment() '%s', kind = %s\n", td->toChars(), td->kind()); - if (td->prot().kind == PROTprivate || sc->protection.kind == PROTprivate) + if (td->prot().kind == Prot::private_ || sc->protection.kind == Prot::private_) return; if (!td->comment) return; @@ -884,7 +884,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) void visit(EnumDeclaration *ed) { - if (ed->prot().kind == PROTprivate || sc->protection.kind == PROTprivate) + if (ed->prot().kind == Prot::private_ || sc->protection.kind == Prot::private_) return; if (ed->isAnonymous() && ed->members) { @@ -906,7 +906,7 @@ void emitComment(Dsymbol *s, OutBuffer *buf, Scope *sc) void visit(EnumMember *em) { //printf("EnumMember::emitComment(%p '%s'), comment = '%s'\n", em, em->toChars(), em->comment); - if (em->prot().kind == PROTprivate || sc->protection.kind == PROTprivate) + if (em->prot().kind == Prot::private_ || sc->protection.kind == Prot::private_) return; if (!em->comment) return; @@ -1233,7 +1233,7 @@ void toDocBuffer(Dsymbol *s, OutBuffer *buf, Scope *sc) buf->writestring(": "); any = 1; } - emitProtection(buf, Prot(PROTpublic)); + emitProtection(buf, Prot(Prot::public_)); if (bc->sym) { buf->printf("$(DDOC_PSUPER_SYMBOL %s)", bc->sym->toPrettyChars()); @@ -1486,7 +1486,7 @@ void DocComment::writeSections(Scope *sc, Dsymbols *a, OutBuffer *buf) for (UnitTestDeclaration *utd = s->ddocUnittest; utd; utd = utd->ddocUnittest) { - if (utd->protection.kind == PROTprivate || !utd->comment || !utd->fbody) + if (utd->protection.kind == Prot::private_ || !utd->comment || !utd->fbody) continue; // Strip whitespaces to avoid showing empty summary diff --git a/gcc/d/dmd/dscope.c b/gcc/d/dmd/dscope.c index d7460a07d7b..32aa965a932 100644 --- a/gcc/d/dmd/dscope.c +++ b/gcc/d/dmd/dscope.c @@ -81,7 +81,7 @@ Scope::Scope() this->linkage = LINKd; this->cppmangle = CPPMANGLEdefault; this->inlining = PINLINEdefault; - this->protection = Prot(PROTpublic); + this->protection = Prot(Prot::public_); this->explicitProtection = 0; this->stc = 0; this->depdecl = NULL; @@ -120,7 +120,7 @@ Scope *Scope::createGlobal(Module *_module) sc->aligndecl = NULL; sc->linkage = LINKd; sc->inlining = PINLINEdefault; - sc->protection = Prot(PROTpublic); + sc->protection = Prot(Prot::public_); sc->_module = _module; @@ -623,7 +623,7 @@ void *scope_search_fp(void *arg, const char *seed, int* cost) if (scopesym != s->parent) { (*cost)++; // got to the symbol through an import - if (s->prot().kind == PROTprivate) + if (s->prot().kind == Prot::private_) return NULL; } } diff --git a/gcc/d/dmd/dstruct.c b/gcc/d/dmd/dstruct.c index f5a99541a67..86bb6c8aa76 100644 --- a/gcc/d/dmd/dstruct.c +++ b/gcc/d/dmd/dstruct.c @@ -187,7 +187,7 @@ AggregateDeclaration::AggregateDeclaration(Loc loc, Identifier *id) this->loc = loc; storage_class = 0; - protection = Prot(PROTpublic); + protection = Prot(Prot::public_); type = NULL; structsize = 0; // size of struct alignsize = 0; // size of struct for alignment purposes @@ -228,7 +228,7 @@ Scope *AggregateDeclaration::newScope(Scope *sc) sc2->parent = this; if (isUnionDeclaration()) sc2->inunion = 1; - sc2->protection = Prot(PROTpublic); + sc2->protection = Prot(Prot::public_); sc2->explicitProtection = 0; sc2->aligndecl = NULL; sc2->userAttribDecl = NULL; @@ -543,7 +543,7 @@ bool AggregateDeclaration::isDeprecated() bool AggregateDeclaration::isExport() const { - return protection.kind == PROTexport; + return protection.kind == Prot::export_; } /*************************************** @@ -925,7 +925,7 @@ void AggregateDeclaration::makeNested() // Emulate vthis->semantic() vthis->storage_class |= STCfield; vthis->parent = this; - vthis->protection = Prot(PROTpublic); + vthis->protection = Prot(Prot::public_); vthis->alignment = t->alignment(); vthis->semanticRun = PASSsemanticdone; diff --git a/gcc/d/dmd/dsymbol.c b/gcc/d/dmd/dsymbol.c index f835192fe34..d74fe6cfdd5 100644 --- a/gcc/d/dmd/dsymbol.c +++ b/gcc/d/dmd/dsymbol.c @@ -867,7 +867,7 @@ Module *Dsymbol::getAccessModule() Prot Dsymbol::prot() { - return Prot(PROTpublic); + return Prot(Prot::public_); } /************************************* @@ -1100,7 +1100,7 @@ Dsymbol *ScopeDsymbol::search(const Loc &loc, Identifier *ident, int flags) for (size_t i = 0; i < importedScopes->length; i++) { // If private import, don't search it - if ((flags & IgnorePrivateImports) && prots[i] == PROTprivate) + if ((flags & IgnorePrivateImports) && prots[i] == Prot::private_) continue; int sflags = flags & (IgnoreErrors | IgnoreAmbiguous | IgnoreSymbolVisibility); // remember these in recursive searches @@ -1144,7 +1144,7 @@ Dsymbol *ScopeDsymbol::search(const Loc &loc, Identifier *ident, int flags) * the other. */ if (s->isDeprecated() || - (s->prot().isMoreRestrictiveThan(s2->prot()) && s2->prot().kind != PROTnone)) + (s->prot().isMoreRestrictiveThan(s2->prot()) && s2->prot().kind != Prot::none)) s = s2; } else @@ -1201,7 +1201,7 @@ Dsymbol *ScopeDsymbol::search(const Loc &loc, Identifier *ident, int flags) } // TODO: remove once private symbol visibility has been deprecated - if (!(flags & IgnoreErrors) && s->prot().kind == PROTprivate && + if (!(flags & IgnoreErrors) && s->prot().kind == Prot::private_ && !s->isOverloadable() && !s->parent->isTemplateMixin() && !s->parent->isNspace()) { AliasDeclaration *ad; @@ -1257,7 +1257,7 @@ OverloadSet *ScopeDsymbol::mergeOverloadSet(Identifier *ident, OverloadSet *os, { if (s2->isDeprecated() || (s2->prot().isMoreRestrictiveThan(s->prot()) && - s->prot().kind != PROTnone)) + s->prot().kind != Prot::none)) { os->a[j] = s; } @@ -1294,7 +1294,7 @@ void ScopeDsymbol::importScope(Dsymbol *s, Prot protection) } } importedScopes->push(s); - prots = (PROTKIND *)mem.xrealloc(prots, importedScopes->length * sizeof(prots[0])); + prots = (Prot::Kind *)mem.xrealloc(prots, importedScopes->length * sizeof(prots[0])); prots[importedScopes->length - 1] = protection.kind; } } @@ -1333,7 +1333,7 @@ static void bitArrayLength(BitArray *array, size_t len) void ScopeDsymbol::addAccessiblePackage(Package *p, Prot protection) { - BitArray *pary = protection.kind == PROTprivate ? &privateAccessiblePackages : &accessiblePackages; + BitArray *pary = protection.kind == Prot::private_ ? &privateAccessiblePackages : &accessiblePackages; if (pary->len <= p->tag) bitArrayLength(pary, p->tag + 1); bitArraySet(pary, p->tag); @@ -1342,7 +1342,7 @@ void ScopeDsymbol::addAccessiblePackage(Package *p, Prot protection) bool ScopeDsymbol::isPackageAccessible(Package *p, Prot protection, int) { if ((p->tag < accessiblePackages.len && bitArrayGet(&accessiblePackages, p->tag)) || - (protection.kind == PROTprivate && p->tag < privateAccessiblePackages.len && bitArrayGet(&privateAccessiblePackages, p->tag))) + (protection.kind == Prot::private_ && p->tag < privateAccessiblePackages.len && bitArrayGet(&privateAccessiblePackages, p->tag))) return true; if (importedScopes) { @@ -1827,11 +1827,11 @@ Dsymbol *DsymbolTable::update(Dsymbol *s) Prot::Prot() { - this->kind = PROTundefined; + this->kind = Prot::undefined; this->pkg = NULL; } -Prot::Prot(PROTKIND kind) +Prot::Prot(Prot::Kind kind) { this->kind = kind; this->pkg = NULL; @@ -1853,7 +1853,7 @@ bool Prot::operator==(const Prot& other) const { if (this->kind == other.kind) { - if (this->kind == PROTpackage) + if (this->kind == Prot::package_) return this->pkg == other.pkg; return true; } @@ -1875,7 +1875,7 @@ bool Prot::isSubsetOf(const Prot& parent) const if (this->kind != parent.kind) return false; - if (this->kind == PROTpackage) + if (this->kind == Prot::package_) { if (!this->pkg) return true; diff --git a/gcc/d/dmd/dsymbol.h b/gcc/d/dmd/dsymbol.h index 8db5cb6c0c8..63dbc2cccbc 100644 --- a/gcc/d/dmd/dsymbol.h +++ b/gcc/d/dmd/dsymbol.h @@ -83,24 +83,23 @@ struct Ungag ~Ungag() { global.gag = oldgag; } }; -enum PROTKIND -{ - PROTundefined, - PROTnone, // no access - PROTprivate, - PROTpackage, - PROTprotected, - PROTpublic, - PROTexport -}; - struct Prot { - PROTKIND kind; + enum Kind + { + undefined, + none, // no access + private_, + package_, + protected_, + public_, + export_ + }; + Kind kind; Package *pkg; Prot(); - Prot(PROTKIND kind); + Prot(Kind kind); bool isMoreRestrictiveThan(const Prot other) const; bool operator==(const Prot& other) const; @@ -109,7 +108,7 @@ struct Prot // in hdrgen.c void protectionToBuffer(OutBuffer *buf, Prot prot); -const char *protectionToChars(PROTKIND kind); +const char *protectionToChars(Prot::Kind kind); /* State of symbol in winding its way through the passes of the compiler */ @@ -296,7 +295,7 @@ public: private: Dsymbols *importedScopes; // imported Dsymbol's - PROTKIND *prots; // array of PROTKIND, one for each import + Prot::Kind *prots; // array of PROTKIND, one for each import BitArray accessiblePackages, privateAccessiblePackages; diff --git a/gcc/d/dmd/dtemplate.c b/gcc/d/dmd/dtemplate.c index 5ec9a4b609c..a35721cc9cd 100644 --- a/gcc/d/dmd/dtemplate.c +++ b/gcc/d/dmd/dtemplate.c @@ -535,7 +535,7 @@ TemplateDeclaration::TemplateDeclaration(Loc loc, Identifier *id, this->ismixin = ismixin; this->isstatic = true; this->previous = NULL; - this->protection = Prot(PROTundefined); + this->protection = Prot(Prot::undefined); this->instances = NULL; // Compute in advance for Ddoc's use @@ -6164,7 +6164,7 @@ Lerror: // Declare each template parameter as an alias for the argument type Scope *paramscope = scope->push(); paramscope->stc = 0; - paramscope->protection = Prot(PROTpublic); // Bugzilla 14169: template parameters should be public + paramscope->protection = Prot(Prot::public_); // Bugzilla 14169: template parameters should be public declareParameters(paramscope); paramscope->pop(); @@ -8408,7 +8408,7 @@ void TemplateMixin::semantic(Scope *sc) ScopeDsymbol *sds = (ScopeDsymbol *)sce->scopesym; if (sds) { - sds->importScope(this, Prot(PROTpublic)); + sds->importScope(this, Prot(Prot::public_)); break; } } diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c index 25f4bd51a59..412d416715b 100644 --- a/gcc/d/dmd/expressionsem.c +++ b/gcc/d/dmd/expressionsem.c @@ -1537,7 +1537,7 @@ public: sc = sc->push(); // just create new scope sc->flags &= ~SCOPEctfe; // temporary stop CTFE - sc->protection = Prot(PROTpublic); // Bugzilla 12506 + sc->protection = Prot(Prot::public_); // Bugzilla 12506 if (!exp->type || exp->type == Type::tvoid) { diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c index 276303a2851..008f09726b4 100644 --- a/gcc/d/dmd/func.c +++ b/gcc/d/dmd/func.c @@ -739,7 +739,7 @@ void FuncDeclaration::semantic(Scope *sc) const char *sfunc; if (isStatic()) sfunc = "static"; - else if (protection.kind == PROTprivate || protection.kind == PROTpackage) + else if (protection.kind == Prot::private_ || protection.kind == Prot::package_) sfunc = protectionToChars(protection.kind); else sfunc = "non-virtual"; @@ -748,8 +748,8 @@ void FuncDeclaration::semantic(Scope *sc) if (isOverride() && !isVirtual()) { - PROTKIND kind = prot().kind; - if ((kind == PROTprivate || kind == PROTpackage) && isMember()) + Prot::Kind kind = prot().kind; + if ((kind == Prot::private_ || kind == Prot::package_) && isMember()) error("%s method is not virtual and cannot override", protectionToChars(kind)); else error("cannot override a non-virtual function"); @@ -868,7 +868,7 @@ void FuncDeclaration::semantic(Scope *sc) if (f2) { f2 = f2->overloadExactMatch(type); - if (f2 && f2->isFinalFunc() && f2->prot().kind != PROTprivate) + if (f2 && f2->isFinalFunc() && f2->prot().kind != Prot::private_) error("cannot override final function %s", f2->toPrettyChars()); } } @@ -1137,7 +1137,7 @@ void FuncDeclaration::semantic(Scope *sc) if (f2) { f2 = f2->overloadExactMatch(type); - if (f2 && f2->isFinalFunc() && f2->prot().kind != PROTprivate) + if (f2 && f2->isFinalFunc() && f2->prot().kind != Prot::private_) error("cannot override final function %s.%s", b->sym->toChars(), f2->toPrettyChars()); } } @@ -1465,7 +1465,7 @@ void FuncDeclaration::semantic3(Scope *sc) STCdeprecated | STCoverride | STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref | STCreturn | STCproperty | STCnothrow | STCpure | STCsafe | STCtrusted | STCsystem); - sc2->protection = Prot(PROTpublic); + sc2->protection = Prot(Prot::public_); sc2->explicitProtection = 0; sc2->aligndecl = NULL; if (this->ident != Id::require && this->ident != Id::ensure) @@ -3755,14 +3755,14 @@ bool FuncDeclaration::isDllMain() bool FuncDeclaration::isExport() const { - return protection.kind == PROTexport; + return protection.kind == Prot::export_; } bool FuncDeclaration::isImportedSymbol() const { //printf("isImportedSymbol()\n"); //printf("protection = %d\n", protection); - return (protection.kind == PROTexport) && !fbody; + return (protection.kind == Prot::export_) && !fbody; } // Determine if function goes into virtual function pointer table @@ -3774,7 +3774,7 @@ bool FuncDeclaration::isVirtual() Dsymbol *p = toParent(); return isMember() && - !(isStatic() || protection.kind == PROTprivate || protection.kind == PROTpackage) && + !(isStatic() || protection.kind == Prot::private_ || protection.kind == Prot::package_) && p->isClassDeclaration() && !(p->isInterfaceDeclaration() && isFinalFunc()); } @@ -4136,7 +4136,7 @@ bool FuncDeclaration::addPreInvariant() ClassDeclaration *cd = ad ? ad->isClassDeclaration() : NULL; return (ad && !(cd && cd->isCPPclass()) && global.params.useInvariants == CHECKENABLEon && - (protection.kind == PROTprotected || protection.kind == PROTpublic || protection.kind == PROTexport) && + (protection.kind == Prot::protected_ || protection.kind == Prot::public_ || protection.kind == Prot::export_) && !naked); } @@ -4147,7 +4147,7 @@ bool FuncDeclaration::addPostInvariant() return (ad && !(cd && cd->isCPPclass()) && ad->inv && global.params.useInvariants == CHECKENABLEon && - (protection.kind == PROTprotected || protection.kind == PROTpublic || protection.kind == PROTexport) && + (protection.kind == Prot::protected_ || protection.kind == Prot::public_ || protection.kind == Prot::export_) && !naked); } @@ -4254,7 +4254,7 @@ FuncDeclaration *FuncDeclaration::genCfunc(Parameters *fparams, Type *treturn, I { tf = new TypeFunction(ParameterList(fparams), treturn, LINKc, stc); fd = new FuncDeclaration(Loc(), Loc(), id, STCstatic, tf); - fd->protection = Prot(PROTpublic); + fd->protection = Prot(Prot::public_); fd->linkage = LINKc; st->insert(fd); diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c index 2c88ef597c6..11a06a88ce9 100644 --- a/gcc/d/dmd/hdrgen.c +++ b/gcc/d/dmd/hdrgen.c @@ -3381,7 +3381,7 @@ void protectionToBuffer(OutBuffer *buf, Prot prot) if (p) buf->writestring(p); - if (prot.kind == PROTpackage && prot.pkg) + if (prot.kind == Prot::package_ && prot.pkg) { buf->writeByte('('); buf->writestring(prot.pkg->toPrettyChars(true)); @@ -3389,17 +3389,17 @@ void protectionToBuffer(OutBuffer *buf, Prot prot) } } -const char *protectionToChars(PROTKIND kind) +const char *protectionToChars(Prot::Kind kind) { switch (kind) { - case PROTundefined: return NULL; - case PROTnone: return "none"; - case PROTprivate: return "private"; - case PROTpackage: return "package"; - case PROTprotected: return "protected"; - case PROTpublic: return "public"; - case PROTexport: return "export"; + case Prot::undefined: return NULL; + case Prot::none: return "none"; + case Prot::private_: return "private"; + case Prot::package_: return "package"; + case Prot::protected_: return "protected"; + case Prot::public_: return "public"; + case Prot::export_: return "export"; default: assert(0); } return NULL; // never reached diff --git a/gcc/d/dmd/json.c b/gcc/d/dmd/json.c index 0c3b7b617b8..b1b90d67334 100644 --- a/gcc/d/dmd/json.c +++ b/gcc/d/dmd/json.c @@ -438,7 +438,7 @@ public: property("kind", s->kind()); } - if (s->prot().kind != PROTpublic) // TODO: How about package(names)? + if (s->prot().kind != Prot::public_) // TODO: How about package(names)? property("protection", protectionToChars(s->prot().kind)); if (EnumMember *em = s->isEnumMember()) @@ -546,7 +546,7 @@ public: property("kind", s->kind()); property("comment", (const char *)s->comment); property("line", "char", &s->loc); - if (s->prot().kind != PROTpublic) + if (s->prot().kind != Prot::public_) property("protection", protectionToChars(s->prot().kind)); if (s->aliasId) property("alias", s->aliasId->toChars()); diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c index 30fd54da185..7684516da99 100644 --- a/gcc/d/dmd/mtype.c +++ b/gcc/d/dmd/mtype.c @@ -5521,7 +5521,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) */ Scope *argsc = sc->push(); argsc->stc = 0; // don't inherit storage class - argsc->protection = Prot(PROTpublic); + argsc->protection = Prot(Prot::public_); argsc->func = NULL; size_t dim = tf->parameterList.length(); diff --git a/gcc/d/dmd/nspace.c b/gcc/d/dmd/nspace.c index bee30e98250..71d1c6f5552 100644 --- a/gcc/d/dmd/nspace.c +++ b/gcc/d/dmd/nspace.c @@ -50,7 +50,7 @@ void Nspace::addMember(Scope *sc, ScopeDsymbol *sds) ScopeDsymbol *sds2 = sce->scopesym; if (sds2) { - sds2->importScope(this, Prot(PROTpublic)); + sds2->importScope(this, Prot(Prot::public_)); break; } } diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c index 38da5808484..79acab731a6 100644 --- a/gcc/d/dmd/parse.c +++ b/gcc/d/dmd/parse.c @@ -231,7 +231,7 @@ struct PrefixAttributes : storageClass(STCundefined), depmsg(NULL), link(LINKdefault), - protection(PROTundefined), + protection(Prot::undefined), setAlignment(false), ealign(NULL), udas(NULL), @@ -262,7 +262,7 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes pAttrs = &attrs; pAttrs->comment = token.blockComment; } - PROTKIND prot; + Prot::Kind prot; StorageClass stc; Condition *condition; @@ -731,14 +731,14 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes break; } - case TOKprivate: prot = PROTprivate; goto Lprot; - case TOKpackage: prot = PROTpackage; goto Lprot; - case TOKprotected: prot = PROTprotected; goto Lprot; - case TOKpublic: prot = PROTpublic; goto Lprot; - case TOKexport: prot = PROTexport; goto Lprot; + case TOKprivate: prot = Prot::private_; goto Lprot; + case TOKpackage: prot = Prot::package_; goto Lprot; + case TOKprotected: prot = Prot::protected_; goto Lprot; + case TOKpublic: prot = Prot::public_; goto Lprot; + case TOKexport: prot = Prot::export_; goto Lprot; Lprot: { - if (pAttrs->protection.kind != PROTundefined) + if (pAttrs->protection.kind != Prot::undefined) { if (pAttrs->protection.kind != prot) error("conflicting protection attribute '%s' and '%s'", @@ -753,7 +753,7 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes // optional qualified package identifier to bind // protection to Identifiers *pkg_prot_idents = NULL; - if (pAttrs->protection.kind == PROTpackage && token.value == TOKlparen) + if (pAttrs->protection.kind == Prot::package_ && token.value == TOKlparen) { pkg_prot_idents = parseQualifiedIdentifier("protection package"); @@ -770,14 +770,14 @@ Dsymbols *Parser::parseDeclDefs(int once, Dsymbol **pLastDecl, PrefixAttributes Loc attrloc = token.loc; a = parseBlock(pLastDecl, pAttrs); - if (pAttrs->protection.kind != PROTundefined) + if (pAttrs->protection.kind != Prot::undefined) { - if (pAttrs->protection.kind == PROTpackage && pkg_prot_idents) + if (pAttrs->protection.kind == Prot::package_ && pkg_prot_idents) s = new ProtDeclaration(attrloc, pkg_prot_idents, a); else s = new ProtDeclaration(attrloc, pAttrs->protection, a); - pAttrs->protection = Prot(PROTundefined); + pAttrs->protection = Prot(Prot::undefined); } break; } @@ -2365,27 +2365,27 @@ BaseClasses *Parser::parseBaseClasses() for (; 1; nextToken()) { bool prot = false; - Prot protection = Prot(PROTpublic); + Prot protection = Prot(Prot::public_); switch (token.value) { case TOKprivate: prot = true; - protection = Prot(PROTprivate); + protection = Prot(Prot::private_); nextToken(); break; case TOKpackage: prot = true; - protection = Prot(PROTpackage); + protection = Prot(Prot::package_); nextToken(); break; case TOKprotected: prot = true; - protection = Prot(PROTprotected); + protection = Prot(Prot::protected_); nextToken(); break; case TOKpublic: prot = true; - protection = Prot(PROTpublic); + protection = Prot(Prot::public_); nextToken(); break; default: break; diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc index 0ff41630f05..79f42c68b10 100644 --- a/gcc/d/modules.cc +++ b/gcc/d/modules.cc @@ -147,7 +147,7 @@ get_internal_fn (tree ident) Identifier::idPool (name)); fd->loc = Loc (mod->srcfile->toChars (), 1, 0); fd->parent = mod; - fd->protection.kind = PROTprivate; + fd->protection.kind = Prot::private_; fd->semanticRun = PASSsemantic3done; return fd;