diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-01-07 22:00:24 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-01-09 23:45:46 +0100 |
commit | 7a103daef78a8f9fc9b2af7c28123f25e8fa7163 (patch) | |
tree | 39e4a1d02b2f424b4d77c4e0b0cdff875467e41d /gcc/d/dmd/declaration.c | |
parent | acae7b21bc026150c2c01465e4ab0eacb20bd44d (diff) | |
download | gcc-7a103daef78a8f9fc9b2af7c28123f25e8fa7163.zip gcc-7a103daef78a8f9fc9b2af7c28123f25e8fa7163.tar.gz gcc-7a103daef78a8f9fc9b2af7c28123f25e8fa7163.tar.bz2 |
d: Support deprecated, @disable, and user-defined attributes on enum members
Reviewed-on: https://github.com/dlang/dmd/pull/12108
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 9bba772fa.
Diffstat (limited to 'gcc/d/dmd/declaration.c')
-rw-r--r-- | gcc/d/dmd/declaration.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c index f196bc8..72a07d9b8 100644 --- a/gcc/d/dmd/declaration.c +++ b/gcc/d/dmd/declaration.c @@ -155,6 +155,51 @@ int Declaration::checkModify(Loc loc, Scope *sc, Type *, Expression *e1, int fla return 1; } +/** + * Issue an error if an attempt to call a disabled method is made + * + * If the declaration is disabled but inside a disabled function, + * returns `true` but do not issue an error message. + * + * Params: + * loc = Location information of the call + * sc = Scope in which the call occurs + * isAliasedDeclaration = if `true` searches overload set + * + * Returns: + * `true` if this `Declaration` is `@disable`d, `false` otherwise. + */ +bool Declaration::checkDisabled(Loc loc, Scope *sc, bool isAliasedDeclaration) +{ + if (!(storage_class & STCdisable)) + return false; + + if (sc->func && (sc->func->storage_class & STCdisable)) + return true; + + Dsymbol *p = toParent(); + if (p && isPostBlitDeclaration()) + { + p->error(loc, "is not copyable because it is annotated with `@disable`"); + return true; + } + + // if the function is @disabled, maybe there + // is an overload in the overload set that isn't + if (isAliasedDeclaration) + { + FuncDeclaration *fd = isFuncDeclaration(); + if (fd) + { + for (FuncDeclaration *ovl = fd; ovl; ovl = (FuncDeclaration *)ovl->overnext) + if (!(ovl->storage_class & STCdisable)) + return false; + } + } + error(loc, "cannot be used because it is annotated with `@disable`"); + return true; +} + Dsymbol *Declaration::search(const Loc &loc, Identifier *ident, int flags) { Dsymbol *s = Dsymbol::search(loc, ident, flags); |