From: Iain Buclaw Date: Fri, 14 Mar 2025 00:36:45 +0000 (+0100) Subject: d: Merge upstream dmd, druntime 53a1cc8d13 X-Git-Tag: basepoints/gcc-16~1476 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26c4ea2ebcdcd0aa26350d04dc4cd38348148bd9;p=thirdparty%2Fgcc.git d: Merge upstream dmd, druntime 53a1cc8d13 D front-end changes: - Typesafe variadic class parameters have been deprecated. D runtime changes: - Added `entry' field to TypeInfo_AssociativeArray. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 53a1cc8d13. * d-tree.h (create_typeinfo): Change second parameter to Scope *. (speculative_type_p): Remove prototype. * d-frontend.cc (getTypeInfoType): Adjust. * decl.cc: Include dmd/typinf.h. (DeclVisitor::visit (TypeInfoDeclaration *)): Update for new front-end interface. * typeinfo.cc (create_typeinfo): Likewise. (class SpeculativeTypeVisitor): Remove class. (speculative_type_p): Remove function. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 53a1cc8d13. gcc/testsuite/ChangeLog: * gdc.dg/pr100967.d: Adjust error message. --- diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc index 0927a3d21c4..3778cc6e593 100644 --- a/gcc/d/d-frontend.cc +++ b/gcc/d/d-frontend.cc @@ -83,7 +83,7 @@ getTypeInfoType (Loc loc, Type *type, Scope *sc) { gcc_assert (type->ty != TY::Terror); check_typeinfo_type (loc, sc); - create_typeinfo (type, sc ? sc->_module->importedFrom : NULL); + create_typeinfo (type, sc); return type->vtinfo->type; } diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h index b3e84d1baef..42d01e45595 100644 --- a/gcc/d/d-tree.h +++ b/gcc/d/d-tree.h @@ -704,11 +704,10 @@ extern tree get_classinfo_decl (ClassDeclaration *); extern void check_typeinfo_type (const Loc &, Scope *, Expression * = NULL); extern tree build_typeinfo (const Loc &, Type *, Expression * = NULL); extern tree build_typeinfo (Expression *, Type *); -extern void create_typeinfo (Type *, Module *); +extern void create_typeinfo (Type *, Scope *); extern void create_tinfo_types (Module *); extern void layout_cpp_typeinfo (ClassDeclaration *); extern tree get_cpp_typeinfo_decl (ClassDeclaration *); -extern bool speculative_type_p (Type *); /* In toir.cc. */ extern void push_binding_level (level_kind); diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 913a9b37690..c05c30397b8 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "dmd/nspace.h" #include "dmd/target.h" #include "dmd/template.h" +#include "dmd/typinf.h" #include "tree.h" #include "tree-iterator.h" @@ -899,7 +900,7 @@ public: if (d->semanticRun >= PASS::obj) return; - if (speculative_type_p (d->tinfo)) + if (dmd::isSpeculativeType (d->tinfo)) return; tree t = get_typeinfo_decl (d); diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 59d5a184810..66cfdd6ad4a 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -ffbad272b649b7ae3e88cfdc85688bfef3168994 +53a1cc8d13e8db2cb1642219320a8dfc1b0cc6c5 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/attrib.d b/gcc/d/dmd/attrib.d index f5618f13733..df04ed1756d 100644 --- a/gcc/d/dmd/attrib.d +++ b/gcc/d/dmd/attrib.d @@ -32,7 +32,7 @@ import dmd.declaration; import dmd.dmodule; import dmd.dscope; import dmd.dsymbol; -import dmd.dsymbolsem : setScope, addMember, include; +import dmd.dsymbolsem : include; import dmd.expression; import dmd.func; import dmd.globals; @@ -125,11 +125,6 @@ extern (C++) abstract class AttribDeclaration : Dsymbol return this.include(null).foreachDsymbol( (s) { return s.hasStaticCtorOrDtor(); } ) != 0; } - override final void checkCtorConstInit() - { - this.include(null).foreachDsymbol( s => s.checkCtorConstInit() ); - } - /**************************************** */ override final void addObjcSymbols(ClassDeclarations* classes, ClassDeclarations* categories) diff --git a/gcc/d/dmd/attrib.h b/gcc/d/dmd/attrib.h index 79b0cb02c1e..ab5f219db88 100644 --- a/gcc/d/dmd/attrib.h +++ b/gcc/d/dmd/attrib.h @@ -32,7 +32,6 @@ public: bool oneMember(Dsymbol *&ps, Identifier *ident) override; bool hasPointers() override final; bool hasStaticCtorOrDtor() override final; - void checkCtorConstInit() override final; AttribDeclaration *isAttribDeclaration() override { return this; } void accept(Visitor *v) override { v->visit(this); } diff --git a/gcc/d/dmd/common/charactertables.d b/gcc/d/dmd/common/charactertables.d index ac89807ddea..6a3b302c1eb 100644 --- a/gcc/d/dmd/common/charactertables.d +++ b/gcc/d/dmd/common/charactertables.d @@ -42,7 +42,8 @@ struct IdentifierCharLookup // Awful solution to require these lambdas. // However without them the extern(C++) ABI issues crop up for isInRange, // and then it can't access the tables. - final switch(table) { + final switch(table) + { case IdentifierTable.UAX31: return IdentifierCharLookup( (c) => isInRange!UAX31_Start(c), diff --git a/gcc/d/dmd/cparse.d b/gcc/d/dmd/cparse.d index 548bee992e1..9f1eab7fc6c 100644 --- a/gcc/d/dmd/cparse.d +++ b/gcc/d/dmd/cparse.d @@ -2006,7 +2006,7 @@ final class CParser(AST) : Parser!AST //printf("AliasDeclaration %s %s\n", id.toChars(), dt.toChars()); auto ad = new AST.AliasDeclaration(token.loc, id, dt); if (id == idt) - ad.adFlags |= ad.hidden; // do not print when generating .di files + ad.hidden = true; // do not print when generating .di files s = ad; } @@ -2088,8 +2088,7 @@ final class CParser(AST) : Parser!AST { auto str = asmName.peekString(); p.mangleOverride = str; -// p.adFlags |= AST.VarDeclaration.nounderscore; - p.adFlags |= 4; // cannot get above line to compile on Ubuntu + p.noUnderscore = true; } } s = applySpecifier(s, specifier); @@ -5527,6 +5526,12 @@ final class CParser(AST) : Parser!AST if (pt && *pt) t = *pt; } + if (t.mcache && t.mcache.typedefIdent) + { + t = t.copy(); + t.mcache = null; + } + t.getMcache().typedefIdent = id; auto tab = cast(void*[void*])(typedefTab[$ - 1]); tab[cast(void*)id] = cast(void*)t; typedefTab[$ - 1] = cast(void*)tab; diff --git a/gcc/d/dmd/cxxfrontend.d b/gcc/d/dmd/cxxfrontend.d index dfc76ff9525..3cd4ced6b49 100644 --- a/gcc/d/dmd/cxxfrontend.d +++ b/gcc/d/dmd/cxxfrontend.d @@ -15,6 +15,7 @@ import dmd.arraytypes; import dmd.astenums; import dmd.attrib; import dmd.common.outbuffer : OutBuffer; +import dmd.declaration : TypeInfoDeclaration; import dmd.denum : EnumDeclaration; import dmd.dmodule /*: Module*/; import dmd.dscope : Scope; @@ -702,6 +703,18 @@ bool builtinTypeInfo(Type t) return dmd.typinf.builtinTypeInfo(t); } +Type makeNakedAssociativeArray(TypeAArray t) +{ + import dmd.typinf; + return dmd.typinf.makeNakedAssociativeArray(t); +} + +TypeInfoDeclaration getTypeInfoAssocArrayDeclaration(TypeAArray t, Scope* sc) +{ + import dmd.typinf; + return dmd.typinf.getTypeInfoAssocArrayDeclaration(t, sc); +} + version (IN_LLVM) { /*********************************************************** diff --git a/gcc/d/dmd/dcast.d b/gcc/d/dmd/dcast.d index f42a061517c..172c8278f7f 100644 --- a/gcc/d/dmd/dcast.d +++ b/gcc/d/dmd/dcast.d @@ -150,7 +150,7 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t) //printf("type %s t %s\n", type.deco, t.deco); auto ts = toAutoQualChars(e.type, t); error(e.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", - e.toChars(), ts[0], ts[1]); + e.toErrMsg(), ts[0], ts[1]); } } return ErrorExp.get(); @@ -2832,6 +2832,7 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null) (*ae.keys)[i] = ex; } ae.type = t; + semanticTypeInfo(sc, ae.type); return ae; } return visit(e); diff --git a/gcc/d/dmd/declaration.d b/gcc/d/dmd/declaration.d index 26887f897ed..30f017d8952 100644 --- a/gcc/d/dmd/declaration.d +++ b/gcc/d/dmd/declaration.d @@ -54,6 +54,7 @@ else version = MARS; */ void ObjectNotFound(Loc loc, Identifier id) { + global.gag = 0; // never gag the fatal error error(loc, "`%s` not found. object.d may be incorrectly installed or corrupt.", id.toChars()); version (IN_LLVM) { @@ -87,19 +88,23 @@ extern (C++) abstract class Declaration : Dsymbol Type type; Type originalType; // before semantic analysis StorageClass storage_class = STC.undefined_; + // overridden symbol with pragma(mangle, "...") + const(char)[] mangleOverride; Visibility visibility; - LINK _linkage = LINK.default_; // may be `LINK.system`; use `resolvedLinkage()` to resolve it short inuse; // used to detect cycles - ubyte adFlags; // control re-assignment of AliasDeclaration (put here for packing reasons) - enum wasRead = 1; // set if AliasDeclaration was read - enum ignoreRead = 2; // ignore any reads of AliasDeclaration - enum nounderscore = 4; // don't prepend _ to mangled name - enum hidden = 8; // don't print this in .di files - enum nrvo = 0x10; /// forward to fd.nrvo_var when generating code + private extern (D) static struct BitFields + { + LINK _linkage = LINK.default_; // may be `LINK.system`; use `resolvedLinkage()` to resolve it + bool wasRead; // set if AliasDeclaration was read + bool ignoreRead; // ignore any reads of AliasDeclaration + bool noUnderscore; // don't prepend _ to mangled name + bool hidden; // don't print this in .di files + bool nrvo; /// forward to fd.nrvo_var when generating code + } - // overridden symbol with pragma(mangle, "...") - const(char)[] mangleOverride; + import dmd.common.bitfields; + mixin(generateBitFields!(BitFields, ubyte)); final extern (D) this(Identifier ident) @safe { @@ -628,8 +633,8 @@ extern (C++) final class AliasDeclaration : Declaration return aliassym; } // Reading the AliasDeclaration - if (!(adFlags & ignoreRead)) - adFlags |= wasRead; // can never assign to this AliasDeclaration again + if (!this.ignoreRead) + this.wasRead = true; // can never assign to this AliasDeclaration again if (inuse == 1 && type && _scope) { @@ -1124,16 +1129,6 @@ extern (C++) class VarDeclaration : Declaration return e; } - override final void checkCtorConstInit() - { - version (none) - { - /* doesn't work if more than one static ctor */ - if (ctorinit == 0 && isCtorinit() && !isField()) - error("missing initializer in static constructor for const variable"); - } - } - /************************************ * Check to see if this variable is actually in an enclosing function * rather than the current one. @@ -1544,6 +1539,8 @@ extern (C++) final class TypeInfoStaticArrayDeclaration : TypeInfoDeclaration */ extern (C++) final class TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration { + Type entry; // type of TypeInfo_AssociativeArray.Entry!(t.index, t.next) + extern (D) this(Type tinfo) { super(tinfo); diff --git a/gcc/d/dmd/declaration.h b/gcc/d/dmd/declaration.h index 4fd35ee76c8..6fef6a5b3a4 100644 --- a/gcc/d/dmd/declaration.h +++ b/gcc/d/dmd/declaration.h @@ -121,11 +121,10 @@ public: Type *type; Type *originalType; // before semantic analysis StorageClass storage_class; + DString mangleOverride; // overridden symbol with pragma(mangle, "...") Visibility visibility; - LINK _linkage; // may be `LINK::system`; use `resolvedLinkage()` to resolve it short inuse; // used to detect cycles - uint8_t adFlags; - DString mangleOverride; // overridden symbol with pragma(mangle, "...") + uint8_t bitFields; const char *kind() const override; uinteger_t size(Loc loc) override final; @@ -299,7 +298,6 @@ public: bool hasPointers() override final; bool canTakeAddressOf(); bool needsScopeDtor(); - void checkCtorConstInit() override final; Dsymbol *toAlias() override final; // Eliminate need for dynamic_cast VarDeclaration *isVarDeclaration() override final { return (VarDeclaration *)this; } @@ -398,6 +396,8 @@ public: class TypeInfoAssociativeArrayDeclaration final : public TypeInfoDeclaration { public: + Type* entry; + static TypeInfoAssociativeArrayDeclaration *create(Type *tinfo); void accept(Visitor *v) override { v->visit(this); } diff --git a/gcc/d/dmd/dinterpret.d b/gcc/d/dmd/dinterpret.d index 5dbab0918c0..3a08c10daf5 100644 --- a/gcc/d/dmd/dinterpret.d +++ b/gcc/d/dmd/dinterpret.d @@ -1989,13 +1989,15 @@ public: Declaration decl = ve.var; // We cannot take the address of an imported symbol at compile time - if (decl.isImportedSymbol()) { + if (decl.isImportedSymbol()) + { error(e.loc, "cannot take address of imported symbol `%s` at compile time", decl.toChars()); result = CTFEExp.cantexp; return; } - if (decl.isDataseg()) { + if (decl.isDataseg()) + { // Normally this is already done by optimize() // Do it here in case optimize(WANTvalue) wasn't run before CTFE emplaceExp!(SymOffExp)(pue, e.loc, e.e1.isVarExp().var, 0); diff --git a/gcc/d/dmd/doc.d b/gcc/d/dmd/doc.d index 0e77cdfc982..261fa387e0a 100644 --- a/gcc/d/dmd/doc.d +++ b/gcc/d/dmd/doc.d @@ -2061,9 +2061,9 @@ string toLowercase(string s) pure @safe // TODO: maybe unicode lowercase, somehow if (c >= 'A' && c <= 'Z') { - if (!lower.length) { + if (!lower.length) lower.reserve(s.length); - } + lower ~= s[lower.length..i]; c += 'a' - 'A'; lower ~= c; diff --git a/gcc/d/dmd/dsymbol.d b/gcc/d/dmd/dsymbol.d index bad9ca2080f..64cf6be84ee 100644 --- a/gcc/d/dmd/dsymbol.d +++ b/gcc/d/dmd/dsymbol.d @@ -916,10 +916,6 @@ extern (C++) class Dsymbol : ASTNode { } - void checkCtorConstInit() - { - } - /**************************************** * Add documentation comment to Dsymbol. * Ignore NULL comments. diff --git a/gcc/d/dmd/dsymbol.h b/gcc/d/dmd/dsymbol.h index 6d223bf1e68..8209dea02ee 100644 --- a/gcc/d/dmd/dsymbol.h +++ b/gcc/d/dmd/dsymbol.h @@ -241,7 +241,6 @@ public: virtual bool hasPointers(); virtual bool hasStaticCtorOrDtor(); virtual void addObjcSymbols(ClassDeclarations *, ClassDeclarations *) { } - virtual void checkCtorConstInit() { } virtual void addComment(const utf8_t *comment); const utf8_t *comment(); // current value of comment diff --git a/gcc/d/dmd/dsymbolsem.d b/gcc/d/dmd/dsymbolsem.d index 3e7f9b92671..b01736677cb 100644 --- a/gcc/d/dmd/dsymbolsem.d +++ b/gcc/d/dmd/dsymbolsem.d @@ -1896,8 +1896,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor const sident = se.toStringz(); if (!sident.length || !Identifier.isValidIdentifier(sident)) { - error(ns.exp.loc, "expected valid identifier for C++ namespace but got `%.*s`", - cast(int)sident.length, sident.ptr); + error(ns.exp.loc, "expected valid identifier for C++ namespace but got `%s`", se.toErrMsg()); return null; } else @@ -5343,7 +5342,8 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc) { s = tident.toDsymbol(sc); // don't error for `var1.static_symbol` - if (s && s.needThis()) { + if (s && s.needThis()) + { error(ds.loc, "cannot alias %s member `%s` of variable `%s`", s.kind(), s.toChars(), mt.ident.toChars()); errorSupplemental(ds.loc, "Use `typeof(%s)` instead to preserve behaviour", @@ -5500,7 +5500,7 @@ private void aliasAssignSemantic(AliasAssign ds, Scope* sc) if (!aliassym) return errorRet(); - if (aliassym.adFlags & Declaration.wasRead) + if (aliassym.wasRead) { if (!aliassym.errors) error(ds.loc, "%s was read, so cannot reassign", aliassym.toChars()); @@ -5508,7 +5508,7 @@ private void aliasAssignSemantic(AliasAssign ds, Scope* sc) return errorRet(); } - aliassym.adFlags |= Declaration.ignoreRead; // temporarilly allow reads of aliassym + aliassym.ignoreRead = true; // temporarilly allow reads of aliassym const storage_class = sc.stc & (STC.deprecated_ | STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.shared_ | STC.disable); @@ -5632,8 +5632,7 @@ private void aliasAssignSemantic(AliasAssign ds, Scope* sc) aliassym.aliassym = null; } - - aliassym.adFlags &= ~Declaration.ignoreRead; + aliassym.ignoreRead = false; if (aliassym.type && aliassym.type.ty == Terror || global.gag && errors != global.errors) @@ -7940,3 +7939,31 @@ extern (C++) class AddCommentVisitor: Visitor } override void visit(StaticForeachDeclaration sfd) {} } + +void checkCtorConstInit(Dsymbol d) +{ + scope v = new CheckCtorConstInitVisitor(); + d.accept(v); +} + +private extern(C++) class CheckCtorConstInitVisitor : Visitor +{ + alias visit = Visitor.visit; + + override void visit(AttribDeclaration ad) + { + ad.include(null).foreachDsymbol( s => s.checkCtorConstInit() ); + } + + override void visit(VarDeclaration vd) + { + version (none) + { + /* doesn't work if more than one static ctor */ + if (vd.ctorinit == 0 && vd.isCtorinit() && !vd.isField()) + error("missing initializer in static constructor for const variable"); + } + } + + override void visit(Dsymbol d){} +} diff --git a/gcc/d/dmd/dtemplate.d b/gcc/d/dmd/dtemplate.d index 1aab94d7c1f..c19d4b942f2 100644 --- a/gcc/d/dmd/dtemplate.d +++ b/gcc/d/dmd/dtemplate.d @@ -136,6 +136,13 @@ inout(Parameter) isParameter(inout RootObject o) return cast(inout(Parameter))o; } +inout(Identifier) isIdentifier(inout RootObject o) +{ + if (!o || o.dyncast() != DYNCAST.identifier) + return null; + return cast(inout(Identifier))o; +} + inout(TemplateParameter) isTemplateParameter(inout RootObject o) { if (!o || o.dyncast() != DYNCAST.templateparameter) @@ -3884,7 +3891,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol if (n_instantiations <= max_shown) { for (TemplateInstance cur = this; cur; cur = cur.tinst) - printFn(cur.loc, format, cur.toChars()); + printFn(cur.loc, format, cur.toErrMsg()); } else if (n_instantiations - n_totalrecursions <= max_shown) { @@ -6265,6 +6272,9 @@ void write(ref OutBuffer buf, RootObject obj) { if (obj) { - buf.writestring(obj.toChars()); + if (auto e = isExpression(obj)) + buf.writestring(e.toErrMsg()); + else + buf.writestring(obj.toChars()); } } diff --git a/gcc/d/dmd/dtoh.d b/gcc/d/dmd/dtoh.d index efd0a2f53e2..a586f874902 100644 --- a/gcc/d/dmd/dtoh.d +++ b/gcc/d/dmd/dtoh.d @@ -976,7 +976,8 @@ public: { EnumKind kind = getEnumKind(type); - if (vd.visibility.kind == AST.Visibility.Kind.none || vd.visibility.kind == AST.Visibility.Kind.private_) { + if (vd.visibility.kind == AST.Visibility.Kind.none || vd.visibility.kind == AST.Visibility.Kind.private_) + { ignored("enum `%s` because it is `%s`.", vd.toPrettyChars(), AST.visibilityToChars(vd.visibility.kind)); return; } diff --git a/gcc/d/dmd/expression.d b/gcc/d/dmd/expression.d index 68276127e25..388023f53c6 100644 --- a/gcc/d/dmd/expression.d +++ b/gcc/d/dmd/expression.d @@ -383,8 +383,7 @@ extern (C++) abstract class Expression : ASTNode final override const(char)* toChars() const { - // FIXME: Test suite relies on lambda's being printed as __lambdaXXX in errors and .stringof - // Printing a (truncated) lambda body is more user friendly + // FIXME: mangling (see runnable/mangle.d) relies on toChars outputting __lambdaXXX here if (auto fe = isFuncExp()) return fe.fd.toChars(); diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d index 7a35328b855..22fbfc29969 100644 --- a/gcc/d/dmd/expressionsem.d +++ b/gcc/d/dmd/expressionsem.d @@ -362,11 +362,11 @@ private Expression incompatibleTypes(UnaExp e) if (e.e1.op == EXP.type) { - error(e.loc, "incompatible type for `%s(%s)`: cannot use `%s` with types", EXPtoString(e.op).ptr, e.e1.toChars(), EXPtoString(e.op).ptr); + error(e.loc, "incompatible type for `%s(%s)`: cannot use `%s` with types", EXPtoString(e.op).ptr, e.e1.toErrMsg(), EXPtoString(e.op).ptr); } else { - error(e.loc, "incompatible type for `%s(%s)`: `%s`", EXPtoString(e.op).ptr, e.e1.toChars(), e.e1.type.toChars()); + error(e.loc, "incompatible type for `%s(%s)`: `%s`", EXPtoString(e.op).ptr, e.e1.toErrMsg(), e.e1.type.toChars()); } return ErrorExp.get(); } @@ -393,18 +393,18 @@ extern (D) Expression incompatibleTypes(BinExp e, Scope* sc = null) if (e.e1.op == EXP.type || e.e2.op == EXP.type) { error(e.loc, "incompatible types for `(%s) %s (%s)`: cannot use `%s` with types", - e.e1.toChars(), thisOp, e.e2.toChars(), EXPtoString(e.op).ptr); + e.e1.toErrMsg(), thisOp, e.e2.toErrMsg(), EXPtoString(e.op).ptr); } else if (e.e1.type.equals(e.e2.type)) { error(e.loc, "incompatible types for `(%s) %s (%s)`: both operands are of type `%s`", - e.e1.toChars(), thisOp, e.e2.toChars(), e.e1.type.toChars()); + e.e1.toErrMsg(), thisOp, e.e2.toErrMsg(), e.e1.type.toChars()); } else { auto ts = toAutoQualChars(e.e1.type, e.e2.type); error(e.loc, "incompatible types for `(%s) %s (%s)`: `%s` and `%s`", - e.e1.toChars(), thisOp, e.e2.toChars(), ts[0], ts[1]); + e.e1.toErrMsg(), thisOp, e.e2.toErrMsg(), ts[0], ts[1]); } return ErrorExp.get(); } @@ -731,7 +731,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, out Expression pe0) if (!e.type) { - error(ae.loc, "`%s` has no value", e.toChars()); + error(ae.loc, "`%s` has no value", e.toErrMsg()); e = ErrorExp.get(); } if (e.op == EXP.error) @@ -768,7 +768,7 @@ Expression resolveOpDollar(Scope* sc, ArrayExp ae, IntervalExp ie, ref Expressio e = resolveProperties(sc, e); if (!e.type) { - error(ae.loc, "`%s` has no value", e.toChars()); + error(ae.loc, "`%s` has no value", e.toErrMsg()); errors = true; } return e; @@ -853,7 +853,7 @@ extern (D) Expression doCopyOrMove(Scope* sc, Expression e, Type t, bool nrvo, b */ VarDeclaration vd = new VarDeclaration(e.loc, e.type, Identifier.generateId("__copyrvalue"), null); if (nrvo) - vd.adFlags |= Declaration.nrvo; + vd.nrvo = true; vd.storage_class |= STC.nodtor; vd.dsymbolSemantic(sc); Expression de = new DeclarationExp(e.loc, vd); @@ -903,7 +903,7 @@ private Expression callCpCtor(Scope* sc, Expression e, Type destinationType, boo */ VarDeclaration tmp = copyToTemp(STC.rvalue, "__copytmp", e); if (nrvo) - tmp.adFlags |= Declaration.nrvo; + tmp.nrvo = true; if (sd.hasCopyCtor && destinationType) { // https://issues.dlang.org/show_bug.cgi?id=22619 @@ -2109,7 +2109,7 @@ public void errorSupplementalInferredAttr(FuncDeclaration fd, int maxDepth, bool { if (maxDepth > 0) { - errorFunc(s.loc, "which calls `%s`", s.fd.toPrettyChars()); + errorFunc(s.loc, "which calls `%s`", s.fd.toErrMsg()); errorSupplementalInferredAttr(s.fd, maxDepth - 1, deprecation, stc, eSink); } } @@ -2477,7 +2477,7 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 = auto tf = fd.type.isTypeFunction(); if (!tf.isRef && e2) { - error(loc, "%s is not an lvalue", e1.toChars()); + error(loc, "%s is not an lvalue", e1.toErrMsg()); return ErrorExp.get(); } } @@ -2645,13 +2645,13 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 = if (!e1.type) { - error(loc, "cannot resolve type for %s", e1.toChars()); + error(loc, "cannot resolve type for %s", e1.toErrMsg()); e1 = ErrorExp.get(); } return e1; Leprop: - error(loc, "not a property %s", e1.toChars()); + error(loc, "not a property %s", e1.toErrMsg()); return ErrorExp.get(); } @@ -2715,7 +2715,7 @@ private Type arrayExpressionToCommonType(Scope* sc, ref Expressions exps) e = resolveProperties(sc, e); if (!e.type) { - error(e.loc, "`%s` has no value", e.toChars()); + error(e.loc, "`%s` has no value", e.toErrMsg()); t0 = Type.terror; continue; } @@ -2912,7 +2912,7 @@ private bool preFunctionParameters(Scope* sc, ArgumentList argumentList, ErrorSi { if (eSink) { - eSink.error(arg.loc, "cannot pass type `%s` as a function argument", arg.toChars()); + eSink.error(arg.loc, "cannot pass type `%s` as a function argument", arg.toErrMsg()); arg = ErrorExp.get(); } err = true; @@ -2922,7 +2922,7 @@ private bool preFunctionParameters(Scope* sc, ArgumentList argumentList, ErrorSi { if (eSink) { - eSink.error(arg.loc, "cannot pass function `%s` as a function argument", arg.toChars()); + eSink.error(arg.loc, "cannot pass function `%s` as a function argument", arg.toErrMsg()); arg = ErrorExp.get(); } err = true; @@ -3515,7 +3515,7 @@ private bool functionParameters(Loc loc, Scope* sc, { if (se.hasOverloads && !se.var.isFuncDeclaration().isUnique()) { - error(arg.loc, "function `%s` is overloaded", arg.toChars()); + error(arg.loc, "function `%s` is overloaded", arg.toErrMsg()); err = true; } } @@ -4159,7 +4159,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (!s) { - error(e.loc, "`%s` is not in a class or struct scope", e.toChars()); + error(e.loc, "`%s` is not in a class or struct scope", e.toErrMsg()); return setError(); } ClassDeclaration cd = s.isClassDeclaration(); @@ -4225,7 +4225,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (!s) { - error(e.loc, "`%s` is not in a class scope", e.toChars()); + error(e.loc, "`%s` is not in a class scope", e.toErrMsg()); return setError(); } cd = s.isClassDeclaration(); @@ -4489,7 +4489,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor e = e.expressionSemantic(sc); if (!e.type) { - error(exp.loc, "`%s` has no value", e.toChars()); + error(exp.loc, "`%s` has no value", e.toErrMsg()); err = true; } else if (e.op == EXP.error) @@ -4540,7 +4540,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor */ if (e.elements.length > 0 && t0.ty == Tvoid) { - error(e.loc, "`%s` of type `%s` has no value", e.toChars(), e.type.toChars()); + error(e.loc, "`%s` of type `%s` has no value", e.toErrMsg(), e.type.toChars()); return setError(); } @@ -4864,14 +4864,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor id = new DotTemplateInstanceExp(ne.loc, id, hook, tiargs); auto arguments = new Expressions(); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? - sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(ne.loc, ne.loc.filename.toDString())); - arguments.push(new IntegerExp(ne.loc, ne.loc.linnum, Type.tint32)); - arguments.push(new StringExp(ne.loc, funcname.toDString())); - } id = new CallExp(ne.loc, id, arguments); ne.lowering = id.expressionSemantic(sc); @@ -5210,14 +5202,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor tiargs.push(t); id = new DotTemplateInstanceExp(exp.loc, id, hook, tiargs); auto arguments = new Expressions(); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? - sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } id = new CallExp(exp.loc, id, arguments); exp.lowering = id.expressionSemantic(sc); @@ -5359,9 +5343,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!global.params.useGC && sc.needsCodegen()) { version(IN_GCC) - error(exp.loc, "expression `%s` allocates with the GC and cannot be used with switch `-fno-rtti`", exp.toChars()); + error(exp.loc, "expression `%s` allocates with the GC and cannot be used with switch `-fno-rtti`", exp.toErrMsg()); else - error(exp.loc, "expression `%s` allocates with the GC and cannot be used with switch `-betterC`", exp.toChars()); + error(exp.loc, "expression `%s` allocates with the GC and cannot be used with switch `-betterC`", exp.toErrMsg()); return setError(); } @@ -5402,14 +5386,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor lowering = new DotTemplateInstanceExp(exp.loc, lowering, hook, tiargs); auto arguments = new Expressions(); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? - sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } arguments.push((*exp.arguments)[0]); arguments.push(new IntegerExp(exp.loc, isShared, Type.tbool)); @@ -5441,14 +5417,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor lowering = new DotTemplateInstanceExp(exp.loc, lowering, hook, tiargs); auto arguments = new Expressions(); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? - sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } arguments.push(new ArrayLiteralExp(exp.loc, Type.tsize_t.sarrayOf(nargs), exp.arguments)); arguments.push(new IntegerExp(exp.loc, tbn.isShared(), Type.tbool)); @@ -5832,8 +5800,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor OutBuffer buf; foreach (idx, ref arg; *arguments) buf.printf("%s%s", (idx ? ", ".ptr : "".ptr), arg.type.toChars()); - error(exp.loc, "function literal `%s%s` is not callable using argument types `(%s)`", - exp.fd.toChars(), parametersTypeToChars(tfl.parameterList), + error(exp.loc, "`%s` is not callable using argument types `(%s)`", + exp.fd.toErrMsg(), // parametersTypeToChars(tfl.parameterList), buf.peekChars()); errorSupplemental(exp.loc, "too %s arguments, expected %d, got %d", arguments.length < dim ? "few".ptr : "many".ptr, @@ -6038,7 +6006,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor __gshared int nest; if (++nest > global.recursionLimit) { - error(exp.loc, "recursive evaluation of `%s`", exp.toChars()); + error(exp.loc, "recursive evaluation of `%s`", exp.toErrMsg()); --nest; return setError(); } @@ -6331,7 +6299,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return null; if (f) return f; - .error(loc, "no overload matches for `%s`", exp.toChars()); + .error(loc, "no overload matches for `%s`", exp.toErrMsg()); errorSupplemental(loc, "Candidates are:"); foreach (s; os.a) { @@ -6591,7 +6559,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } else if (!t1) { - error(exp.loc, "function expected before `()`, not `%s`", exp.e1.toChars()); + error(exp.loc, "function expected before `()`, not `%s`", exp.e1.toErrMsg()); return setError(); } else if (t1.ty == Terror) @@ -6674,7 +6642,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } else { - error(exp.loc, "function expected before `()`, not `%s` of type `%s`", exp.e1.toChars(), exp.e1.type.toChars()); + error(exp.loc, "function expected before `()`, not `%s` of type `%s`", exp.e1.toErrMsg(), exp.e1.type.toChars()); return setError(); } @@ -6688,8 +6656,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor tthis.modToBuffer(buf); //printf("tf = %s, args = %s\n", tf.deco, (*arguments)[0].type.deco); - .error(exp.loc, "%s `%s%s` is not callable using argument types `%s`", - p, exp.e1.toChars(), parametersTypeToChars(tf.parameterList), buf.peekChars()); + .error(exp.loc, "%s `%s` is not callable using argument types `%s`", + p, exp.e1.toErrMsg(), buf.peekChars()); if (failMessage) errorSupplemental(exp.loc, "%s", failMessage); } @@ -6712,20 +6680,20 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!tf.purity && sc.func.setImpure(exp.loc, "calling impure `%s`", exp.e1)) { error(exp.loc, "`pure` %s `%s` cannot call impure %s `%s`", - sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toChars()); + sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toErrMsg()); err = true; } if (!tf.isNogc && sc.func.setGC(exp.loc, "calling non-@nogc `%s`", exp.e1)) { error(exp.loc, "`@nogc` %s `%s` cannot call non-@nogc %s `%s`", - sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toChars()); + sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toErrMsg()); err = true; } if (tf.trust <= TRUST.system && sc.setUnsafe(true, exp.loc, "calling `@system` `%s`", exp.e1)) { error(exp.loc, "`@safe` %s `%s` cannot call `@system` %s `%s`", - sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toChars()); + sc.func.kind(), sc.func.toPrettyChars(), p, exp.e1.toErrMsg()); err = true; } if (err) @@ -6770,7 +6738,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } .error(exp.loc, "%s `%s` is not callable using argument types `%s`", - exp.f.kind(), exp.f.toChars(), buf.peekChars()); + exp.f.kind(), exp.f.toErrMsg(), buf.peekChars()); if (failMessage) errorSupplemental(exp.loc, "%s", failMessage); .errorSupplemental(exp.f.loc, "`%s%s` declared here", exp.f.toPrettyChars(), parametersTypeToChars(tf.parameterList)); @@ -6846,7 +6814,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { exp.e1 = e1org; // https://issues.dlang.org/show_bug.cgi?id=10922 // avoid recursive expression printing - error(exp.loc, "forward reference to inferred return type of function call `%s`", exp.toChars()); + error(exp.loc, "forward reference to inferred return type of function call `%s`", exp.toErrMsg()); return setError(); } @@ -7126,7 +7094,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!ta) { //printf("ta %p ea %p sa %p\n", ta, ea, sa); - error(exp.loc, "no type for `typeid(%s)`", ea ? ea.toChars() : (sa ? sa.toChars() : "")); + error(exp.loc, "no type for `typeid(%s)`", ea ? ea.toErrMsg() : (sa ? sa.toChars() : "")); return setError(); } @@ -7798,7 +7766,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor // deprecated in 2.107 deprecation(e.loc, "assert condition cannot be a string literal"); deprecationSupplemental(e.loc, "If intentional, use `%s !is null` instead to preserve behaviour", - e.toChars()); + e.toErrMsg()); } const generateMsg = !exp.msg && @@ -8430,7 +8398,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor MODMatchToBuffer(&thisBuf, e.e1.type.mod, tf.mod); MODMatchToBuffer(&funcBuf, tf.mod, e.e1.type.mod); error(e.loc, "%smethod `%s` is not callable using a %s`%s`", - funcBuf.peekChars(), f.toPrettyChars(), thisBuf.peekChars(), e.e1.toChars()); + funcBuf.peekChars(), f.toPrettyChars(), thisBuf.peekChars(), e.e1.toErrMsg()); return setError(); } } @@ -8614,7 +8582,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!exp.e1.type) { - error(exp.loc, "cannot take address of `%s`", exp.e1.toChars()); + error(exp.loc, "cannot take address of `%s`", exp.e1.toErrMsg()); return setError(); } if (!checkAddressable(exp, sc)) @@ -8638,7 +8606,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor error(exp.loc, "forward reference to %s `%s`", d.kind(), d.toChars()); } else - error(exp.loc, "forward reference to type `%s` of expression `%s`", exp.e1.type.toChars(), exp.e1.toChars()); + error(exp.loc, "forward reference to type `%s` of expression `%s`", exp.e1.type.toChars(), exp.e1.toErrMsg()); return setError(); } } @@ -8801,7 +8769,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor case Tarray: if (isNonAssignmentArrayOp(exp.e1)) goto default; - error(exp.loc, "using `*` on an array is no longer supported; use `*(%s).ptr` instead", exp.e1.toChars()); + error(exp.loc, "using `*` on an array is no longer supported; use `*(%s).ptr` instead", exp.e1.toErrMsg()); exp.type = (cast(TypeArray)tb).next; exp.e1 = exp.e1.castTo(sc, exp.type.pointerTo()); break; @@ -9111,7 +9079,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!exp.e1.type) { - error(exp.loc, "cannot cast `%s`", exp.e1.toChars()); + error(exp.loc, "cannot cast `%s`", exp.e1.toErrMsg()); return setError(); } @@ -9149,7 +9117,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.to.ty == Ttuple) { - error(exp.loc, "cannot cast `%s` of type `%s` to type sequence `%s`", exp.e1.toChars(), exp.e1.type.toChars(), exp.to.toChars()); + error(exp.loc, "cannot cast `%s` of type `%s` to type sequence `%s`", exp.e1.toErrMsg(), exp.e1.type.toChars(), exp.to.toChars()); return setError(); } @@ -9333,7 +9301,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (elem.isConst() == 1) return false; - error(exp.loc, "constant expression expected, not `%s`", elem.toChars()); + error(exp.loc, "constant expression expected, not `%s`", elem.toErrMsg()); return true; } @@ -9393,7 +9361,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (exp.lwr || exp.upr) { - error(exp.loc, "cannot slice type `%s`", exp.e1.toChars()); + error(exp.loc, "cannot slice type `%s`", exp.e1.toErrMsg()); return setError(); } Expression e = new TypeExp(exp.loc, exp.e1.type.arrayOf()); @@ -9445,7 +9413,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (t1b.isPtrToFunction()) { - error(exp.loc, "cannot slice function pointer `%s`", exp.e1.toChars()); + error(exp.loc, "cannot slice function pointer `%s`", exp.e1.toErrMsg()); return setError(); } if (!exp.lwr || !exp.upr) @@ -9462,9 +9430,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { errorSupplemental(exp.loc, "pointer `%s` points to an aggregate that defines an `%s`, perhaps you meant `(*%s)[]`", - exp.e1.toChars(), + exp.e1.toErrMsg(), s.ident.toChars(), - exp.e1.toChars() + exp.e1.toErrMsg() ); } @@ -9505,7 +9473,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } else { - error(exp.loc, "`%s` cannot be sliced with `[]`", t1b.ty == Tvoid ? exp.e1.toChars() : t1b.toChars()); + error(exp.loc, "`%s` cannot be sliced with `[]`", t1b.ty == Tvoid ? exp.e1.toErrMsg() : t1b.toChars()); return setError(); } @@ -9981,7 +9949,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor case Tpointer: if (t1b.isPtrToFunction()) { - error(exp.loc, "cannot index function pointer `%s`", exp.e1.toChars()); + error(exp.loc, "cannot index function pointer `%s`", exp.e1.toErrMsg()); return setError(); } exp.e2 = exp.e2.implicitCastTo(sc, Type.tsize_t); @@ -10078,7 +10046,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return; } default: - error(exp.loc, "`%s` must be an array or pointer type, not `%s`", exp.e1.toChars(), exp.e1.type.toChars()); + error(exp.loc, "`%s` must be an array or pointer type, not `%s`", exp.e1.toErrMsg(), exp.e1.type.toChars()); return setError(); } @@ -10156,7 +10124,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.e1.op == EXP.slice) { const(char)* s = exp.op == EXP.plusPlus ? "increment" : "decrement"; - error(exp.loc, "cannot post-%s array slice `%s`, use pre-%s instead", s, exp.e1.toChars(), s); + error(exp.loc, "cannot post-%s array slice `%s`, use pre-%s instead", s, exp.e1.toErrMsg(), s); return setError(); } @@ -10909,7 +10877,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (newExp.newtype && newExp.newtype == t1) { error(exp.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", - newExp.toChars(), newExp.type.toChars(), t1.toChars()); + newExp.toErrMsg(), newExp.type.toChars(), t1.toChars()); errorSupplemental(exp.loc, "Perhaps remove the `new` keyword?"); return setError(); } @@ -11200,6 +11168,11 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor exp.e2 = e2x; t1 = e1x.type.toBasetype(); } + else if (t1.ty == Taarray) + { + // when assigning a constant, the need for TypeInfo might change + semanticTypeInfo(sc, t1); + } /* Check the mutability of e1. */ if (auto ale = exp.e1.isArrayLengthExp()) @@ -11248,14 +11221,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor id = id.expressionSemantic(sc); auto arguments = new Expressions(); - arguments.reserve(5); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } arguments.push(ale.e1); arguments.push(exp.e2); @@ -11282,7 +11247,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.op == EXP.assign && !tn.baseElemOf().isAssignable()) { error(exp.loc, "slice `%s` is not mutable, struct `%s` has immutable members", - exp.e1.toChars(), tn.baseElemOf().toChars()); + exp.e1.toErrMsg(), tn.baseElemOf().toChars()); result = ErrorExp.get(); return; } @@ -11305,7 +11270,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (tn && !tn.baseElemOf().isAssignable()) { error(exp.loc, "array `%s` is not mutable, struct `%s` has immutable members", - exp.e1.toChars(), tn.baseElemOf().toChars()); + exp.e1.toErrMsg(), tn.baseElemOf().toChars()); result = ErrorExp.get(); return; } @@ -11375,7 +11340,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor uinteger_t dim2 = tsa2.dim.toInteger(); if (dim1 != dim2) { - error(exp.loc, "mismatched array lengths %d and %d for assignment `%s`", cast(int)dim1, cast(int)dim2, exp.toChars()); + error(exp.loc, "mismatched array lengths %d and %d for assignment `%s`", cast(int)dim1, cast(int)dim2, exp.toErrMsg()); return setError(); } } @@ -11451,7 +11416,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor // offer more information about the cause of the problem errorSupplemental(exp.loc, "`%s` is the first assignment of `%s` therefore it represents its initialization", - exp.toChars(), exp.e1.toChars()); + exp.toErrMsg(), exp.e1.toErrMsg()); errorSupplemental(exp.loc, "`opAssign` methods are not used for initialization, but for subsequent assignments"); } @@ -11973,15 +11938,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor id = new DotIdExp(exp.loc, id, hook); auto arguments = new Expressions(); - arguments.reserve(5); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } - arguments.push(exp.e1); arguments.push(exp.e2); Expression ce = new CallExp(exp.loc, id, arguments); @@ -12016,15 +11972,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor id = new DotIdExp(exp.loc, id, hook); auto arguments = new Expressions(); - arguments.reserve(5); - if (global.params.tracegc) - { - auto funcname = (sc.callsc && sc.callsc.func) ? sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } - Expression eValue1; Expression value1 = extractSideEffect(sc, "__appendtmp", eValue1, exp.e1); @@ -12368,7 +12315,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (hook == Id._d_arraycatnTX) arguments.pushSlice((*callExp.arguments)[]); else - arguments.pushSlice((*callExp.arguments)[3 .. $]); + arguments.pushSlice((*callExp.arguments)[0 .. $ - 3]); } } else @@ -12376,15 +12323,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } auto arguments = new Expressions(); - if (useTraceGCHook) - { - auto funcname = (sc.callsc && sc.callsc.func) ? - sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars(); - arguments.push(new StringExp(exp.loc, exp.loc.filename.toDString())); - arguments.push(new IntegerExp(exp.loc, exp.loc.linnum, Type.tint32)); - arguments.push(new StringExp(exp.loc, funcname.toDString())); - } - handleCatArgument(arguments, exp.e1, exp.type.toBasetype(), false); handleCatArgument(arguments, exp.e2, exp.type.toBasetype(), true); @@ -12796,7 +12734,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor Module mmath = Module.loadStdMath(); if (!mmath) { - error(e.loc, "`%s` requires `std.math` for `^^` operators", e.toChars()); + error(e.loc, "`%s` requires `std.math` for `^^` operators", e.toErrMsg()); return setError(); } e = new ScopeExp(exp.loc, mmath); @@ -12970,7 +12908,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (e2x.op == EXP.type || e2x.op == EXP.scope_) { - error(exp.loc, "`%s` is not an expression", exp.e2.toChars()); + error(exp.loc, "`%s` is not an expression", exp.e2.toErrMsg()); return setError(); } if (e1x.op == EXP.error || e1x.type.ty == Tnoreturn) @@ -13137,7 +13075,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor exp.e1 = exp.e1.implicitCastTo(sc, ta.index); } - semanticTypeInfo(sc, ta.index); + // even though the glue layer only needs the type info of the index, + // this might be the first time an AA literal is accessed, so check + // the full type info + semanticTypeInfo(sc, ta); // Return type is pointer to value exp.type = ta.nextOf().pointerTo(); @@ -13152,7 +13093,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor errorSupplemental(exp.loc, "`in` is only allowed on associative arrays"); const(char)* slice = (t2b.ty == Tsarray) ? "[]" : ""; errorSupplemental(exp.loc, "perhaps use `std.algorithm.find(%s, %s%s)` instead", - exp.e1.toChars(), exp.e2.toChars(), slice); + exp.e1.toErrMsg(), exp.e2.toErrMsg(), slice); return; default: @@ -13374,8 +13315,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } if (exp.e1.type.toBasetype().ty == Taarray) + { semanticTypeInfo(sc, exp.e1.type.toBasetype()); - + } if (!target.isVectorOpSupported(t1, exp.op, t2)) { @@ -13998,12 +13940,12 @@ private Expression dotIdSemanticPropX(DotIdExp exp, Scope* sc) // Template has no built-in properties except for 'stringof'. if ((exp.e1.isDotTemplateExp() || exp.e1.isTemplateExp()) && exp.ident != Id.stringof) { - error(exp.loc, "template `%s` does not have property `%s`", exp.e1.toChars(), exp.ident.toChars()); + error(exp.loc, "template `%s` does not have property `%s`", exp.e1.toErrMsg(), exp.ident.toChars()); return ErrorExp.get(); } if (!exp.e1.type) { - error(exp.loc, "expression `%s` does not have property `%s`", exp.e1.toChars(), exp.ident.toChars()); + error(exp.loc, "expression `%s` does not have property `%s`", exp.e1.toErrMsg(), exp.ident.toChars()); return ErrorExp.get(); } @@ -14405,7 +14347,7 @@ Expression dotTemplateSemanticProp(DotTemplateInstanceExp exp, Scope* sc, bool g Expression notTemplate() { - error(exp.loc, "`%s` isn't a template", e.toChars()); + error(exp.loc, "`%s` isn't a template", e.toErrMsg()); return errorExp(); } @@ -14720,7 +14662,7 @@ MATCH matchType(FuncExp funcExp, Type to, Scope* sc, FuncExp* presult, ErrorSink { auto ts = toAutoQualChars(tx, to); eSink.error(loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", - funcExp.toChars(), ts[0], ts[1]); + funcExp.toErrMsg(), ts[0], ts[1]); } return m; } @@ -14733,7 +14675,7 @@ private bool checkScalar(Expression e) return true; if (!e.type.isScalar()) { - error(e.loc, "`%s` is not a scalar, it is a `%s`", e.toChars(), e.type.toChars()); + error(e.loc, "`%s` is not a scalar, it is a `%s`", e.toErrMsg(), e.type.toChars()); return true; } return e.checkValue(); @@ -14747,7 +14689,7 @@ private bool checkNoBool(Expression e) return true; if (e.type.toBasetype().ty == Tbool) { - error(e.loc, "operation not allowed on `bool` `%s`", e.toChars()); + error(e.loc, "operation not allowed on `bool` `%s`", e.toErrMsg()); return true; } return false; @@ -14761,7 +14703,7 @@ private bool checkIntegral(Expression e) return true; if (!e.type.isIntegral()) { - error(e.loc, "`%s` is not of integral type, it is a `%s`", e.toChars(), e.type.toChars()); + error(e.loc, "`%s` is not of integral type, it is a `%s`", e.toErrMsg(), e.type.toChars()); return true; } return e.checkValue(); @@ -14779,7 +14721,7 @@ private bool checkArithmetic(Expression e, EXP op) const char* msg = e.type.isAggregate() ? "operator `%s` is not defined for `%s` of type `%s`" : "illegal operator `%s` for `%s` of type `%s`"; - error(e.loc, msg, EXPtoString(op).ptr, e.toChars(), e.type.toChars()); + error(e.loc, msg, EXPtoString(op).ptr, e.toErrMsg(), e.type.toChars()); return true; } @@ -14862,7 +14804,7 @@ bool checkValue(Expression e) { if (auto te = e.isTypeExp()) { - error(e.loc, "type `%s` has no value", e.toChars()); + error(e.loc, "type `%s` has no value", e.toErrMsg()); if (!e.type.isOpaqueType) errorSupplemental(e.loc, "perhaps use `%s.init`", e.toChars()); return true; @@ -14874,7 +14816,7 @@ bool checkValue(Expression e) dtie.ti.semantictiargsdone && dtie.ti.semanticRun == PASS.initial) - error(e.loc, "partial %s `%s` has no value", dtie.ti.kind(), e.toChars()); + error(e.loc, "partial %s `%s` has no value", dtie.ti.kind(), e.toErrMsg()); else error(e.loc, "%s `%s` has no value", dtie.ti.kind(), dtie.ti.toChars()); return true; @@ -14904,13 +14846,13 @@ bool checkValue(Expression e) if (auto dte = e.isDotTemplateExp()) { - error(e.loc, "%s `%s` has no value", dte.td.kind(), e.toChars()); + error(e.loc, "%s `%s` has no value", dte.td.kind(), e.toErrMsg()); return true; } if (e.type && e.type.toBasetype().ty == Tvoid) { - error(e.loc, "expression `%s` is `void` and has no value", e.toChars()); + error(e.loc, "expression `%s` is `void` and has no value", e.toErrMsg()); //print(); assert(0); if (!global.gag) e.type = Type.terror; @@ -14970,7 +14912,7 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) bool sharedError(Expression e) { // https://dlang.org/phobos/core_atomic.html - error(e.loc, "direct access to shared `%s` is not allowed, see `core.atomic`", e.toChars()); + error(e.loc, "direct access to shared `%s` is not allowed, see `core.atomic`", e.toErrMsg()); return true; } @@ -15494,9 +15436,9 @@ private Expression toLvalueImpl(Expression _this, Scope* sc, const(char)* action if (e.op == EXP.type) error(_this.loc, "cannot %s type `%s`", action, e.type.toChars()); else if (e.op == EXP.template_) - error(_this.loc, "cannot %s template `%s`, perhaps instantiate it first", action, e.toChars()); + error(_this.loc, "cannot %s template `%s`, perhaps instantiate it first", action, e.toErrMsg()); else - error(_this.loc, "cannot %s expression `%s` because it is not an lvalue", action, e.toChars()); + error(_this.loc, "cannot %s expression `%s` because it is not an lvalue", action, e.toErrMsg()); return ErrorExp.get(); } @@ -15505,7 +15447,7 @@ private Expression toLvalueImpl(Expression _this, Scope* sc, const(char)* action { if (!_this.loc.isValid()) _this.loc = e.loc; - error(e.loc, "cannot %s constant `%s`", action, e.toChars()); + error(e.loc, "cannot %s constant `%s`", action, e.toErrMsg()); return ErrorExp.get(); } @@ -15930,12 +15872,12 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression break; if (!ff.type.isMutable) { - error(exp.loc, "cannot modify `%s` in `%s` function", exp.toChars(), MODtoChars(type.mod)); + error(exp.loc, "cannot modify `%s` in `%s` function", exp.toErrMsg(), MODtoChars(type.mod)); return ErrorExp.get(); } } } - error(exp.loc, "cannot modify `%s` expression `%s`", MODtoChars(type.mod), exp.toChars()); + error(exp.loc, "cannot modify `%s` expression `%s`", MODtoChars(type.mod), exp.toErrMsg()); return ErrorExp.get(); } else if (!type.isAssignable()) @@ -15950,7 +15892,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression Expression visitString(StringExp exp) { - error(exp.loc, "cannot modify string literal `%s`", exp.toChars()); + error(exp.loc, "cannot modify string literal `%s`", exp.toErrMsg()); return ErrorExp.get(); } @@ -15959,7 +15901,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression //printf("VarExp::modifiableLvalue('%s')\n", exp.var.toChars()); if (exp.var.storage_class & STC.manifest) { - error(exp.loc, "cannot modify manifest constant `%s`", exp.toChars()); + error(exp.loc, "cannot modify manifest constant `%s`", exp.toErrMsg()); return ErrorExp.get(); } // See if this expression is a modifiable lvalue (i.e. not const) @@ -15988,7 +15930,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression Expression visitSlice(SliceExp exp) { - error(exp.loc, "slice expression `%s` is not a modifiable lvalue", exp.toChars()); + error(exp.loc, "slice expression `%s` is not a modifiable lvalue", exp.toErrMsg()); return exp; } @@ -16030,7 +15972,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression { if (!exp.e1.isLvalue() && !exp.e2.isLvalue()) { - error(exp.loc, "conditional expression `%s` is not a modifiable lvalue", exp.toChars()); + error(exp.loc, "conditional expression `%s` is not a modifiable lvalue", exp.toErrMsg()); return ErrorExp.get(); } exp.e1 = exp.e1.modifiableLvalue(sc); @@ -16071,7 +16013,7 @@ private bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v) if (!v.canTakeAddressOf()) { - error(exp.loc, "cannot take address of `%s`", exp.toChars()); + error(exp.loc, "cannot take address of `%s`", exp.toErrMsg()); return false; } if (sc.func && !sc.intypeof && !v.isDataseg()) @@ -16133,9 +16075,9 @@ bool checkAddressable(Expression e, Scope* sc) if (ex.isVarExp().var.storage_class & STC.register) { if (e.isIndexExp()) - error(e.loc, "cannot index through register variable `%s`", ex.toChars()); + error(e.loc, "cannot index through register variable `%s`", ex.toErrMsg()); else - error(e.loc, "cannot take address of register variable `%s`", ex.toChars()); + error(e.loc, "cannot take address of register variable `%s`", ex.toErrMsg()); return false; } } @@ -16629,7 +16571,7 @@ bool evalStaticCondition(Scope* sc, Expression original, Expression e, out bool if (opt.isEmpty()) { if (!e.type.isTypeError()) - error(e.loc, "expression `%s` is not constant", e.toChars()); + error(e.loc, "expression `%s` is not constant", e.toErrMsg()); errors = true; return false; } @@ -16916,6 +16858,9 @@ void semanticTypeInfo(Scope* sc, Type t) { semanticTypeInfo(sc, t.index); semanticTypeInfo(sc, t.next); + + if (global.params.useTypeInfo) + getTypeInfoType(t.loc, t, sc); } void visitStruct(TypeStruct t) diff --git a/gcc/d/dmd/file_manager.d b/gcc/d/dmd/file_manager.d index 7f39ec91f02..f2116e585d8 100644 --- a/gcc/d/dmd/file_manager.d +++ b/gcc/d/dmd/file_manager.d @@ -101,8 +101,10 @@ private struct PathCache */ bool exists = true; auto st = PathStack(filespec); - while (st.up) { - if (auto cached = pathStatus.lookup(st.cur)) { + while (st.up) + { + if (auto cached = pathStatus.lookup(st.cur)) + { exists = cached.value; break; } @@ -112,7 +114,8 @@ private struct PathCache * Once a directory is found to not exist, all the directories * to the right of it do not exist */ - while (st.down) { + while (st.down) + { if (!exists) pathStatus.insert(st.cur, false); else @@ -218,17 +221,19 @@ nothrow: const(char)[] n = FileName.combine(p, sdi); - if (!pathCache.pathExists(n)) { + if (!pathCache.pathExists(n)) + { FileName.free(n.ptr); continue; // no need to check for anything else. } - if (FileName.exists(n) == 1) { + if (FileName.exists(n) == 1) return n; - } + FileName.free(n.ptr); n = FileName.combine(p, sd); - if (FileName.exists(n) == 1) { + if (FileName.exists(n) == 1) + { whichPathFoundThis = pathIndex; return n; } @@ -241,14 +246,16 @@ nothrow: if (pathCache.isExistingPath(n)) { const n2i = FileName.combine(n, package_di); - if (FileName.exists(n2i) == 1) { + if (FileName.exists(n2i) == 1) + { whichPathFoundThis = pathIndex; return n2i; } FileName.free(n2i.ptr); const n2 = FileName.combine(n, package_d); - if (FileName.exists(n2) == 1) { + if (FileName.exists(n2) == 1) + { whichPathFoundThis = pathIndex; return n2; } @@ -272,14 +279,16 @@ nothrow: const p = entry.path.toDString(); const(char)[] n = FileName.combine(p, si); - if (FileName.exists(n) == 1) { + if (FileName.exists(n) == 1) + { whichPathFoundThis = pathIndex; return n; } FileName.free(n.ptr); n = FileName.combine(p, sc); - if (FileName.exists(n) == 1) { + if (FileName.exists(n) == 1) + { whichPathFoundThis = pathIndex; return n; } diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d index 80312f2f3c5..e5b72e2bb3c 100644 --- a/gcc/d/dmd/func.d +++ b/gcc/d/dmd/func.d @@ -1883,10 +1883,10 @@ struct AttributeViolation assert(args.length <= 4); // expand if necessary OutBuffer buf; buf.printf(fmt, - args.length > 0 && args[0] ? args[0].toChars() : "", - args.length > 1 && args[1] ? args[1].toChars() : "", - args.length > 2 && args[2] ? args[2].toChars() : "", - args.length > 3 && args[3] ? args[3].toChars() : "", + args.length > 0 && args[0] ? args[0].toErrMsg() : "", + args.length > 1 && args[1] ? args[1].toErrMsg() : "", + args.length > 2 && args[2] ? args[2].toErrMsg() : "", + args.length > 3 && args[3] ? args[3].toErrMsg() : "", ); this.action = buf.extractSlice(); } diff --git a/gcc/d/dmd/hdrgen.d b/gcc/d/dmd/hdrgen.d index c0fcf64be31..0ef955a0339 100644 --- a/gcc/d/dmd/hdrgen.d +++ b/gcc/d/dmd/hdrgen.d @@ -59,10 +59,12 @@ struct HdrGenState bool ddoc; /// true if generating Ddoc file bool fullDump; /// true if generating a full AST dump file bool importcHdr; /// true if generating a .di file from an ImportC file + bool inCAlias; /// Set to prevent ImportC translating typedefs as `alias X = X` bool doFuncBodies; /// include function bodies in output bool vcg_ast; /// write out codegen-ast bool skipConstraints; // skip constraints when doing templates bool showOneMember = true; + bool errorMsg; /// true if formatting for inside an error message bool fullQual; /// fully qualify types when printing int tpltMember; @@ -96,6 +98,87 @@ void genhdrfile(Module m, bool doFuncBodies, ref OutBuffer buf) toCBuffer(m, buf, hgs); } +/** + * Convert `o` to a string for error messages. + * Params: + * e = object to convert + * Returns: string representation of `e` + */ +const(char)* toErrMsg(const RootObject o) +{ + if (auto e = o.isExpression()) + return toErrMsg(e); + if (auto d = o.isDsymbol()) + return toErrMsg(d); + if (auto t = o.isType()) + return t.toChars(); + if (auto id = o.isIdentifier()) + return id.toChars(); + assert(0); +} + +/// ditto +const(char)* toErrMsg(const Expression e) +{ + HdrGenState hgs; + hgs.errorMsg = true; + OutBuffer buf; + toCBuffer(e, buf, hgs); + truncateForError(buf, 60); + + return buf.extractChars(); +} + +/// ditto +const(char)* toErrMsg(const Dsymbol d) +{ + if (d.isFuncDeclaration() || d.isTemplateInstance()) + { + if (d.ident && d.ident.toString.startsWith("__") && !d.isCtorDeclaration()) + { + HdrGenState hgs; + hgs.errorMsg = true; + OutBuffer buf; + toCBuffer(cast() d, buf, hgs); + truncateForError(buf, 80); + return buf.extractChars(); + } + } + + return d.toChars(); +} + +/** + * Make the content of `buf` fit inline for an error message. + * Params: + * buf = buffer with text to modify + * maxLength = truncate text when it exceeds this length + */ +private void truncateForError(ref OutBuffer buf, size_t maxLength) +{ + // Remove newlines, escape backticks ` by doubling them + for (size_t i = 0; i < buf.length; i++) + { + if (buf[i] == '\r') + buf.remove(i, 1); + if (buf[i] == '\n') + buf.peekSlice[i] = ' '; + if (buf[i] == '`') + i = buf.insert(i, "`"); + } + + // Strip trailing whitespace + while (buf.length && buf[$-1] == ' ') + buf.setsize(buf.length - 1); + + // Truncate + if (buf.length > maxLength) + { + buf.setsize(maxLength - 3); + buf.writestring("..."); + } +} + /*************************************** * Turn a Statement into a string suitable for printf. * Leaks memory. @@ -1658,7 +1741,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) { if (d.storage_class & STC.local) return; - if (d.adFlags & d.hidden) + if (d.hidden) return; buf.writestring("alias "); if (d.aliassym) @@ -1695,7 +1778,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) buf.writestring(" = "); if (stcToBuffer(buf, d.storage_class)) buf.writeByte(' '); + hgs.inCAlias = hgs.importcHdr; typeToBuffer(d.type, null, buf, hgs); + hgs.inCAlias = false; hgs.declstring = false; } buf.writeByte(';'); @@ -1772,7 +1857,7 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) buf.writestring("__error"); return; } - if (f.tok != TOK.reserved) + if (f.tok != TOK.reserved && !hgs.errorMsg) { buf.writestring(f.kind()); buf.writeByte(' '); @@ -1789,8 +1874,9 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) buf.writeByte(' '); buf.writestring(str); } - tf.attributesApply(&printAttribute); + if (!hgs.errorMsg) + tf.attributesApply(&printAttribute); CompoundStatement cs = f.fbody.isCompoundStatement(); Statement s1; @@ -4366,6 +4452,11 @@ private void typeToBufferx(Type t, ref OutBuffer buf, ref HdrGenState hgs) buf.writestring("noreturn"); } + if (hgs.importcHdr && !hgs.inCAlias && t.mcache && t.mcache.typedefIdent) + { + buf.writestring(t.mcache.typedefIdent.toString()); + return; + } switch (t.ty) { diff --git a/gcc/d/dmd/id.d b/gcc/d/dmd/id.d index 9833e1980ed..fa7fe1d5eda 100644 --- a/gcc/d/dmd/id.d +++ b/gcc/d/dmd/id.d @@ -166,6 +166,7 @@ immutable Msgtable[] msgtable = { "xopCmp", "__xopCmp" }, { "xtoHash", "__xtoHash" }, { "__tmpfordtor" }, + { "Entry" }, { "LINE", "__LINE__" }, { "FILE", "__FILE__" }, diff --git a/gcc/d/dmd/identifier.d b/gcc/d/dmd/identifier.d index 231aa5832fd..9ef8285f8ea 100644 --- a/gcc/d/dmd/identifier.d +++ b/gcc/d/dmd/identifier.d @@ -248,13 +248,14 @@ nothrow: * directly, but that would unnecessary lengthen symbols names. See issue: * https://issues.dlang.org/show_bug.cgi?id=23722 */ - static struct Key { uint fileOffset; string prefix; string parent; } + static struct Key { string locKey; string prefix; string parent; } __gshared uint[Key] counters; + string locKey = cast(string) (sl.filename ~ idBuf[]); static if (__traits(compiles, counters.update(Key.init, () => 0u, (ref uint a) => 0u))) { // 2.082+ - counters.update(Key(loc.fileOffset, prefix, parent), + counters.update(Key(locKey, prefix, parent), () => 1u, // insertion (ref uint counter) // update { @@ -266,7 +267,7 @@ nothrow: } else { - const key = Key(loc.fileOffset, prefix, parent); + const key = Key(locKey, prefix, parent); if (auto pCounter = key in counters) { idBuf.writestring("_"); diff --git a/gcc/d/dmd/initsem.d b/gcc/d/dmd/initsem.d index 467b7966074..cda4088cb17 100644 --- a/gcc/d/dmd/initsem.d +++ b/gcc/d/dmd/initsem.d @@ -585,7 +585,7 @@ Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx, NeedIn const errors = global.startGagging(); i.exp = i.exp.implicitCastTo(sc, t); if (global.endGagging(errors)) - error(currExp.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", currExp.toChars(), et.toChars(), t.toChars()); + error(currExp.loc, "cannot implicitly convert expression `%s` of type `%s` to `%s`", currExp.toErrMsg(), et.toChars(), t.toChars()); } } L1: diff --git a/gcc/d/dmd/json.d b/gcc/d/dmd/json.d index 05924f7b8b7..490032066e0 100644 --- a/gcc/d/dmd/json.d +++ b/gcc/d/dmd/json.d @@ -41,10 +41,13 @@ import dmd.root.string; import dmd.target; import dmd.visitor; -version(Windows) { +version(Windows) +{ extern (C) char* _getcwd(char* buffer, size_t maxlen); alias getcwd = _getcwd; -} else { +} +else +{ import core.sys.posix.unistd : getcwd; } diff --git a/gcc/d/dmd/lambdacomp.d b/gcc/d/dmd/lambdacomp.d index 90c794e2405..96a17805d2b 100644 --- a/gcc/d/dmd/lambdacomp.d +++ b/gcc/d/dmd/lambdacomp.d @@ -445,7 +445,8 @@ public: visitType(p.type); } - override void visit(StructLiteralExp e) { + override void visit(StructLiteralExp e) + { static if (LOG) printf("StructLiteralExp: %s\n", e.toChars); diff --git a/gcc/d/dmd/lexer.d b/gcc/d/dmd/lexer.d index 61b4f414c1f..51e597c4130 100644 --- a/gcc/d/dmd/lexer.d +++ b/gcc/d/dmd/lexer.d @@ -867,7 +867,7 @@ class Lexer case 0: case 0x1A: error(t.loc, "unterminated /* */ comment"); - p = end; + //p = end; t.loc = loc(); t.value = TOK.endOfFile; return; @@ -927,7 +927,7 @@ class Lexer getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1); lastDocLine = linnum; } - p = end; + //p = end; t.loc = loc(); t.value = TOK.endOfFile; return; @@ -1003,7 +1003,7 @@ class Lexer case 0: case 0x1A: error(t.loc, "unterminated /+ +/ comment"); - p = end; + //p = end; t.loc = loc(); t.value = TOK.endOfFile; return; @@ -3441,9 +3441,8 @@ class Lexer int linestart = 0; if (ct == '/') { - if (q < qend && *q == ' ') { + if (q < qend && *q == ' ') ++q; - } } else if (q < qend) { diff --git a/gcc/d/dmd/location.d b/gcc/d/dmd/location.d index 8a27541a72e..ef5430ffa23 100644 --- a/gcc/d/dmd/location.d +++ b/gcc/d/dmd/location.d @@ -64,7 +64,7 @@ nothrow: extern (C++) static Loc singleFilename(const char* filename) { Loc result; - locFileTable ~= BaseLoc(filename.toDString, locIndex, 0, [0]); + locFileTable ~= new BaseLoc(filename.toDString, locIndex, 0, [0]); result.index = locIndex++; return result; } @@ -95,7 +95,19 @@ nothrow: */ extern (C++) const(char)* filename() const @nogc { - return SourceLoc(this).filename.ptr; // _filename; + if (this.index == 0) + return null; + + const i = fileTableIndex(this.index); + if (locFileTable[i].substitutions.length > 0) + { + const si = locFileTable[i].getSubstitutionIndex(this.index - locFileTable[i].startIndex); + const fname = locFileTable[i].substitutions[si].filename; + if (fname.length > 0) + return fname.ptr; + } + + return locFileTable[i].filename.ptr; } extern (C++) const(char)* toChars( @@ -293,11 +305,11 @@ private size_t fileTableIndex(uint index) nothrow @nogc */ BaseLoc* newBaseLoc(const(char)* filename, size_t size) nothrow { - locFileTable ~= BaseLoc(filename.toDString, locIndex, 1, [0]); + locFileTable ~= new BaseLoc(filename.toDString, locIndex, 1, [0]); // Careful: the endloc of a FuncDeclaration can // point to 1 past the very last byte in the file, so account for that locIndex += size + 1; - return &locFileTable[$ - 1]; + return locFileTable[$ - 1]; } /** @@ -385,7 +397,23 @@ struct BaseLoc if (substitutions.length == 0) return loc; - const offset = loc.fileOffset; + const i = getSubstitutionIndex(loc.fileOffset); + if (substitutions[i].filename.length > 0) + loc.filename = substitutions[i].filename; + loc.linnum += substitutions[i].startLine; + return loc; + } + + /// Resolve an offset into this file to a filename + line + column + private SourceLoc getSourceLoc(uint offset) @nogc + { + const i = getLineIndex(offset); + const sl = SourceLoc(filename, cast(int) (i + startLine), cast(int) (1 + offset - lines[i]), offset); + return substitute(sl); + } + + private size_t getSubstitutionIndex(uint offset) @nogc + { size_t lo = 0; size_t hi = substitutions.length + -1; size_t mid = 0; @@ -395,12 +423,7 @@ struct BaseLoc if (substitutions[mid].startIndex <= offset) { if (mid == substitutions.length - 1 || substitutions[mid + 1].startIndex > offset) - { - if (substitutions[mid].filename.length > 0) - loc.filename = substitutions[mid].filename; - loc.linnum += substitutions[mid].startLine; - return loc; - } + return mid; lo = mid + 1; } @@ -412,14 +435,6 @@ struct BaseLoc assert(0); } - /// Resolve an offset into this file to a filename + line + column - private SourceLoc getSourceLoc(uint offset) @nogc - { - const i = getLineIndex(offset); - const sl = SourceLoc(filename, cast(int) (i + startLine), cast(int) (1 + offset - lines[i]), offset); - return substitute(sl); - } - /// Binary search the index in `this.lines` corresponding to `offset` private size_t getLineIndex(uint offset) @nogc { @@ -449,4 +464,4 @@ struct BaseLoc private __gshared uint locIndex = 1; // Global mapping of Loc indices to source file offset/line/column, see `BaseLoc` -private __gshared BaseLoc[] locFileTable; +private __gshared BaseLoc*[] locFileTable; diff --git a/gcc/d/dmd/mtype.d b/gcc/d/dmd/mtype.d index 1cebcc8de64..84899d003ca 100644 --- a/gcc/d/dmd/mtype.d +++ b/gcc/d/dmd/mtype.d @@ -299,13 +299,16 @@ extern (C++) abstract class Type : ASTNode Type wcto; // MODFlags.wildconst Type swto; // MODFlags.shared_ | MODFlags.wild Type swcto; // MODFlags.shared_ | MODFlags.wildconst + Type pto; // merged pointer to this type + Type rto; // reference to this type + Type arrayof; // array of this type + + // ImportC: store the name of the typedef resolving to this type + // So `uint8_t x;` will be printed as `uint8_t x;` and not as the resolved `ubyte x;` + Identifier typedefIdent; } Mcache* mcache; - Type pto; // merged pointer to this type - Type rto; // reference to this type - Type arrayof; // array of this type - TypeInfoDeclaration vtinfo; // TypeInfo object for this Type void* ctype; // for back end @@ -762,9 +765,6 @@ extern (C++) abstract class Type : ASTNode memcpy(cast(void*)t, cast(void*)this, sz); // t.mod = NULL; // leave mod unchanged t.deco = null; - t.arrayof = null; - t.pto = null; - t.rto = null; t.vtinfo = null; t.ctype = null; t.mcache = null; @@ -2959,9 +2959,6 @@ extern (C++) final class TypeIdentifier : TypeQualified { Identifier ident; - // The symbol representing this identifier, before alias resolution - Dsymbol originalSymbol; - extern (D) this(Loc loc, Identifier ident) { super(Tident, loc); @@ -3870,7 +3867,8 @@ extern (C++) struct ParameterList foreach (_, p1; cast() this) { auto p2 = other[idx++]; - if (!p2 || p1 != p2) { + if (!p2 || p1 != p2) + { diff = true; break; } diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h index 0cf08e74884..990f8d4d70d 100644 --- a/gcc/d/dmd/mtype.h +++ b/gcc/d/dmd/mtype.h @@ -146,9 +146,6 @@ public: MOD mod; // modifiers MODxxxx char *deco; void* mcache; - Type *pto; // merged pointer to this type - Type *rto; // reference to this type - Type *arrayof; // array of this type TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type type *ctype; // for back end @@ -630,7 +627,6 @@ class TypeIdentifier final : public TypeQualified { public: Identifier *ident; - Dsymbol *originalSymbol; // The symbol representing this identifier, before alias resolution static TypeIdentifier *create(Loc loc, Identifier *ident); const char *kind() override; diff --git a/gcc/d/dmd/parse.d b/gcc/d/dmd/parse.d index 121f9900f2e..33e0e5a1131 100644 --- a/gcc/d/dmd/parse.d +++ b/gcc/d/dmd/parse.d @@ -1041,6 +1041,30 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer nextToken(); continue; + // The following are all errors, the cases are just for better error messages than the default case + case TOK.return_: + case TOK.goto_: + case TOK.break_: + case TOK.continue_: + error("`%s` statement must be inside function scope", token.toChars()); + goto Lerror; + case TOK.asm_: + case TOK.do_: + case TOK.for_: + case TOK.foreach_: + case TOK.foreach_reverse_: + case TOK.if_: + case TOK.switch_: + case TOK.try_: + case TOK.while_: + error("`%s` statement must be inside function scope", token.toChars()); + if (peekNext() == TOK.leftParenthesis || peekNext() == TOK.leftCurly) + { + parseStatement(0); + s = null; + continue; + } + goto Lerror; default: error("declaration expected, not `%s`", token.toChars()); Lerror: @@ -1504,28 +1528,26 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (token.value != TOK.identifier) { error("identifier expected following `template`"); - goto Lerr; + return null; } id = token.ident; nextToken(); tpl = parseTemplateParameterList(); if (!tpl) - goto Lerr; + return null; constraint = parseConstraint(); if (token.value != TOK.leftCurly) { error("`{` expected after template parameter list, not `%s`", token.toChars()); /* } */ - goto Lerr; + nextToken(); + return null; } decldefs = parseBlock(null); tempdecl = new AST.TemplateDeclaration(loc, id, tpl, constraint, decldefs, ismixin); return tempdecl; - - Lerr: - return null; } /****************************************** @@ -4509,7 +4531,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer if (ident) checkCstyleTypeSyntax(loc, t, alt, ident); else if (!isThis && (t != AST.Type.terror)) - noIdentifierForDeclarator(t); + noIdentifierForDeclarator(t, token); if (isAliasDeclaration) { @@ -4571,6 +4593,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer default: error("semicolon expected to close `alias` declaration, not `%s`", token.toChars()); + nextToken(); break; } } @@ -4734,11 +4757,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer return a; } - /// Report an error that a declaration of type `t` is missing an identifier + /// Report an error that a declaration of type `t` is missing an identifier and got `tok` instead /// The parser is expected to sit on the next token after the type. - private void noIdentifierForDeclarator(AST.Type t) + private void noIdentifierForDeclarator(AST.Type t, Token tok) { - error("no identifier for declarator `%s`", t.toChars()); + error("variable name expected after type `%s`, not `%s`", t.toChars(), tok.toChars); + // A common mistake is to use a reserved keyword as an identifier, e.g. `in` or `out` if (token.isKeyword) { @@ -5016,6 +5040,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer default: error("semicolon expected to close `alias` declaration, not `%s`", token.toChars()); + nextToken(); break; } break; @@ -5356,9 +5381,14 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer error("template constraint must follow parameter lists and attributes"); else error("cannot use function constraints for non-template functions. Use `static if` instead"); + + parseConstraint(); } else + { error("semicolon expected following function declaration, not `%s`", token.toChars()); + nextToken(); + } } break; } @@ -5542,7 +5572,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer } at = parseType(&ai); if (!ai) - noIdentifierForDeclarator(at); + noIdentifierForDeclarator(at, token); Larg: auto p = new AST.Parameter(aloc, storageClass, at, ai, null, null); parameters.push(p); diff --git a/gcc/d/dmd/root/string.d b/gcc/d/dmd/root/string.d index 847af0eab61..be606c41f7d 100644 --- a/gcc/d/dmd/root/string.d +++ b/gcc/d/dmd/root/string.d @@ -377,9 +377,9 @@ auto splitLines(const char[] text) public const(char)[] front() { advance(); - if (index > eolIndex || index >= text.length) { + if (index > eolIndex || index >= text.length) return ""; - } + return text[index .. eolIndex]; } diff --git a/gcc/d/dmd/semantic2.d b/gcc/d/dmd/semantic2.d index 31fc418dbcc..893dc1b9d7b 100644 --- a/gcc/d/dmd/semantic2.d +++ b/gcc/d/dmd/semantic2.d @@ -852,6 +852,8 @@ private extern(C++) final class StaticAAVisitor : SemanticTimeTransitiveVisitor loweredExp = loweredExp.ctfeInterpret(); aaExp.lowering = loweredExp; + + semanticTypeInfo(sc, loweredExp.type); } // https://issues.dlang.org/show_bug.cgi?id=24602 diff --git a/gcc/d/dmd/semantic3.d b/gcc/d/dmd/semantic3.d index 5d7f8bc3282..f7a7ce150b3 100644 --- a/gcc/d/dmd/semantic3.d +++ b/gcc/d/dmd/semantic3.d @@ -380,7 +380,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (!sc.intypeof) { if (fld.tok == TOK.delegate_) - .error(funcdecl.loc, "%s `%s` cannot be %s members", funcdecl.kind, funcdecl.toPrettyChars, ad.kind()); + .error(funcdecl.loc, "%s `%s` cannot be %s members", funcdecl.kind, funcdecl.toErrMsg, ad.kind()); else fld.tok = TOK.function_; } @@ -933,7 +933,37 @@ private extern(C++) final class Semantic3Visitor : Visitor // if a copy constructor is present, the return type conversion will be handled by it const hasCopyCtor = exp.type.ty == Tstruct && (cast(TypeStruct)exp.type).sym.hasCopyCtor; if (!hasCopyCtor || !exp.isLvalue()) - exp = exp.implicitCastTo(sc2, tret); + { + const errors = global.startGagging(); + auto implicitlyCastedExp = exp.implicitCastTo(sc2, tret); + global.endGagging(errors); + + // + if (implicitlyCastedExp.isErrorExp()) + { + auto types = toAutoQualChars(exp.type, tret); + error( + exp.loc, + "return value `%s` of type `%s` does not match return type `%s`" + ~ ", and cannot be implicitly converted", + exp.toErrMsg(), + types[0], + types[1], + ); + + if (const func = exp.type.isFunction_Delegate_PtrToFunction()) + if (func.next.equals(tret)) + errorSupplemental( + exp.loc, + "Did you intend to call the %s?", + (exp.type.isPtrToFunction()) + ? "function pointer" + : exp.type.kind + ); + } + + exp = implicitlyCastedExp; + } exp = exp.optimize(WANTvalue); @@ -1375,7 +1405,7 @@ private extern(C++) final class Semantic3Visitor : Visitor } if (isCppNonMappableType(f.next.toBasetype())) { - .error(funcdecl.loc, "%s `%s` cannot return type `%s` because its linkage is `extern(C++)`", funcdecl.kind, funcdecl.toPrettyChars, f.next.toChars()); + .error(funcdecl.loc, "%s `%s` cannot return type `%s` because its linkage is `extern(C++)`", funcdecl.kind, funcdecl.toErrMsg(), f.next.toChars()); if (f.next.isTypeDArray()) errorSupplemental(funcdecl.loc, "slices are specific to D and do not have a counterpart representation in C++", f.next.toChars()); funcdecl.errors = true; @@ -1384,7 +1414,7 @@ private extern(C++) final class Semantic3Visitor : Visitor { if (isCppNonMappableType(param.type.toBasetype(), param)) { - .error(funcdecl.loc, "%s `%s` cannot have parameter of type `%s` because its linkage is `extern(C++)`", funcdecl.kind, funcdecl.toPrettyChars, param.type.toChars()); + .error(funcdecl.loc, "%s `%s` cannot have parameter of type `%s` because its linkage is `extern(C++)`", funcdecl.kind, funcdecl.toErrMsg(), param.type.toChars()); if (param.type.toBasetype().isTypeSArray()) errorSupplemental(funcdecl.loc, "perhaps use a `%s*` type instead", param.type.nextOf().mutableOf().unSharedOf().toChars()); @@ -1741,7 +1771,7 @@ extern (D) bool checkClosure(FuncDeclaration fd) } a.push(f); .errorSupplemental(f.loc, "%s `%s` closes over variable `%s`", - f.kind, f.toPrettyChars(), v.toChars()); + f.kind, f.toErrMsg(), v.toChars()); if (v.ident != Id.This) .errorSupplemental(v.loc, "`%s` declared here", v.toChars()); diff --git a/gcc/d/dmd/sideeffect.d b/gcc/d/dmd/sideeffect.d index 84b9e4e6530..659b0f4e0a5 100644 --- a/gcc/d/dmd/sideeffect.d +++ b/gcc/d/dmd/sideeffect.d @@ -20,6 +20,7 @@ import dmd.expressionsem; import dmd.func; import dmd.funcsem; import dmd.globals; +import dmd.hdrgen; import dmd.id; import dmd.identifier; import dmd.init; @@ -346,12 +347,13 @@ bool discardValue(Expression e) BinExp tmp = e.isBinExp(); assert(tmp); - error(e.loc, "the result of the equality expression `%s` is discarded", e.toChars()); + error(e.loc, "the result of the equality expression `%s` is discarded", e.toErrMsg()); bool seenSideEffect = false; foreach(expr; [tmp.e1, tmp.e2]) { - if (hasSideEffect(expr)) { - errorSupplemental(expr.loc, "note that `%s` may have a side effect", expr.toChars()); + if (hasSideEffect(expr)) + { + errorSupplemental(expr.loc, "note that `%s` may have a side effect", expr.toErrMsg()); seenSideEffect |= true; } } @@ -359,7 +361,7 @@ bool discardValue(Expression e) default: break; } - error(e.loc, "`%s` has no effect", e.toChars()); + error(e.loc, "`%s` has no effect", e.toErrMsg()); return true; } diff --git a/gcc/d/dmd/statementsem.d b/gcc/d/dmd/statementsem.d index 6a3bc38adce..4029fdac38a 100644 --- a/gcc/d/dmd/statementsem.d +++ b/gcc/d/dmd/statementsem.d @@ -664,7 +664,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) const olderrors = global.startGagging(); discardValue(fs.increment); if (global.endGagging(olderrors)) - deprecation(fs.increment.loc, "`%s` has no effect", fs.increment.toChars()); + deprecation(fs.increment.loc, "`%s` has no effect", fs.increment.toErrMsg()); if (checkNonAssignmentArrayOp(fs.increment)) fs.increment = ErrorExp.get(); fs.increment = fs.increment.optimize(WANTvalue); @@ -2604,7 +2604,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc) //errors = true; } if (global.endGagging(olderrors)) - deprecation(rs.exp.loc, "`%s` has no effect", rs.exp.toChars()); + deprecation(rs.exp.loc, "`%s` has no effect", rs.exp.toErrMsg()); /* Replace: * return exp; diff --git a/gcc/d/dmd/tokens.d b/gcc/d/dmd/tokens.d index e82a582bee3..aad88d6bcab 100644 --- a/gcc/d/dmd/tokens.d +++ b/gcc/d/dmd/tokens.d @@ -436,8 +436,10 @@ enum FirstCKeyword = TOK.inline; // Assert that all token enum members have consecutive values and // that none of them overlap static assert(() { - foreach (idx, enumName; __traits(allMembers, TOK)) { - static if (idx != __traits(getMember, TOK, enumName)) { + foreach (idx, enumName; __traits(allMembers, TOK)) + { + static if (idx != __traits(getMember, TOK, enumName)) + { pragma(msg, "Error: Expected TOK.", enumName, " to be ", idx, " but is ", __traits(getMember, TOK, enumName)); static assert(0); } @@ -925,13 +927,18 @@ nothrow: return 0; } - extern(D) void appendInterpolatedPart(const ref OutBuffer buf) { + extern(D) void appendInterpolatedPart(const ref OutBuffer buf) + { appendInterpolatedPart(cast(const(char)*)buf[].ptr, buf.length); } - extern(D) void appendInterpolatedPart(const(char)[] str) { + + extern(D) void appendInterpolatedPart(const(char)[] str) + { appendInterpolatedPart(str.ptr, str.length); } - extern(D) void appendInterpolatedPart(const(char)* ptr, size_t length) { + + extern(D) void appendInterpolatedPart(const(char)* ptr, size_t length) + { assert(value == TOK.interpolated); if (interpolatedSet is null) interpolatedSet = new InterpolatedSet; diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d index ae52de554dc..7f87ac4d731 100644 --- a/gcc/d/dmd/typesem.d +++ b/gcc/d/dmd/typesem.d @@ -1187,7 +1187,7 @@ private const(char)* getParamError(TypeFunction tf, Expression arg, Parameter pa // only mention rvalue if it's relevant const rv = !arg.isLvalue() && par.isReference(); buf.printf("cannot pass %sargument `%s` of type `%s` to parameter `%s`", - rv ? "rvalue ".ptr : "".ptr, arg.toChars(), at, + rv ? "rvalue ".ptr : "".ptr, arg.toErrMsg(), at, parameterToChars(par, tf, qual)); return buf.extractChars(); } @@ -2329,7 +2329,7 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) { const(char)* errTxt = fparam.storageClass & STC.ref_ ? "ref" : "out"; .error(e.loc, "expression `%s` of type `%s` is not implicitly convertible to type `%s %s` of parameter `%s`", - e.toChars(), e.type.toChars(), errTxt, fparam.type.toChars(), fparam.toChars()); + e.toErrMsg(), e.type.toChars(), errTxt, fparam.type.toChars(), fparam.toChars()); } e = e.implicitCastTo(sc, fparam.type); @@ -2493,10 +2493,17 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) errors = true; } - const bool isTypesafeVariadic = i + 1 == dim && - tf.parameterList.varargs == VarArg.typesafe && - (t.isTypeDArray() || t.isTypeClass()); - if (isTypesafeVariadic) + const bool isTypesafeVariadic = i + 1 == dim && tf.parameterList.varargs == VarArg.typesafe; + const bool isStackAllocatedVariadic = isTypesafeVariadic && (t.isTypeDArray() || t.isTypeClass()); + + if (isTypesafeVariadic && t.isTypeClass()) + { + // Deprecated in 2.111, kept as a legacy feature for compatibility (currently no plan to turn it into an error) + .deprecation(loc, "typesafe variadic parameters with a `class` type (`%s %s...`) are deprecated", + t.isTypeClass().sym.ident.toChars(), fparam.toChars()); + } + + if (isStackAllocatedVariadic) { /* typesafe variadic arguments are constructed on the stack, so must be `scope` */ @@ -2518,7 +2525,7 @@ Type typeSemantic(Type type, Loc loc, Scope* sc) } } - if (isTypesafeVariadic) + if (isStackAllocatedVariadic) { /* This is because they can be constructed on the stack * https://dlang.org/spec/function.html#typesafe_variadic_functions @@ -3454,10 +3461,26 @@ Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int fla { if (auto sym = dsym.isAggregateDeclaration()) { - if (auto fd = search_function(sym, Id.opDispatch)) - errorSupplemental(loc, "potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message"); - else if (!sym.members) + if (!sym.members) + { errorSupplemental(sym.loc, "`%s %s` is opaque and has no members.", sym.kind, mt.toPrettyChars(true)); + return ErrorExp.get(); + } + + if (auto fd = search_function(sym, Id.opDispatch)) + { + if (auto td = fd.isTemplateDeclaration()) + { + e = mt.defaultInitLiteral(loc); + auto se = new StringExp(e.loc, ident.toString()); + auto tiargs = new Objects(); + tiargs.push(se); + auto dti = new DotTemplateInstanceExp(e.loc, e, Id.opDispatch, tiargs); + dti.ti.tempdecl = td; + dti.dotTemplateSemanticProp(scope_, DotExpFlag.none); + return ErrorExp.get(); + } + } } errorSupplemental(dsym.loc, "%s `%s` defined here", dsym.kind, dsym.toChars()); @@ -4731,7 +4754,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag { if (e.op == EXP.type) { - error(e.loc, "`%s` is not an expression", e.toChars()); + error(e.loc, "`%s` is not an expression", e.toErrMsg()); return ErrorExp.get(); } else if (mt.dim.toUInteger() < 1 && checkUnsafeDotExp(sc, e, ident, flag)) @@ -4780,7 +4803,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag } if (e.op == EXP.type && (ident == Id.length || ident == Id.ptr)) { - error(e.loc, "`%s` is not an expression", e.toChars()); + error(e.loc, "`%s` is not an expression", e.toErrMsg()); return ErrorExp.get(); } if (ident == Id.length) @@ -5207,7 +5230,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag Declaration d = s.isDeclaration(); if (!d) { - error(e.loc, "`%s.%s` is not a declaration", e.toChars(), ident.toChars()); + error(e.loc, "`%s.%s` is not a declaration", e.toErrMsg(), ident.toChars()); return ErrorExp.get(); } @@ -5640,7 +5663,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag Declaration d = s.isDeclaration(); if (!d) { - error(e.loc, "`%s.%s` is not a declaration", e.toChars(), ident.toChars()); + error(e.loc, "`%s.%s` is not a declaration", e.toErrMsg(), ident.toChars()); return ErrorExp.get(); } @@ -6715,30 +6738,32 @@ Type pointerTo(Type type) { if (type.ty == Terror) return type; - if (!type.pto) + auto mcache = type.getMcache(); + if (!mcache.pto) { Type t = new TypePointer(type); if (type.ty == Tfunction) { t.deco = t.merge().deco; - type.pto = t; + mcache.pto = t; } else - type.pto = t.merge(); + mcache.pto = t.merge(); } - return type.pto; + return mcache.pto; } Type referenceTo(Type type) { if (type.ty == Terror) return type; - if (!type.rto) + auto mcache = type.getMcache(); + if (!mcache.rto) { Type t = new TypeReference(type); - type.rto = t.merge(); + mcache.rto = t.merge(); } - return type.rto; + return mcache.rto; } // Make corresponding static array type without semantic @@ -6756,12 +6781,13 @@ Type arrayOf(Type type) { if (type.ty == Terror) return type; - if (!type.arrayof) + auto mcache = type.getMcache(); + if (!mcache.arrayof) { Type t = new TypeDArray(type); - type.arrayof = t.merge(); + mcache.arrayof = t.merge(); } - return type.arrayof; + return mcache.arrayof; } /******************************** @@ -7013,6 +7039,39 @@ Type sharedWildConstOf(Type type) return t; } +Type nakedOf(Type type) +{ + //printf("Type::nakedOf() %p, %s\n", type, type.toChars()); + if (type.mod == 0) + return type; + if (type.mcache) with(type.mcache) + { + // the cache has the naked type at the "identity" position, try to find it + if (cto && cto.mod == 0) + return cto; + if (ito && ito.mod == 0) + return ito; + if (sto && sto.mod == 0) + return sto; + if (scto && scto.mod == 0) + return scto; + if (wto && wto.mod == 0) + return wto; + if (wcto && wcto.mod == 0) + return wcto; + if (swto && swto.mod == 0) + return swto; + if (swcto && swcto.mod == 0) + return swcto; + } + Type t = type.nullAttributes(); + t.mod = 0; + t = t.merge(); + t.fixTo(type); + //printf("\t%p %s\n", t, t.toChars()); + return t; +} + Type unqualify(Type type, uint m) { Type t = type.mutableOf().unSharedOf(); diff --git a/gcc/d/dmd/typinf.d b/gcc/d/dmd/typinf.d index 58102cda36f..1a96823dadc 100644 --- a/gcc/d/dmd/typinf.d +++ b/gcc/d/dmd/typinf.d @@ -22,6 +22,7 @@ import dmd.expression; import dmd.globals; import dmd.location; import dmd.mtype; +import dmd.typesem; import core.stdc.stdio; /**************************************************** @@ -67,6 +68,9 @@ bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc) import dmd.typesem : merge2; Type t = torig.merge2(); // do this since not all Type's are merge'd + if (t.ty == Taarray) + t = makeNakedAssociativeArray(cast(TypeAArray)t); + bool needsCodegen = false; if (!t.vtinfo) { @@ -79,7 +83,7 @@ bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc) else if (t.isWild()) t.vtinfo = TypeInfoWildDeclaration.create(t); else - t.vtinfo = getTypeInfoDeclaration(t); + t.vtinfo = getTypeInfoDeclaration(t, sc); assert(t.vtinfo); // ClassInfos are generated as part of ClassDeclaration codegen @@ -105,7 +109,7 @@ bool genTypeInfo(Expression e, Loc loc, Type torig, Scope* sc) */ extern (C++) Type getTypeInfoType(Loc loc, Type t, Scope* sc); -private TypeInfoDeclaration getTypeInfoDeclaration(Type t) +private TypeInfoDeclaration getTypeInfoDeclaration(Type t, Scope* sc) { //printf("Type::getTypeInfoDeclaration() %s\n", t.toChars()); switch (t.ty) @@ -117,7 +121,7 @@ private TypeInfoDeclaration getTypeInfoDeclaration(Type t) case Tsarray: return TypeInfoStaticArrayDeclaration.create(t); case Taarray: - return TypeInfoAssociativeArrayDeclaration.create(t); + return getTypeInfoAssocArrayDeclaration(cast(TypeAArray)t, sc); case Tstruct: return TypeInfoStructDeclaration.create(t); case Tvector: @@ -141,6 +145,70 @@ private TypeInfoDeclaration getTypeInfoDeclaration(Type t) } } +/****************************************** + * Instantiate TypeInfoAssociativeArrayDeclaration and fill + * the entry with TypeInfo_AssociativeArray.Entry!(t.index, t.next) + * + * Params: + * t = TypeAArray to generate TypeInfo_AssociativeArray for + * sc = context + * Returns: + * a TypeInfoAssociativeArrayDeclaration with field entry initialized + */ +TypeInfoDeclaration getTypeInfoAssocArrayDeclaration(TypeAArray t, Scope* sc) +{ + import dmd.arraytypes; + import dmd.expressionsem; + import dmd.id; + + assert(sc); // must not be called in the code generation phase + + auto ti = TypeInfoAssociativeArrayDeclaration.create(t); + t.vtinfo = ti; // assign it early to avoid recursion in expressionSemantic + Loc loc = t.loc; + auto tiargs = new Objects(); + tiargs.push(t.index); // always called with naked types + tiargs.push(t.next); + + Expression id = new IdentifierExp(loc, Id.empty); + id = new DotIdExp(loc, id, Id.object); + id = new DotIdExp(loc, id, Id.TypeInfo_AssociativeArray); + auto tempinst = new DotTemplateInstanceExp(loc, id, Id.Entry, tiargs); + auto e = expressionSemantic(tempinst, sc); + assert(e.type); + ti.entry = e.type; + if (auto ts = ti.entry.isTypeStruct()) + { + ts.sym.requestTypeInfo = true; + if (auto tmpl = ts.sym.isInstantiated()) + tmpl.minst = sc._module.importedFrom; // ensure it get's emitted + } + getTypeInfoType(loc, ti.entry, sc); + assert(ti.entry.vtinfo); + + return ti; +} + +/****************************************** + * Find or create a TypeAArray with index and next without + * any head modifiers, tail `inout` is replaced with `const` + * + * Params: + * t = TypeAArray to convert + * Returns: + * t = found type + */ +Type makeNakedAssociativeArray(TypeAArray t) +{ + Type tindex = t.index.toBasetype().nakedOf().substWildTo(MODFlags.const_); + Type tnext = t.next.toBasetype().nakedOf().substWildTo(MODFlags.const_); + if (tindex == t.index && tnext == t.next) + return t; + + t = new TypeAArray(tnext, tindex); + return t.merge(); +} + /************************************************** * Returns: * true if any part of type t is speculative. diff --git a/gcc/d/dmd/typinf.h b/gcc/d/dmd/typinf.h index 4a8c9427524..e4161919112 100644 --- a/gcc/d/dmd/typinf.h +++ b/gcc/d/dmd/typinf.h @@ -14,6 +14,8 @@ class Expression; class Type; +class TypeAArray; +class TypeInfoDeclaration; struct Scope; namespace dmd @@ -21,5 +23,7 @@ namespace dmd bool genTypeInfo(Expression *e, Loc loc, Type *torig, Scope *sc); bool isSpeculativeType(Type *t); bool builtinTypeInfo(Type *t); + Type *makeNakedAssociativeArray(TypeAArray *t); + TypeInfoDeclaration *getTypeInfoAssocArrayDeclaration(TypeAArray *t, Scope *sc); } Type *getTypeInfoType(Loc loc, Type *t, Scope *sc); diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc index f548451c8ba..e81b2f0157f 100644 --- a/gcc/d/typeinfo.cc +++ b/gcc/d/typeinfo.cc @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "dmd/scope.h" #include "dmd/template.h" #include "dmd/target.h" +#include "dmd/typinf.h" #include "tree.h" #include "fold-const.h" @@ -728,7 +729,8 @@ public: void **__vptr; void *__monitor; TypeInfo value; - TypeInfo key; */ + TypeInfo key; + TypeInfo entry; */ void visit (TypeInfoAssociativeArrayDeclaration *d) final override { @@ -742,6 +744,12 @@ public: /* TypeInfo for index of type. */ this->layout_field (build_typeinfo (d->loc, ti->index)); + + /* TypeInfo for the key/value pair. */ + if (d->entry != NULL) + this->layout_field (build_typeinfo (d->loc, d->entry)); + else + this->layout_field (null_pointer_node); } /* Layout of TypeInfo_Vector is: @@ -1550,7 +1558,7 @@ get_cpp_typeinfo_decl (ClassDeclaration *decl) /* Get the exact TypeInfo for TYPE, if it doesn't exist, create it. */ void -create_typeinfo (Type *type, Module *mod) +create_typeinfo (Type *type, Scope *sc) { if (!Type::dtypeinfo) create_frontend_tinfo_types (); @@ -1559,6 +1567,9 @@ create_typeinfo (Type *type, Module *mod) Type *t = dmd::merge2 (type); Identifier *ident; + if (TypeAArray *ta = t->isTypeAArray ()) + t = dmd::makeNakedAssociativeArray (ta); + if (!t->vtinfo) { tinfo_kind tk = get_typeinfo_kind (t); @@ -1636,9 +1647,11 @@ create_typeinfo (Type *type, Module *mod) { ident = Identifier::idPool ("TypeInfo_AssociativeArray"); make_internal_typeinfo (tk, ident, ptr_type_node, ptr_type_node, - NULL); + ptr_type_node, NULL); } - t->vtinfo = TypeInfoAssociativeArrayDeclaration::create (t); + t->vtinfo = sc && have_typeinfo_p (Type::typeinfoassociativearray) + ? dmd::getTypeInfoAssocArrayDeclaration (t->isTypeAArray (), sc) + : TypeInfoAssociativeArrayDeclaration::create (t); break; case TK_STRUCT_TYPE: @@ -1711,6 +1724,7 @@ create_typeinfo (Type *type, Module *mod) if (!builtin_typeinfo_p (t)) { /* Find module that will go all the way to an object file. */ + Module *mod = sc ? sc->_module->importedFrom : NULL; if (mod) mod->members->push (t->vtinfo); else @@ -1724,113 +1738,4 @@ create_typeinfo (Type *type, Module *mod) gcc_assert (type->vtinfo != NULL); } -/* Implements a visitor interface to check whether a type is speculative. - TypeInfo_Struct would reference the members of the struct it is representing - (e.g: opEquals via xopEquals field), so if it's instantiated in speculative - context, TypeInfo creation should also be stopped to avoid possible - `unresolved symbol' linker errors. */ - -class SpeculativeTypeVisitor : public Visitor -{ - using Visitor::visit; - - bool result_; - -public: - SpeculativeTypeVisitor (void) - { - this->result_ = false; - } - - bool result (void) - { - return this->result_; - } - - void visit (Type *t) final override - { - Type *tb = t->toBasetype (); - if (tb != t) - tb->accept (this); - } - - void visit (TypeNext *t) final override - { - if (t->next) - t->next->accept (this); - } - - void visit (TypeBasic *) final override - { - } - - void visit (TypeVector *t) final override - { - t->basetype->accept (this); - } - - void visit (TypeAArray *t) final override - { - t->index->accept (this); - visit ((TypeNext *) t); - } - - void visit (TypeFunction *t) final override - { - visit ((TypeNext *) t); - } - - void visit (TypeStruct *t) final override - { - StructDeclaration *sd = t->sym; - if (TemplateInstance *ti = sd->isInstantiated ()) - { - if (!ti->needsCodegen ()) - { - if (ti->minst || sd->requestTypeInfo ()) - return; - - this->result_ |= true; - } - } - } - - void visit (TypeClass *t) final override - { - ClassDeclaration *cd = t->sym; - if (TemplateInstance *ti = cd->isInstantiated ()) - { - if (!ti->needsCodegen () && !ti->minst) - { - this->result_ |= true; - } - } - } - - void visit (TypeTuple *t) final override - { - if (!t->arguments) - return; - - for (size_t i = 0; i < t->arguments->length; i++) - { - Type *tprm = (*t->arguments)[i]->type; - if (tprm) - tprm->accept (this); - if (this->result_) - return; - } - } -}; - -/* Return true if type was instantiated in a speculative context. */ - -bool -speculative_type_p (Type *t) -{ - SpeculativeTypeVisitor v = SpeculativeTypeVisitor (); - t->accept (&v); - return v.result (); -} - #include "gt-d-typeinfo.h" diff --git a/gcc/testsuite/gdc.dg/pr100967.d b/gcc/testsuite/gdc.dg/pr100967.d index bb83c299ced..3861a37899c 100644 --- a/gcc/testsuite/gdc.dg/pr100967.d +++ b/gcc/testsuite/gdc.dg/pr100967.d @@ -5,7 +5,7 @@ module object; extern(C) int main() { - int[int] aa; + int[int] aa; // { dg-error ".object.TypeInfo. could not be found" } aa[0] = 1; // { dg-error ".object.TypeInfo. could not be found, but is implicitly used" } return 0; } diff --git a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d index 18d1f3604d5..2a3cfee3372 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d +++ b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic.d @@ -2,8 +2,8 @@ TEST_OUTPUT: --- fail_compilation/attributediagnostic.d(21): Error: `@safe` function `attributediagnostic.layer2` cannot call `@system` function `attributediagnostic.layer1` -fail_compilation/attributediagnostic.d(23): which calls `attributediagnostic.layer0` -fail_compilation/attributediagnostic.d(25): which calls `attributediagnostic.system` +fail_compilation/attributediagnostic.d(23): which calls `layer0` +fail_compilation/attributediagnostic.d(25): which calls `system` fail_compilation/attributediagnostic.d(27): and executing an `asm` statement without `@trusted` annotation makes it fail to infer `@safe` fail_compilation/attributediagnostic.d(22): `attributediagnostic.layer1` is declared here fail_compilation/attributediagnostic.d(43): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system1` diff --git a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nogc.d b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nogc.d index 9069ecc4788..f54a4e91d94 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nogc.d +++ b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nogc.d @@ -2,8 +2,8 @@ TEST_OUTPUT: --- fail_compilation/attributediagnostic_nogc.d(21): Error: `@nogc` function `attributediagnostic_nogc.layer2` cannot call non-@nogc function `attributediagnostic_nogc.layer1` -fail_compilation/attributediagnostic_nogc.d(22): which calls `attributediagnostic_nogc.layer0` -fail_compilation/attributediagnostic_nogc.d(23): which calls `attributediagnostic_nogc.gc` +fail_compilation/attributediagnostic_nogc.d(22): which calls `layer0` +fail_compilation/attributediagnostic_nogc.d(23): which calls `gc` fail_compilation/attributediagnostic_nogc.d(27): and executing an `asm` statement without `@nogc` annotation makes it fail to infer `@nogc` fail_compilation/attributediagnostic_nogc.d(43): Error: `@nogc` function `D main` cannot call non-@nogc function `attributediagnostic_nogc.gc1` fail_compilation/attributediagnostic_nogc.d(32): and allocating with `new` makes it fail to infer `@nogc` diff --git a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nothrow.d b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nothrow.d index add5ccc05a6..3b5c17a0aa5 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nothrow.d +++ b/gcc/testsuite/gdc.test/fail_compilation/attributediagnostic_nothrow.d @@ -2,8 +2,8 @@ TEST_OUTPUT: --- fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer1` is not `nothrow` -fail_compilation/attributediagnostic_nothrow.d(20): which calls `attributediagnostic_nothrow.layer0` -fail_compilation/attributediagnostic_nothrow.d(21): which calls `attributediagnostic_nothrow.gc` +fail_compilation/attributediagnostic_nothrow.d(20): which calls `layer0` +fail_compilation/attributediagnostic_nothrow.d(21): which calls `gc` fail_compilation/attributediagnostic_nothrow.d(25): and executing an `asm` statement without a `nothrow` annotation makes it fail to infer `nothrow` fail_compilation/attributediagnostic_nothrow.d(19): Error: function `attributediagnostic_nothrow.layer2` may throw but is marked as `nothrow` fail_compilation/attributediagnostic_nothrow.d(41): Error: function `attributediagnostic_nothrow.gc1` is not `nothrow` diff --git a/gcc/testsuite/gdc.test/fail_compilation/b19523.d b/gcc/testsuite/gdc.test/fail_compilation/b19523.d index 3b2a5e0f224..5ab491faeaa 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/b19523.d +++ b/gcc/testsuite/gdc.test/fail_compilation/b19523.d @@ -3,7 +3,7 @@ TEST_OUTPUT: ---- fail_compilation/b19523.d(13): Error: undefined identifier `SomeStruct` fail_compilation/b19523.d(14): Error: function `foo` is not callable using argument types `(_error_)` -fail_compilation/b19523.d(14): cannot pass argument `__lambda_L14_C6` of type `_error_` to parameter `int delegate() arg` +fail_compilation/b19523.d(14): cannot pass argument `__error` of type `_error_` to parameter `int delegate() arg` fail_compilation/b19523.d(19): `b19523.foo(int delegate() arg)` declared here ---- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d index 574b29aae38..157a07584e1 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/bug9631.d +++ b/gcc/testsuite/gdc.test/fail_compilation/bug9631.d @@ -65,7 +65,7 @@ TEST_OUTPUT: fail_compilation/bug9631.d(80): Error: function `f` is not callable using argument types `(int, S)` fail_compilation/bug9631.d(80): cannot pass argument `y` of type `bug9631.tem!().S` to parameter `bug9631.S s` fail_compilation/bug9631.d(79): `bug9631.arg.f(int i, S s)` declared here -fail_compilation/bug9631.d(81): Error: function literal `__lambda_L81_C5(S s)` is not callable using argument types `(S)` +fail_compilation/bug9631.d(81): Error: function literal `(S s) { }` is not callable using argument types `(S)` fail_compilation/bug9631.d(81): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S s` fail_compilation/bug9631.d(87): Error: constructor `bug9631.arg.A.this(S __param_0)` is not callable using argument types `(S)` fail_compilation/bug9631.d(87): cannot pass argument `S(0)` of type `bug9631.tem!().S` to parameter `bug9631.S __param_0` diff --git a/gcc/testsuite/gdc.test/fail_compilation/code_global_scope.d b/gcc/testsuite/gdc.test/fail_compilation/code_global_scope.d new file mode 100644 index 00000000000..4db84c02e78 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/code_global_scope.d @@ -0,0 +1,26 @@ +/** +TEST_OUTPUT: +--- +fail_compilation/code_global_scope.d(18): Error: `switch` statement must be inside function scope +fail_compilation/code_global_scope.d(19): Error: `do` statement must be inside function scope +fail_compilation/code_global_scope.d(20): Error: `foreach` statement must be inside function scope +fail_compilation/code_global_scope.d(21): Error: `while` statement must be inside function scope +fail_compilation/code_global_scope.d(22): Error: `if` statement must be inside function scope +fail_compilation/code_global_scope.d(23): Error: `return` statement must be inside function scope +fail_compilation/code_global_scope.d(24): Error: `goto` statement must be inside function scope +fail_compilation/code_global_scope.d(25): Error: `continue` statement must be inside function scope +fail_compilation/code_global_scope.d(26): Error: `break` statement must be inside function scope +--- +*/ + + + +switch s; +do d; +foreach (i; 0 .. 4) {} +while (x) {} +if (y) {} +return 0; +goto A; +continue B; +break; diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_defs.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_defs.d index b3a335b4e24..2a9aff6dcd4 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/constraints_defs.d +++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_defs.d @@ -5,7 +5,7 @@ TEST_OUTPUT: fail_compilation/constraints_defs.d(49): Error: template instance `constraints_defs.main.def!(int, 0, (a) => a)` does not match template declaration `def(T, int i = 5, alias R)()` with `T = int, i = 0, - R = __lambda_L49_C18` + R = (a) => a` must satisfy the following constraint: ` N!T` fail_compilation/constraints_defs.d(50): Error: template instance `imports.constraints.defa!int` does not match template declaration `defa(T, U = int)()` diff --git a/gcc/testsuite/gdc.test/fail_compilation/constraints_tmpl.d b/gcc/testsuite/gdc.test/fail_compilation/constraints_tmpl.d index fee7a3e3e7b..1c4b97a99f8 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/constraints_tmpl.d +++ b/gcc/testsuite/gdc.test/fail_compilation/constraints_tmpl.d @@ -22,7 +22,7 @@ fail_compilation/constraints_tmpl.d(41): Error: template instance `imports.const ` N!T N!U` fail_compilation/constraints_tmpl.d(43): Error: template instance `constraints_tmpl.main.lambda!((a) => a)` does not match template declaration `lambda(alias pred)()` - with `pred = __lambda_L43_C13` + with `pred = (a) => a` must satisfy the following constraint: ` N!int` --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d b/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d index b3c89b46d2a..479e6e924d7 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d +++ b/gcc/testsuite/gdc.test/fail_compilation/cppmangle.d @@ -1,10 +1,10 @@ /* TEST_OUTPUT: --- -fail_compilation/cppmangle.d(11): Error: expected valid identifier for C++ namespace but got `` -fail_compilation/cppmangle.d(15): Error: expected valid identifier for C++ namespace but got `0num` +fail_compilation/cppmangle.d(11): Error: expected valid identifier for C++ namespace but got `""` +fail_compilation/cppmangle.d(15): Error: expected valid identifier for C++ namespace but got `"0num"` fail_compilation/cppmangle.d(19): Error: compile time string constant (or sequence) expected, not `2` -fail_compilation/cppmangle.d(23): Error: expected valid identifier for C++ namespace but got `invalid@namespace` +fail_compilation/cppmangle.d(23): Error: expected valid identifier for C++ namespace but got `"invalid@namespace"` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/cppvar.d b/gcc/testsuite/gdc.test/fail_compilation/cppvar.d index 213b54d10f5..f336e35d69c 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/cppvar.d +++ b/gcc/testsuite/gdc.test/fail_compilation/cppvar.d @@ -9,7 +9,7 @@ fail_compilation/cppvar.d(21): Error: variable `cppvar.staticVar` cannot have `e fail_compilation/cppvar.d(21): perhaps declare it as `__gshared` instead fail_compilation/cppvar.d(22): Error: variable `cppvar.sharedVar` cannot have `extern(C++)` linkage because it is `shared` fail_compilation/cppvar.d(22): perhaps declare it as `__gshared` instead -fail_compilation/cppvar.d(30): Error: delegate `cppvar.__lambda_L30_C46` cannot return type `bool[3]` because its linkage is `extern(C++)` +fail_compilation/cppvar.d(30): Error: delegate `() { bool[3] a = false; return a; }` cannot return type `bool[3]` because its linkage is `extern(C++)` --- */ #line 10 diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag12829.d b/gcc/testsuite/gdc.test/fail_compilation/diag12829.d index 0ed04d3a749..3a24180af8c 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag12829.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag12829.d @@ -2,12 +2,12 @@ TEST_OUTPUT: --- fail_compilation/diag12829.d(15): Error: function `diag12829.test1` is `@nogc` yet allocates closure for `test1()` with the GC -fail_compilation/diag12829.d(18): delegate `diag12829.test1.__lambda_L18_C33` closes over variable `x` +fail_compilation/diag12829.d(18): delegate `() { int y = x; }` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here -fail_compilation/diag12829.d(22): function `diag12829.test1.bar` closes over variable `x` +fail_compilation/diag12829.d(22): function `bar` closes over variable `x` fail_compilation/diag12829.d(17): `x` declared here fail_compilation/diag12829.d(29): Error: function `diag12829.test2` is `@nogc` yet allocates closure for `test2()` with the GC -fail_compilation/diag12829.d(34): function `diag12829.test2.S.foo` closes over variable `x` +fail_compilation/diag12829.d(34): function `foo` closes over variable `x` fail_compilation/diag12829.d(31): `x` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag14145.d b/gcc/testsuite/gdc.test/fail_compilation/diag14145.d index fee73078e30..b2044b31db3 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag14145.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag14145.d @@ -1,11 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/diag14145.d(16): Error: no property `i` for `_` of type `diag14145.main.Capture!(i)` -fail_compilation/diag14145.d(16): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message -fail_compilation/diag14145.d(26): struct `Capture` defined here -fail_compilation/diag14145.d(35): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int` -fail_compilation/diag14145.d(17): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating +fail_compilation/diag14145.d(14): Error: no property `i` for `_` of type `diag14145.main.Capture!(i)` +fail_compilation/diag14145.d(33): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int` +fail_compilation/diag14145.d(14): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag20888.d b/gcc/testsuite/gdc.test/fail_compilation/diag20888.d new file mode 100644 index 00000000000..84af42533fc --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/diag20888.d @@ -0,0 +1,71 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag20888.d(24): Error: return value `callback` of type `int function()` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(24): Did you intend to call the function pointer? +fail_compilation/diag20888.d(29): Error: return value `s` of type `string` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(34): Error: return value `callback` of type `int delegate()` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(34): Did you intend to call the delegate? +fail_compilation/diag20888.d(39): Error: return value `callback` of type `int delegate()` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(39): Did you intend to call the delegate? +fail_compilation/diag20888.d(44): Error: return value `callback` of type `int delegate()*` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(49): Error: return value `callback` of type `int delegate()` does not match return type `string`, and cannot be implicitly converted +fail_compilation/diag20888.d(54): Error: return value `() => 3755` of type `int function() pure nothrow @nogc @safe` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(54): Did you intend to call the function pointer? +fail_compilation/diag20888.d(59): Error: `return` expression expected +fail_compilation/diag20888.d(64): Error: cannot return non-void from `void` function +fail_compilation/diag20888.d(70): Error: return value `() => i` of type `int delegate() pure nothrow @nogc @safe` does not match return type `int`, and cannot be implicitly converted +fail_compilation/diag20888.d(70): Did you intend to call the delegate? +--- +*/ + +int alpha(int function() callback) +{ + return callback; +} + +int beta(string s) +{ + return s; +} + +int gamma(int delegate() callback) +{ + return callback; +} + +int delta(int delegate() callback) +{ + return callback; +} + +int epsilon(int delegate()* callback) +{ + return callback; // no supplemental yet +} + +string zeta(int delegate() callback) +{ + return callback; +} + +int eta() +{ + return () => 0xEAB; +} + +int theta() +{ + return; +} + +void iota() +{ + return 0xEAB; +} + +int kappa() +{ + int i = 0xEAB; + return () { return i; }; +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d b/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d index 0173d4b78ef..4009beadcfd 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag_funclit.d @@ -1,19 +1,19 @@ /** TEST_OUTPUT: --- -fail_compilation/diag_funclit.d(103): Error: function literal `__lambda_L103_C5(x, y, z)` is not callable using argument types `()` +fail_compilation/diag_funclit.d(103): Error: function literal `(x, y, z) { return 42; }` is not callable using argument types `()` fail_compilation/diag_funclit.d(103): too few arguments, expected 3, got 0 -fail_compilation/diag_funclit.d(106): Error: function literal `__lambda_L106_C5(x, y, z)` is not callable using argument types `(int, string, int, int)` +fail_compilation/diag_funclit.d(106): Error: `(x, y, z) { return 42; }` is not callable using argument types `(int, string, int, int)` fail_compilation/diag_funclit.d(106): too many arguments, expected 3, got 4 -fail_compilation/diag_funclit.d(108): Error: function literal `__lambda_L108_C5(x, y, string z = "Hello")` is not callable using argument types `(int, int, string, string)` +fail_compilation/diag_funclit.d(108): Error: `(x, y, string z = "Hello") { return x; }` is not callable using argument types `(int, int, string, string)` fail_compilation/diag_funclit.d(108): too many arguments, expected 3, got 4 -fail_compilation/diag_funclit.d(110): Error: function literal `__lambda_L110_C5(x, y, string z = "Hello")` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(110): Error: `(x, y, string z = "Hello") { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(110): too few arguments, expected 3, got 1 -fail_compilation/diag_funclit.d(112): Error: function literal `__lambda_L112_C5(x, y, z)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(112): Error: `(x, y, z) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(112): too few arguments, expected 3, got 1 -fail_compilation/diag_funclit.d(115): Error: function literal `__lambda_L115_C5(x, y, ...)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(115): Error: `(x, y, ...) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(115): too few arguments, expected 2, got 1 -fail_compilation/diag_funclit.d(117): Error: function literal `__lambda_L117_C5(x, y, string z = "Hey", ...)` is not callable using argument types `(int)` +fail_compilation/diag_funclit.d(117): Error: `(x, y, string z = "Hey", ...) { return x; }` is not callable using argument types `(int)` fail_compilation/diag_funclit.d(117): too few arguments, expected 3, got 1 --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag_template_alias.d b/gcc/testsuite/gdc.test/fail_compilation/diag_template_alias.d index 151bb426574..fd17852f6b5 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag_template_alias.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag_template_alias.d @@ -4,7 +4,7 @@ TEST_OUTPUT: fail_compilation/diag_template_alias.d(1): Error: identifier expected for template `alias` parameter fail_compilation/diag_template_alias.d(1): Error: found `alias` when expecting `(` fail_compilation/diag_template_alias.d(1): Error: semicolon expected following function declaration, not `(` -fail_compilation/diag_template_alias.d(1): Error: declaration expected, not `(` +fail_compilation/diag_template_alias.d(1): Error: declaration expected, not `)` --- */ #line 1 diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag_template_this.d b/gcc/testsuite/gdc.test/fail_compilation/diag_template_this.d index 25de03ce19e..d4250f77e3f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/diag_template_this.d +++ b/gcc/testsuite/gdc.test/fail_compilation/diag_template_this.d @@ -4,7 +4,7 @@ TEST_OUTPUT: fail_compilation/diag_template_this.d(1): Error: identifier expected for template `this` parameter fail_compilation/diag_template_this.d(1): Error: found `this` when expecting `(` fail_compilation/diag_template_this.d(1): Error: semicolon expected following function declaration, not `(` -fail_compilation/diag_template_this.d(1): Error: declaration expected, not `(` +fail_compilation/diag_template_this.d(1): Error: declaration expected, not `)` --- */ #line 1 diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_1.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_1.d index 0152cdee276..70b79a2449b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/e15876_1.d +++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_1.d @@ -7,11 +7,11 @@ fail_compilation/e15876_1.d(18): Error: found `End of File` instead of statement fail_compilation/e15876_1.d(18): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_1.d(17): unmatched `{` fail_compilation/e15876_1.d(18): Error: found `End of File` when expecting `]` -fail_compilation/e15876_1.d(18): Error: no identifier for declarator `o[() +fail_compilation/e15876_1.d(18): Error: variable name expected after type `o[() { scope(exit) __error__ } -]` +]`, not `End of File` --- */ o[{scope(x diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_2.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_2.d index 92164a4fd8b..c996b95e336 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/e15876_2.d +++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_2.d @@ -5,11 +5,11 @@ fail_compilation/e15876_2.d(16): Error: identifier expected following `template` fail_compilation/e15876_2.d(16): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_2.d(15): unmatched `{` fail_compilation/e15876_2.d(16): Error: found `End of File` when expecting `]` -fail_compilation/e15876_2.d(16): Error: no identifier for declarator `o[() +fail_compilation/e15876_2.d(16): Error: variable name expected after type `o[() { ; } -]` +]`, not `End of File` --- */ o[{template diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_3.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_3.d index 100c5e1ed5a..7e9d70913d2 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/e15876_3.d +++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_3.d @@ -13,7 +13,7 @@ fail_compilation/e15876_3.d(29): Error: found `End of File` instead of statement fail_compilation/e15876_3.d(29): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_3.d(28): unmatched `{` fail_compilation/e15876_3.d(29): Error: found `End of File` when expecting `)` -fail_compilation/e15876_3.d(29): Error: no identifier for declarator `d(_error_ = () +fail_compilation/e15876_3.d(29): Error: variable name expected after type `d(_error_ = () { for (__error__ __error; __error) @@ -21,7 +21,7 @@ for (__error__ __error__ } } -)` +)`, not `End of File` fail_compilation/e15876_3.d(29): Error: semicolon expected following function declaration, not `End of File` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_4.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_4.d index a9115b92dd5..76521671640 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/e15876_4.d +++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_4.d @@ -12,7 +12,7 @@ fail_compilation/e15876_4.d(27): Error: found `End of File` instead of statement fail_compilation/e15876_4.d(27): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_4.d(26): unmatched `{` fail_compilation/e15876_4.d(27): Error: found `End of File` when expecting `)` -fail_compilation/e15876_4.d(27): Error: no identifier for declarator `typeof(() +fail_compilation/e15876_4.d(27): Error: variable name expected after type `typeof(() { for (__error__ __error; __error) @@ -20,7 +20,7 @@ for (__error__ __error__ } } -)` +)`, not `End of File` --- */ typeof){for diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_5.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_5.d index 6bebc29fcb6..42183b26bd0 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/e15876_5.d +++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_5.d @@ -6,11 +6,11 @@ fail_compilation/e15876_5.d(17): Error: semicolon expected to close `alias` decl fail_compilation/e15876_5.d(17): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/e15876_5.d(16): unmatched `{` fail_compilation/e15876_5.d(17): Error: found `End of File` when expecting `]` -fail_compilation/e15876_5.d(17): Error: no identifier for declarator `p[() +fail_compilation/e15876_5.d(17): Error: variable name expected after type `p[() { alias ; } -]` +]`, not `End of File` --- */ p[{alias diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail100.d b/gcc/testsuite/gdc.test/fail_compilation/fail100.d index a8189ecb0af..0ebb9210239 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail100.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail100.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail100.d(24): Error: cannot implicitly convert expression `f` of type `Class[]` to `I[]` +fail_compilation/fail100.d(24): Error: return value `f` of type `Class[]` does not match return type `I[]`, and cannot be implicitly converted --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11125.d b/gcc/testsuite/gdc.test/fail_compilation/fail11125.d index 4349755519d..457dda83f52 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail11125.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail11125.d @@ -2,11 +2,11 @@ TEST_OUTPUT: --- fail_compilation/fail11125.d(26): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` - with `predfun = __lambda_L26_C13` + with `predfun = (int a) => a + 1` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` fail_compilation/fail11125.d(27): Error: template instance `fail11125.filter!(function (int a) pure nothrow @nogc @safe => a + 1)` does not match template declaration `filter(alias predfun)` - with `predfun = __lambda_L27_C17` + with `predfun = (int a) => a + 1` must satisfy the following constraint: ` is(ReturnType!predfun == bool)` --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11375.d b/gcc/testsuite/gdc.test/fail_compilation/fail11375.d index cabf87a6cae..26e633c27db 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail11375.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail11375.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail11375.d(18): Error: constructor `fail11375.D!().D.this` is not `nothrow` - which calls `fail11375.B.this` + which calls `this` fail_compilation/fail11375.d(16): Error: function `D main` may throw but is marked as `nothrow` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail117.d b/gcc/testsuite/gdc.test/fail_compilation/fail117.d index b0e1b120c9c..0f0c5ad6789 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail117.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail117.d @@ -1,10 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail117.d(37): Error: expression `foo.mixin MGettor!(a) geta; -` is `void` and has no value -fail_compilation/fail117.d(38): Error: expression `foo.mixin MGettor!(b) getb; -` is `void` and has no value +fail_compilation/fail117.d(35): Error: expression `foo.mixin MGettor!(a) geta;` is `void` and has no value +fail_compilation/fail117.d(36): Error: expression `foo.mixin MGettor!(b) getb;` is `void` and has no value --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11751.d b/gcc/testsuite/gdc.test/fail_compilation/fail11751.d index 36d7f9d8e30..b2d774b7544 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail11751.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail11751.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/fail11751.d(10): Error: missing exponent fail_compilation/fail11751.d(10): Error: semicolon expected following auto declaration, not `ABC` -fail_compilation/fail11751.d(10): Error: no identifier for declarator `ABC` +fail_compilation/fail11751.d(10): Error: variable name expected after type `ABC`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail13120.d b/gcc/testsuite/gdc.test/fail_compilation/fail13120.d index 1d1127c4c30..cc73b5f9ba9 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail13120.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail13120.d @@ -17,7 +17,7 @@ void g1(char[] s) pure @nogc TEST_OUTPUT: --- fail_compilation/fail13120.d(35): Error: `pure` function `fail13120.h2` cannot call impure function `fail13120.g2!().g2` -fail_compilation/fail13120.d(30): which calls `fail13120.f2` +fail_compilation/fail13120.d(30): which calls `f2` fail_compilation/fail13120.d(35): Error: `@safe` function `fail13120.h2` cannot call `@system` function `fail13120.g2!().g2` fail_compilation/fail13120.d(27): `fail13120.g2!().g2` is declared here fail_compilation/fail13120.d(35): Error: `@nogc` function `fail13120.h2` cannot call non-@nogc function `fail13120.g2!().g2` diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail13424.d b/gcc/testsuite/gdc.test/fail_compilation/fail13424.d index 1a7f16b55c5..5533e24b0ec 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail13424.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail13424.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail13424.d(12): Error: delegate `fail13424.S.__lambda_L12_C35` cannot be struct members -fail_compilation/fail13424.d(17): Error: delegate `fail13424.U.__lambda_L17_C35` cannot be union members -fail_compilation/fail13424.d(22): Error: delegate `fail13424.C.__lambda_L22_C35` cannot be class members +fail_compilation/fail13424.d(12): Error: delegate `(dchar) { }` cannot be struct members +fail_compilation/fail13424.d(17): Error: delegate `(dchar) { }` cannot be union members +fail_compilation/fail13424.d(22): Error: delegate `(dchar) { }` cannot be class members --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail13498.d b/gcc/testsuite/gdc.test/fail_compilation/fail13498.d index 27f47b3f7ab..e8099f3cd80 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail13498.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail13498.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail13498.d(11): Error: cannot implicitly convert expression `"foo"` of type `string` to `int` +fail_compilation/fail13498.d(11): Error: return value `"foo"` of type `string` does not match return type `int`, and cannot be implicitly converted fail_compilation/fail13498.d(16): Error: template instance `fail13498.foo!()` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16.d b/gcc/testsuite/gdc.test/fail_compilation/fail16.d index f462a13a585..4602d3de3bd 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail16.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail16.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/fail16.d(19): Error: function declaration without return type. (Note that constructors are always named `this`) -fail_compilation/fail16.d(19): Error: no identifier for declarator `bar!(typeof(X))(X)` +fail_compilation/fail16.d(19): Error: variable name expected after type `bar!(typeof(X))(X)`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16575.d b/gcc/testsuite/gdc.test/fail_compilation/fail16575.d index 7f6672428bf..89d63ae2798 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail16575.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail16575.d @@ -3,29 +3,29 @@ REQUIRED_ARGS: -m64 TEST_OUTPUT: --- -fail_compilation/fail16575.d(10): Error: function `fail16575.immNull` cannot have parameter of type `immutable(typeof(null))*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(11): Error: function `fail16575.shaNull` cannot have parameter of type `shared(typeof(null))*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(20): Error: function `fail16575.immNoReturn` cannot have parameter of type `immutable(noreturn)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(21): Error: function `fail16575.shaNoReturn` cannot have parameter of type `shared(noreturn)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(30): Error: function `fail16575.immBasic` cannot have parameter of type `immutable(int)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(31): Error: function `fail16575.shaBasic` cannot have parameter of type `shared(int)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(40): Error: function `fail16575.immVector` cannot have parameter of type `immutable(__vector(long[2]))*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(41): Error: function `fail16575.shaVector` cannot have parameter of type `shared(__vector(long[2]))*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(50): Error: function `fail16575.immSArray` cannot have parameter of type `immutable(long[2])` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(10): Error: function `immNull` cannot have parameter of type `immutable(typeof(null))*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(11): Error: function `shaNull` cannot have parameter of type `shared(typeof(null))*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(20): Error: function `immNoReturn` cannot have parameter of type `immutable(noreturn)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(21): Error: function `shaNoReturn` cannot have parameter of type `shared(noreturn)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(30): Error: function `immBasic` cannot have parameter of type `immutable(int)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(31): Error: function `shaBasic` cannot have parameter of type `shared(int)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(40): Error: function `immVector` cannot have parameter of type `immutable(__vector(long[2]))*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(41): Error: function `shaVector` cannot have parameter of type `shared(__vector(long[2]))*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(50): Error: function `immSArray` cannot have parameter of type `immutable(long[2])` because its linkage is `extern(C++)` fail_compilation/fail16575.d(50): perhaps use a `long*` type instead -fail_compilation/fail16575.d(51): Error: function `fail16575.shaSArray` cannot have parameter of type `shared(long[2])` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(51): Error: function `shaSArray` cannot have parameter of type `shared(long[2])` because its linkage is `extern(C++)` fail_compilation/fail16575.d(51): perhaps use a `long*` type instead -fail_compilation/fail16575.d(60): Error: function `fail16575.immPointer` cannot have parameter of type `immutable(int*)` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(61): Error: function `fail16575.shaPointer` cannot have parameter of type `shared(int*)` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(71): Error: function `fail16575.immStruct` cannot have parameter of type `immutable(SPP)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(72): Error: function `fail16575.shaStruct` cannot have parameter of type `shared(SPP)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(81): Error: function `fail16575.immClass` cannot have parameter of type `immutable(CPP)` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(82): Error: function `fail16575.shaClass` cannot have parameter of type `shared(CPP)` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(91): Error: function `fail16575.immEnum` cannot have parameter of type `immutable(EPP)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(92): Error: function `fail16575.shaEnum` cannot have parameter of type `shared(EPP)*` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(100): Error: function `fail16575.typeDArray` cannot have parameter of type `int[]` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(101): Error: function `fail16575.typeAArray` cannot have parameter of type `int[int]` because its linkage is `extern(C++)` -fail_compilation/fail16575.d(102): Error: function `fail16575.typeDelegate` cannot have parameter of type `extern (C++) int delegate()` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(60): Error: function `immPointer` cannot have parameter of type `immutable(int*)` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(61): Error: function `shaPointer` cannot have parameter of type `shared(int*)` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(71): Error: function `immStruct` cannot have parameter of type `immutable(SPP)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(72): Error: function `shaStruct` cannot have parameter of type `shared(SPP)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(81): Error: function `immClass` cannot have parameter of type `immutable(CPP)` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(82): Error: function `shaClass` cannot have parameter of type `shared(CPP)` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(91): Error: function `immEnum` cannot have parameter of type `immutable(EPP)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(92): Error: function `shaEnum` cannot have parameter of type `shared(EPP)*` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(100): Error: function `typeDArray` cannot have parameter of type `int[]` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(101): Error: function `typeAArray` cannot have parameter of type `int[int]` because its linkage is `extern(C++)` +fail_compilation/fail16575.d(102): Error: function `typeDelegate` cannot have parameter of type `extern (C++) int delegate()` because its linkage is `extern(C++)` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16689.d b/gcc/testsuite/gdc.test/fail_compilation/fail16689.d index f8e0bae50d9..30a745ec809 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail16689.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail16689.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail16689.d(3): Error: static assert: "false" -fail_compilation/fail16689.d(6): instantiated from here: `Issue16689!()` +fail_compilation/fail16689.d(6): instantiated from here: `mixin Issue16689!();` --- */ #line 1 diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail16772.d b/gcc/testsuite/gdc.test/fail_compilation/fail16772.d index 0bc97512c9a..333ee6e98b5 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail16772.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail16772.d @@ -1,7 +1,7 @@ // https://issues.dlang.org/show_bug.cgi?id=16772 /* TEST_OUTPUT: --- -fail_compilation/fail16772.d(8): Error: function `fail16772.ice16772` cannot return type `ubyte[]` because its linkage is `extern(C++)` +fail_compilation/fail16772.d(8): Error: function `ice16772` cannot return type `ubyte[]` because its linkage is `extern(C++)` fail_compilation/fail16772.d(8): slices are specific to D and do not have a counterpart representation in C++ --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17570.d b/gcc/testsuite/gdc.test/fail_compilation/fail17570.d index 9be7cd4b05f..9cb3fa0d445 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail17570.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail17570.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail17570.d(12): Error: cannot use function constraints for non-template functions. Use `static if` instead -fail_compilation/fail17570.d(12): Error: declaration expected, not `if` +fail_compilation/fail17570.d(13): Error: declaration expected, not `{` fail_compilation/fail17570.d(15): Error: `}` expected following members in `struct` declaration fail_compilation/fail17570.d(11): struct `S` starts here --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail18970.d b/gcc/testsuite/gdc.test/fail_compilation/fail18970.d index 9b1ec1d4589..d7f76afc53f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail18970.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail18970.d @@ -2,11 +2,11 @@ TEST_OUTPUT: --- fail_compilation/fail18970.d(26): Error: no property `y` for `S()` of type `fail18970.S` -fail_compilation/fail18970.d(26): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message -fail_compilation/fail18970.d(15): struct `S` defined here +fail_compilation/fail18970.d(19): Error: undefined identifier `x` +fail_compilation/fail18970.d(26): Error: template instance `fail18970.S.opDispatch!"y"` error instantiating fail_compilation/fail18970.d(33): Error: no property `yyy` for `this` of type `fail18970.S2` -fail_compilation/fail18970.d(33): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message -fail_compilation/fail18970.d(29): struct `S2` defined here +fail_compilation/fail18970.d(38): Error: undefined identifier `x` +fail_compilation/fail18970.d(33): Error: template instance `fail18970.S2.opDispatch!"yyy"` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19759.d b/gcc/testsuite/gdc.test/fail_compilation/fail19759.d index cdb65ae0c80..2c8d98b5134 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail19759.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail19759.d @@ -1,7 +1,7 @@ // https://issues.dlang.org/show_bug.cgi?id=19759 /* TEST_OUTPUT: --- -fail_compilation/fail19759.d(8): Error: function `fail19759.fail19759` cannot have parameter of type `float[4]` because its linkage is `extern(C++)` +fail_compilation/fail19759.d(8): Error: function `fail19759` cannot have parameter of type `float[4]` because its linkage is `extern(C++)` fail_compilation/fail19759.d(8): perhaps use a `float*` type instead --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail20073.d b/gcc/testsuite/gdc.test/fail_compilation/fail20073.d index 01a9ede4622..5353016d797 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail20073.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail20073.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/fail20073.d(20): Error: cannot implicitly convert expression `s` of type `S` to `string` -fail_compilation/fail20073.d(21): Error: cannot implicitly convert expression `s` of type `S` to `string` +fail_compilation/fail20073.d(21): Error: return value `s` of type `S` does not match return type `string`, and cannot be implicitly converted --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail20376.d b/gcc/testsuite/gdc.test/fail_compilation/fail20376.d index 8410af535e2..dbd0061ef88 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail20376.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail20376.d @@ -3,7 +3,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail20376.d(17): Error: cannot implicitly convert expression `Foo()` of type `Foo` to `ubyte` +fail_compilation/fail20376.d(17): Error: return value `Foo()` of type `Foo` does not match return type `ubyte`, and cannot be implicitly converted --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21206.d b/gcc/testsuite/gdc.test/fail_compilation/fail21206.d index b3b42f34296..5dc85ca9be3 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail21206.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail21206.d @@ -1,7 +1,7 @@ // https://issues.dlang.org/show_bug.cgi?id=21206 /* TEST_OUTPUT: --- -fail_compilation/fail21206.d(10): Error: function `fail21206.Obj.toString` cannot return type `string` because its linkage is `extern(C++)` +fail_compilation/fail21206.d(10): Error: function `toString` cannot return type `string` because its linkage is `extern(C++)` fail_compilation/fail21206.d(10): slices are specific to D and do not have a counterpart representation in C++ --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22.d b/gcc/testsuite/gdc.test/fail_compilation/fail22.d index 1de2a13044a..47c6018d138 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail22.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail22.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail22.d(13): Error: no identifier for declarator `char` +fail_compilation/fail22.d(13): Error: variable name expected after type `char`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail22054.d b/gcc/testsuite/gdc.test/fail_compilation/fail22054.d index 8b525d85fb2..c172f089d9c 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail22054.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail22054.d @@ -3,12 +3,10 @@ /* TEST_OUTPUT: --- -fail_compilation/fail22054.d(23): Error: no property `what` for type `fail22054.exception` -fail_compilation/fail22054.d(18): `class fail22054.exception` is opaque and has no members. -fail_compilation/fail22054.d(18): class `exception` defined here -fail_compilation/fail22054.d(24): Error: no property `what` for type `fail22054.exception2` -fail_compilation/fail22054.d(19): `struct fail22054.exception2` is opaque and has no members. -fail_compilation/fail22054.d(19): struct `exception2` defined here +fail_compilation/fail22054.d(21): Error: no property `what` for type `fail22054.exception` +fail_compilation/fail22054.d(16): `class fail22054.exception` is opaque and has no members. +fail_compilation/fail22054.d(22): Error: no property `what` for type `fail22054.exception2` +fail_compilation/fail22054.d(17): `struct fail22054.exception2` is opaque and has no members. --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail2450.d b/gcc/testsuite/gdc.test/fail_compilation/fail2450.d index 82118d5de45..b61df87b52f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail2450.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail2450.d @@ -2,10 +2,8 @@ /* TEST_OUTPUT: --- -fail_compilation/fail2450.d(22): Error: function expected before `()`, not `this.mixin Event!() clicked; -` of type `void` -fail_compilation/fail2450.d(25): Error: function expected before `()`, not `b.mixin Event!() clicked; -` of type `void` +fail_compilation/fail2450.d(20): Error: function expected before `()`, not `this.mixin Event!() clicked;` of type `void` +fail_compilation/fail2450.d(23): Error: function expected before `()`, not `b.mixin Event!() clicked;` of type `void` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail3673b.d b/gcc/testsuite/gdc.test/fail_compilation/fail3673b.d index bf745ac8bbd..60de5971ac9 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail3673b.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail3673b.d @@ -4,7 +4,7 @@ TEST_OUTPUT: fail_compilation/fail3673b.d(12): Error: basic type expected, not `if` fail_compilation/fail3673b.d(12): Error: template constraints only allowed for templates fail_compilation/fail3673b.d(12): Error: { } expected following `class` declaration -fail_compilation/fail3673b.d(12): Error: no identifier for declarator `A` +fail_compilation/fail3673b.d(12): Error: variable name expected after type `A`, not `{` fail_compilation/fail3673b.d(12): Error: declaration expected, not `{` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d b/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d index 8a95b34e891..33f9ea1ec31 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail4269e.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail4269e.d(10): Error: semicolon needed to end declaration of `Y` instead of `X5` -fail_compilation/fail4269e.d(10): Error: no identifier for declarator `X5` +fail_compilation/fail4269e.d(10): Error: variable name expected after type `X5`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail4544.d b/gcc/testsuite/gdc.test/fail_compilation/fail4544.d index cf1554da235..1cb0292cc8c 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail4544.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail4544.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/fail4544.d(15): Error: character constant has multiple characters fail_compilation/fail4544.d(16): Error: `0x` isn't a valid integer literal, use `0x0` instead -fail_compilation/fail4544.d(16): Error: no identifier for declarator `int` +fail_compilation/fail4544.d(16): Error: variable name expected after type `int`, not `0` fail_compilation/fail4544.d(17): Error: unterminated character constant fail_compilation/fail4544.d(18): Error: character constant has multiple characters --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail6334.d b/gcc/testsuite/gdc.test/fail_compilation/fail6334.d index 7abdb9e26a3..4afe6546224 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail6334.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail6334.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail6334.d(13): Error: static assert: `0` is false -fail_compilation/fail6334.d(11): instantiated from here: `T2!()` +fail_compilation/fail6334.d(11): instantiated from here: `mixin T2!();` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail99.d b/gcc/testsuite/gdc.test/fail_compilation/fail99.d index a12fa3f4cc6..4f119f2aa9b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail99.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail99.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail99.d(13): Error: delegate `dg(int)` is not callable using argument types `()` +fail_compilation/fail99.d(13): Error: delegate `dg` is not callable using argument types `()` fail_compilation/fail99.d(13): too few arguments, expected 1, got 0 --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d b/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d index 51275d0140e..b6c3bc906a1 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d +++ b/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d @@ -3,7 +3,7 @@ fail_compilation/failcontracts.d(17): Error: missing `{ ... }` for function literal fail_compilation/failcontracts.d(17): Error: semicolon expected following auto declaration, not `bode` fail_compilation/failcontracts.d(18): Error: function declaration without return type. (Note that constructors are always named `this`) -fail_compilation/failcontracts.d(18): Error: no identifier for declarator `test1()` +fail_compilation/failcontracts.d(18): Error: variable name expected after type `test1()`, not `bode` fail_compilation/failcontracts.d(18): Error: semicolon expected following function declaration, not `bode` fail_compilation/failcontracts.d(19): Error: semicolon expected following function declaration, not `bode` fail_compilation/failcontracts.d(21): Error: unexpected `(` in declarator diff --git a/gcc/testsuite/gdc.test/fail_compilation/fnconstraint.d b/gcc/testsuite/gdc.test/fail_compilation/fnconstraint.d index 21603f725f6..6369bdc5baf 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fnconstraint.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fnconstraint.d @@ -2,9 +2,9 @@ TEST_OUTPUT: --- fail_compilation/fnconstraint.d(14): Error: template constraint must follow parameter lists and attributes -fail_compilation/fnconstraint.d(14): Error: declaration expected, not `if` +fail_compilation/fnconstraint.d(15): Error: declaration expected, not `{` fail_compilation/fnconstraint.d(23): Error: template constraint must follow parameter lists and attributes -fail_compilation/fnconstraint.d(23): Error: declaration expected, not `if` +fail_compilation/fnconstraint.d(23): Error: declaration expected, not `{` fail_compilation/fnconstraint.d(27): Error: `}` expected following members in `struct` declaration fail_compilation/fnconstraint.d(19): struct `S` starts here --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d index fc6c593ae0a..4f052b28193 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice10922.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice10922.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/ice10922.d(11): Error: function `__lambda_L10_C12` is not callable using argument types `()` +fail_compilation/ice10922.d(11): Error: function `(in uint n) { enum self = __lambda_L10_C12; return n < 2 ? n : self(n - 1) + ...` is not callable using argument types `()` fail_compilation/ice10922.d(11): too few arguments, expected 1, got 0 fail_compilation/ice10922.d(10): `ice10922.__lambda_L10_C12(in uint n)` declared here --- diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice10938.d b/gcc/testsuite/gdc.test/fail_compilation/ice10938.d index 4d107c9e7b2..16eaa99b3d8 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice10938.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice10938.d @@ -2,8 +2,8 @@ TEST_OUTPUT: --- fail_compilation/ice10938.d(14): Error: no property `opts` for `this` of type `ice10938.C` -fail_compilation/ice10938.d(14): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message -fail_compilation/ice10938.d(10): class `C` defined here +fail_compilation/ice10938.d(19): Error: forward reference to inferred return type of function call `this.opDispatch()` +fail_compilation/ice10938.d(14): Error: template instance `ice10938.C.opDispatch!"opts"` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice11153.d b/gcc/testsuite/gdc.test/fail_compilation/ice11153.d index 6a1b89ba776..826bd8cd7ec 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice11153.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice11153.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/ice11153.d(11): Error: function declaration without return type. (Note that constructors are always named `this`) -fail_compilation/ice11153.d(11): Error: no identifier for declarator `foo()` +fail_compilation/ice11153.d(11): Error: variable name expected after type `foo()`, not `{` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice11963.d b/gcc/testsuite/gdc.test/fail_compilation/ice11963.d index 39eb120827a..165945b6f43 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice11963.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice11963.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/ice11963.d(10): Error: unexpected `(` in declarator fail_compilation/ice11963.d(10): Error: identifier expected for template type parameter -fail_compilation/ice11963.d(10): Error: no identifier for declarator `A` +fail_compilation/ice11963.d(10): Error: variable name expected after type `A`, not `""` fail_compilation/ice11963.d(10): Error: declaration expected, not `""` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice11965.d b/gcc/testsuite/gdc.test/fail_compilation/ice11965.d index 9e6da3bbf84..79d15aa5a6f 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice11965.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice11965.d @@ -1,15 +1,15 @@ /* TEST_OUTPUT: --- -fail_compilation/ice11965.d(16): Error: no identifier for declarator `b*` +fail_compilation/ice11965.d(16): Error: variable name expected after type `b*`, not `End of File` fail_compilation/ice11965.d(16): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/ice11965.d(15): unmatched `{` fail_compilation/ice11965.d(16): Error: found `End of File` when expecting `]` -fail_compilation/ice11965.d(16): Error: no identifier for declarator `u[() +fail_compilation/ice11965.d(16): Error: variable name expected after type `u[() { b* A; } -]` +]`, not `End of File` --- */ u[{b*A, diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice15855.d b/gcc/testsuite/gdc.test/fail_compilation/ice15855.d index 5d1cea1de72..da630913b20 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice15855.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice15855.d @@ -12,7 +12,7 @@ fail_compilation/ice15855.d(28): Error: found `End of File` instead of statement fail_compilation/ice15855.d(28): Error: matching `}` expected following compound statement, not `End of File` fail_compilation/ice15855.d(27): unmatched `{` fail_compilation/ice15855.d(28): Error: found `End of File` when expecting `]` -fail_compilation/ice15855.d(28): Error: no identifier for declarator `a[() +fail_compilation/ice15855.d(28): Error: variable name expected after type `a[() { for (__error__ __error; __error) @@ -20,7 +20,7 @@ for (__error__ __error__ } } -]` +]`, not `End of File` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice22377.d b/gcc/testsuite/gdc.test/fail_compilation/ice22377.d index 686e700cae9..b9e1a927813 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice22377.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice22377.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/ice22377.d(8): Error: function `ice22377.foo` cannot have parameter of type `string` because its linkage is `extern(C++)` +fail_compilation/ice22377.d(8): Error: function `foo` cannot have parameter of type `string` because its linkage is `extern(C++)` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice8309.d b/gcc/testsuite/gdc.test/fail_compilation/ice8309.d index a9f6f7253ac..48e35e2ed0e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice8309.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice8309.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/ice8309.d(10): Error: incompatible types for `(__lambda_L10_C15) : (__lambda_L10_C24)`: `double function() pure nothrow @nogc @safe` and `int function() pure nothrow @nogc @safe` +fail_compilation/ice8309.d(10): Error: incompatible types for `(() => 1.0) : (() => 1)`: `double function() pure nothrow @nogc @safe` and `int function() pure nothrow @nogc @safe` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice9406.d b/gcc/testsuite/gdc.test/fail_compilation/ice9406.d index c1807a0f542..f9032ec0e88 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ice9406.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ice9406.d @@ -1,8 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/ice9406.d(22): Error: `s1.mixin Mixin!() t1; -` has no effect +fail_compilation/ice9406.d(21): Error: `s1.mixin Mixin!() t1;` has no effect --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue16020.d b/gcc/testsuite/gdc.test/fail_compilation/issue16020.d index 79eda2ea08c..9f1f3776388 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/issue16020.d +++ b/gcc/testsuite/gdc.test/fail_compilation/issue16020.d @@ -1,10 +1,11 @@ /* TEST_OUTPUT: --- -fail_compilation/issue16020.d(13): Error: user-defined attributes not allowed for `alias` declarations -fail_compilation/issue16020.d(14): Error: semicolon expected to close `alias` declaration, not `(` -fail_compilation/issue16020.d(14): Error: declaration expected, not `(` -fail_compilation/issue16020.d(15): Deprecation: storage class `final` has no effect in type aliases +fail_compilation/issue16020.d(14): Error: user-defined attributes not allowed for `alias` declarations +fail_compilation/issue16020.d(15): Error: semicolon expected to close `alias` declaration, not `(` +fail_compilation/issue16020.d(15): Error: semicolon needed to end declaration of `t` instead of `)` +fail_compilation/issue16020.d(15): Error: declaration expected, not `)` +fail_compilation/issue16020.d(16): Deprecation: storage class `final` has no effect in type aliases --- */ module issue16020; diff --git a/gcc/testsuite/gdc.test/fail_compilation/misc1.d b/gcc/testsuite/gdc.test/fail_compilation/misc1.d index 90e42d83e99..957c0809d5d 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/misc1.d +++ b/gcc/testsuite/gdc.test/fail_compilation/misc1.d @@ -5,7 +5,7 @@ fail_compilation/misc1.d(109): Error: `5` has no effect fail_compilation/misc1.d(110): Error: `1 + 2` has no effect fail_compilation/misc1.d(111): Error: `x` has no effect fail_compilation/misc1.d(117): Deprecation: `1 * 1` has no effect -fail_compilation/misc1.d(118): Deprecation: `__lambda_L118_C34` has no effect +fail_compilation/misc1.d(118): Deprecation: `() { j++; d++; }` has no effect fail_compilation/misc1.d(124): Deprecation: `false` has no effect fail_compilation/misc1.d(127): Deprecation: `*sp++` has no effect fail_compilation/misc1.d(128): Deprecation: `j` has no effect diff --git a/gcc/testsuite/gdc.test/fail_compilation/nogc3.d b/gcc/testsuite/gdc.test/fail_compilation/nogc3.d index 6fa115a6a8a..17daa96358b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/nogc3.d +++ b/gcc/testsuite/gdc.test/fail_compilation/nogc3.d @@ -44,10 +44,10 @@ fail_compilation/nogc3.d(35): Error: `@nogc` function `nogc3.testCall` cannot ca TEST_OUTPUT: --- fail_compilation/nogc3.d(54): Error: function `nogc3.testClosure1` is `@nogc` yet allocates closure for `testClosure1()` with the GC -fail_compilation/nogc3.d(57): function `nogc3.testClosure1.bar` closes over variable `x` +fail_compilation/nogc3.d(57): function `bar` closes over variable `x` fail_compilation/nogc3.d(56): `x` declared here fail_compilation/nogc3.d(66): Error: function `nogc3.testClosure3` is `@nogc` yet allocates closure for `testClosure3()` with the GC -fail_compilation/nogc3.d(69): function `nogc3.testClosure3.bar` closes over variable `x` +fail_compilation/nogc3.d(69): function `bar` closes over variable `x` fail_compilation/nogc3.d(68): `x` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d index 66c1d5287f5..ec6bd3ebce9 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d +++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d @@ -55,7 +55,7 @@ NR returns() /+ TEST_OUTPUT: --- -fail_compilation/noreturn2.d(64): Error: cannot implicitly convert expression `1` of type `int` to `noreturn` +fail_compilation/noreturn2.d(64): Error: return value `1` of type `int` does not match return type `noreturn`, and cannot be implicitly converted --- +/ diff --git a/gcc/testsuite/gdc.test/fail_compilation/opapplyscope.d b/gcc/testsuite/gdc.test/fail_compilation/opapplyscope.d index 3eef0f92937..872a44796f8 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/opapplyscope.d +++ b/gcc/testsuite/gdc.test/fail_compilation/opapplyscope.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- fail_compilation/opapplyscope.d(113): Error: function `opapplyscope.S.opApply(scope int delegate(scope int* ptr) @safe dg)` is not callable using argument types `(int delegate(int* x) nothrow @nogc @safe)` -fail_compilation/opapplyscope.d(113): cannot pass argument `__foreachbody_L113_C5` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg` +fail_compilation/opapplyscope.d(113): cannot pass argument `int(int* x) => 0` of type `int delegate(int* x) nothrow @nogc @safe` to parameter `scope int delegate(scope int* ptr) @safe dg` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/parse14285.d b/gcc/testsuite/gdc.test/fail_compilation/parse14285.d index c9aa70aa793..3777cf6a958 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/parse14285.d +++ b/gcc/testsuite/gdc.test/fail_compilation/parse14285.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/parse14285.d(10): Error: no identifier for declarator `this` +fail_compilation/parse14285.d(10): Error: variable name expected after type `this`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/previewin.d b/gcc/testsuite/gdc.test/fail_compilation/previewin.d index 77f8e438563..3ae5de00993 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/previewin.d +++ b/gcc/testsuite/gdc.test/fail_compilation/previewin.d @@ -3,13 +3,13 @@ REQUIRED_ARGS: -preview=in -preview=dip1000 TEST_OUTPUT: ---- fail_compilation/previewin.d(4): Error: function `takeFunction` is not callable using argument types `(void function(real x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(4): cannot pass argument `__lambda_L4_C18` of type `void function(real x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(4): cannot pass argument `(real x) { }` of type `void function(real x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(5): Error: function `takeFunction` is not callable using argument types `(void function(scope const(real) x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(5): cannot pass argument `__lambda_L5_C18` of type `void function(scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(5): cannot pass argument `(scope const(real) x) { }` of type `void function(scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(6): Error: function `takeFunction` is not callable using argument types `(void function(ref scope const(real) x) pure nothrow @nogc @safe)` -fail_compilation/previewin.d(6): cannot pass argument `__lambda_L6_C18` of type `void function(ref scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` +fail_compilation/previewin.d(6): cannot pass argument `(ref scope const(real) x) { }` of type `void function(ref scope const(real) x) pure nothrow @nogc @safe` to parameter `void function(in real) f` fail_compilation/previewin.d(11): `previewin.takeFunction(void function(in real) f)` declared here fail_compilation/previewin.d(15): Error: assigning scope variable `arg` to global variable `myGlobal` is not allowed in a `@safe` function fail_compilation/previewin.d(16): Error: assigning scope variable `arg` to global variable `myGlobal` is not allowed in a `@safe` function diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope.d b/gcc/testsuite/gdc.test/fail_compilation/retscope.d index 0c2d86a6b2a..39fa8ab57af 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/retscope.d +++ b/gcc/testsuite/gdc.test/fail_compilation/retscope.d @@ -55,7 +55,7 @@ void test2(scope int* p, int[] a ...) @safe TEST_OUTPUT: --- fail_compilation/retscope.d(75): Error: function `retscope.HTTP.Impl.onReceive` is `@nogc` yet allocates closure for `onReceive()` with the GC -fail_compilation/retscope.d(77): delegate `retscope.HTTP.Impl.onReceive.__lambda_L77_C23` closes over variable `this` +fail_compilation/retscope.d(77): delegate `() => this.x` closes over variable `this` --- */ @@ -164,6 +164,7 @@ class C11 /* TEST_OUTPUT: --- +fail_compilation/retscope.d(177): Error: assigning address of variable `i` to `p` with longer lifetime is not allowed in a `@safe` function --- */ @@ -180,6 +181,7 @@ void foo11() @safe /* TEST_OUTPUT: --- +fail_compilation/retscope.d(197): Error: returning scope variable `e` is not allowed in a `@safe` function --- */ @@ -199,8 +201,6 @@ void* escapeDg1(scope void* d) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(176): Error: assigning address of variable `i` to `p` with longer lifetime is not allowed in a `@safe` function -fail_compilation/retscope.d(195): Error: returning scope variable `e` is not allowed in a `@safe` function fail_compilation/retscope.d(212): Error: assigning scope variable `p` to non-scope `e.e` is not allowed in a `@safe` function --- */ @@ -234,10 +234,10 @@ void* funretscope(scope dg_t ptr) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda_L248_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda_L248_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda_L249_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` -fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda_L249_C21` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` +fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `() => & x` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() scope @safe` --- */ @@ -254,6 +254,7 @@ void escape4() @safe /* TEST_OUTPUT: --- +fail_compilation/retscope.d(266): Error: taking address of `scope` variable `p` with pointers is not allowed in a `@safe` function --- */ @@ -270,7 +271,6 @@ void escape5() @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(265): Error: taking address of `scope` variable `p` with pointers is not allowed in a `@safe` function fail_compilation/retscope.d(286): Error: escaping a reference to local variable `b` by returning `foo6(& b)` is not allowed in a `@safe` function --- */ @@ -323,6 +323,7 @@ ref int[3] asStatic2( scope int[] p) @safe { return p[0 .. 3]; } /* TEST_OUTPUT: --- +fail_compilation/retscope.d(335): Error: assigning reference to local variable `i` to non-scope `f` is not allowed in a `@safe` function --- */ @@ -346,7 +347,6 @@ int* bar10( scope int** ptr ) @safe /* TEST_OUTPUT: --- -fail_compilation/retscope.d(334): Error: assigning reference to local variable `i` to non-scope `f` is not allowed in a `@safe` function fail_compilation/retscope.d(358): Error: taking address of `scope` variable `aa` with pointers is not allowed in a `@safe` function --- */ @@ -399,6 +399,7 @@ struct Foo12 /* TEST_OUTPUT: --- +fail_compilation/retscope.d(1103): Error: returning scope variable `f` is not allowed in a `@safe` function --- */ @@ -418,6 +419,7 @@ class Foo13 /* TEST_OUTPUT: --- +fail_compilation/retscope.d(1205): Error: scope variable `f14` calling non-scope member function `Foo14.foo()` is not allowed in a `@safe` function --- */ @@ -440,6 +442,7 @@ struct Foo14 /* TEST_OUTPUT: --- +fail_compilation/retscope.d(1311): Error: assigning scope variable `u2` to `ek` with longer lifetime is not allowed in a `@safe` function --- */ @@ -467,6 +470,7 @@ TEST_OUTPUT: /* TEST_OUTPUT: --- +fail_compilation/retscope.d(1405): Error: assigning reference to local variable `buf` to non-scope anonymous parameter calling `myprintf` is not allowed in a `@safe` function --- */ @@ -484,10 +488,6 @@ TEST_OUTPUT: /* TEST_OUTPUT: --- -fail_compilation/retscope.d(1103): Error: returning scope variable `f` is not allowed in a `@safe` function -fail_compilation/retscope.d(1205): Error: scope variable `f14` calling non-scope member function `Foo14.foo()` is not allowed in a `@safe` function -fail_compilation/retscope.d(1311): Error: assigning scope variable `u2` to `ek` with longer lifetime is not allowed in a `@safe` function -fail_compilation/retscope.d(1405): Error: assigning reference to local variable `buf` to non-scope anonymous parameter calling `myprintf` is not allowed in a `@safe` function fail_compilation/retscope.d(1509): Error: assigning reference to stack allocated value returned by `(*fp15)()` to non-scope anonymous parameter is not allowed in a `@safe` function --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope2.d b/gcc/testsuite/gdc.test/fail_compilation/retscope2.d index 4638cdc139a..f663e4f4fb0 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/retscope2.d +++ b/gcc/testsuite/gdc.test/fail_compilation/retscope2.d @@ -2,6 +2,8 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- +fail_compilation/retscope2.d(102): Error: assigning scope variable `s` to `ref` variable `p` with longer lifetime is not allowed in a `@safe` function +fail_compilation/retscope2.d(107): Error: assigning address of variable `s` to `p` with longer lifetime is not allowed in a `@safe` function --- */ @@ -34,6 +36,7 @@ void test200() /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(302): Error: assigning scope variable `a` to return scope `b` is not allowed in a `@safe` function --- */ @@ -49,6 +52,7 @@ TEST_OUTPUT: /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(403): Error: assigning scope variable `a` to return scope `c` is not allowed in a `@safe` function --- */ @@ -65,6 +69,7 @@ TEST_OUTPUT: /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(504): Error: returning scope variable `c` is not allowed in a `@safe` function --- */ @@ -81,11 +86,6 @@ TEST_OUTPUT: /* TEST_OUTPUT: --- -fail_compilation/retscope2.d(102): Error: assigning scope variable `s` to `ref` variable `p` with longer lifetime is not allowed in a `@safe` function -fail_compilation/retscope2.d(107): Error: assigning address of variable `s` to `p` with longer lifetime is not allowed in a `@safe` function -fail_compilation/retscope2.d(302): Error: assigning scope variable `a` to return scope `b` is not allowed in a `@safe` function -fail_compilation/retscope2.d(403): Error: assigning scope variable `a` to return scope `c` is not allowed in a `@safe` function -fail_compilation/retscope2.d(504): Error: returning scope variable `c` is not allowed in a `@safe` function fail_compilation/retscope2.d(604): Error: assigning scope variable `__param_0` to non-scope anonymous parameter calling `foo600` is not allowed in a `@safe` function fail_compilation/retscope2.d(604): Error: assigning scope variable `__param_1` to non-scope anonymous parameter calling `foo600` is not allowed in a `@safe` function fail_compilation/retscope2.d(614): Error: template instance `retscope2.test600!(int*, int*)` error instantiating @@ -115,6 +115,8 @@ fail_compilation/retscope2.d(614): Error: template instance `retscope2.test600!( /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(719): Error: returning `get2(s)` escapes a reference to local variable `s` +fail_compilation/retscope2.d(721): Error: returning `s.get1()` escapes a reference to local variable `s` --- */ @@ -148,6 +150,7 @@ S700* escape700(int i) @safe /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(804): Error: throwing scope variable `e` is not allowed in a `@safe` function --- */ @@ -164,6 +167,7 @@ void foo800() @safe /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(907): Error: assigning address of variable `this` to `p17568` with longer lifetime is not allowed in a `@safe` function --- */ @@ -184,6 +188,9 @@ struct T17568 /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(1005): Error: assigning scope variable `p` to non-scope `this._p` is not allowed in a `@safe` function +fail_compilation/retscope2.d(1021): Error: assigning scope variable `p` to non-scope `c._p` is not allowed in a `@safe` function +fail_compilation/retscope2.d(1024): Error: assigning scope variable `p` to non-scope `d._p` is not allowed in a `@safe` function --- */ @@ -222,6 +229,7 @@ void test17428() @safe /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(1107): Error: returning scope variable `dg` is not allowed in a `@safe` function --- */ @@ -241,6 +249,8 @@ void delegate() test17430() @safe /* TEST_OUTPUT: --- +fail_compilation/retscope2.d(1216): Error: returning `s.foo()` escapes a reference to local variable `s` +fail_compilation/retscope2.d(1233): Error: returning `t.foo()` escapes a reference to local variable `t` --- */ @@ -286,16 +296,6 @@ struct T17388 /* TEST_OUTPUT: --- -fail_compilation/retscope2.d(719): Error: returning `get2(s)` escapes a reference to local variable `s` -fail_compilation/retscope2.d(721): Error: returning `s.get1()` escapes a reference to local variable `s` -fail_compilation/retscope2.d(804): Error: throwing scope variable `e` is not allowed in a `@safe` function -fail_compilation/retscope2.d(907): Error: assigning address of variable `this` to `p17568` with longer lifetime is not allowed in a `@safe` function -fail_compilation/retscope2.d(1005): Error: assigning scope variable `p` to non-scope `this._p` is not allowed in a `@safe` function -fail_compilation/retscope2.d(1021): Error: assigning scope variable `p` to non-scope `c._p` is not allowed in a `@safe` function -fail_compilation/retscope2.d(1024): Error: assigning scope variable `p` to non-scope `d._p` is not allowed in a `@safe` function -fail_compilation/retscope2.d(1107): Error: returning scope variable `dg` is not allowed in a `@safe` function -fail_compilation/retscope2.d(1216): Error: returning `s.foo()` escapes a reference to local variable `s` -fail_compilation/retscope2.d(1233): Error: returning `t.foo()` escapes a reference to local variable `t` fail_compilation/retscope2.d(1306): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/retscope3.d b/gcc/testsuite/gdc.test/fail_compilation/retscope3.d index 819071f15d0..438fdd76e1b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/retscope3.d +++ b/gcc/testsuite/gdc.test/fail_compilation/retscope3.d @@ -5,6 +5,8 @@ REQUIRED_ARGS: -preview=dip1000 /* TEST_OUTPUT: --- +fail_compilation/retscope3.d(2008): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function +fail_compilation/retscope3.d(2017): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function --- */ @@ -51,8 +53,6 @@ void bar4() /* TEST_OUTPUT: --- -fail_compilation/retscope3.d(2008): Error: escaping a reference to local variable `i` by copying `& i` into allocated memory is not allowed in a `@safe` function -fail_compilation/retscope3.d(2017): Error: escaping a reference to local variable `i` by copying `S2000(& i)` into allocated memory is not allowed in a `@safe` function fail_compilation/retscope3.d(4003): Error: escaping a reference to parameter `u` by copying `u[]` into allocated memory is not allowed in a `@safe` function fail_compilation/retscope3.d(4016): Error: storing reference to outer local variable `i` into allocated memory causes it to escape fail_compilation/retscope3.d(4025): Error: escaping reference to stack allocated value returned by `makeSA()` into allocated memory diff --git a/gcc/testsuite/gdc.test/fail_compilation/shared.d b/gcc/testsuite/gdc.test/fail_compilation/shared.d index 1af95949d7a..7ab1d7cd173 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/shared.d +++ b/gcc/testsuite/gdc.test/fail_compilation/shared.d @@ -96,7 +96,7 @@ fail_compilation/shared.d(2216): return value `getSharedObject()` is not fail_compilation/shared.d(2222): Error: direct access to shared `a` is not allowed, see `core.atomic` fail_compilation/shared.d(2220): Error: function `shared.test_inference_4` function returns `shared` but cannot be inferred `ref` fail_compilation/shared.d(2222): cannot implicitly convert `a` of type `shared(const(Object))` to `object.Object` -fail_compilation/shared.d(2222): Error: cannot implicitly convert expression `a` of type `shared(const(Object))` to `object.Object` +fail_compilation/shared.d(2222): Error: return value `a` of type `shared(const(Object))` does not match return type `object.Object`, and cannot be implicitly converted --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/systemvariables_deprecation.d b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_deprecation.d index 88f6d83632b..9dd07168843 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/systemvariables_deprecation.d +++ b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_deprecation.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -de TEST_OUTPUT: --- fail_compilation/systemvariables_deprecation.d(15): Deprecation: `@safe` function `main` calling `middle` -fail_compilation/systemvariables_deprecation.d(20): which calls `systemvariables_deprecation.inferred` +fail_compilation/systemvariables_deprecation.d(20): which calls `inferred` fail_compilation/systemvariables_deprecation.d(26): and access `@system` variable `x0` makes it fail to infer `@safe` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/template_decl.d b/gcc/testsuite/gdc.test/fail_compilation/template_decl.d index d986dd65065..a28284b9e47 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/template_decl.d +++ b/gcc/testsuite/gdc.test/fail_compilation/template_decl.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/template_decl.d(8): Error: `{` expected after template parameter list, not `(` -fail_compilation/template_decl.d(8): Error: declaration expected, not `(` +fail_compilation/template_decl.d(8): Error: declaration expected, not `)` --- */ template b(alias d)() { diff --git a/gcc/testsuite/gdc.test/fail_compilation/test1.d b/gcc/testsuite/gdc.test/fail_compilation/test1.d index aeceb52cadc..0f5bd707b8e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test1.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test1.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test1.d(8): Error: no identifier for declarator `fail` +fail_compilation/test1.d(8): Error: variable name expected after type `fail`, not `End of File` --- */ fail diff --git a/gcc/testsuite/gdc.test/fail_compilation/test14238.d b/gcc/testsuite/gdc.test/fail_compilation/test14238.d index e1cd39c595a..4fcea9d7752 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test14238.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test14238.d @@ -3,7 +3,7 @@ --- fail_compilation/test14238.d(22): Error: scope parameter `fn` may not be returned fail_compilation/test14238.d(25): Error: function `test14238.bar` is `@nogc` yet allocates closure for `bar()` with the GC -fail_compilation/test14238.d(27): function `test14238.bar.baz` closes over variable `x` +fail_compilation/test14238.d(27): function `baz` closes over variable `x` fail_compilation/test14238.d(26): `x` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test14538.d b/gcc/testsuite/gdc.test/fail_compilation/test14538.d index 1ad2126fd43..c912d165a2d 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test14538.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test14538.d @@ -2,7 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test14538.d(18): Error: cannot implicitly convert expression `x ? cast(uint)this.fCells[x].code : 32u` of type `uint` to `Cell` +fail_compilation/test14538.d(18): Error: return value `x ? cast(uint)this.fCells[x].code : 32u` of type `uint` does not match return type `Cell`, and cannot be implicitly converted --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16188.d b/gcc/testsuite/gdc.test/fail_compilation/test16188.d index 0bd052ca6db..e3fedf34bd9 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test16188.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test16188.d @@ -2,8 +2,8 @@ * TEST_OUTPUT: --- fail_compilation/test16188.d(101): Error: no property `name` for `Where()` of type `test16188.Where` -fail_compilation/test16188.d(101): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message -fail_compilation/test16188.d(103): struct `Where` defined here +fail_compilation/test16188.d(107): Error: undefined identifier `getMember` +fail_compilation/test16188.d(101): Error: template instance `test16188.Where.opDispatch!"name"` error instantiating --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16193.d b/gcc/testsuite/gdc.test/fail_compilation/test16193.d index 84dc7d1c6d7..76a2fb66765 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test16193.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test16193.d @@ -3,7 +3,7 @@ REQUIRED_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test16193.d(39): Error: function `test16193.abc` is `@nogc` yet allocates closure for `abc()` with the GC -fail_compilation/test16193.d(41): delegate `test16193.abc.__foreachbody_L41_C5` closes over variable `x` +fail_compilation/test16193.d(41): delegate `int(int i) => 0` closes over variable `x` fail_compilation/test16193.d(40): `x` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19107.d b/gcc/testsuite/gdc.test/fail_compilation/test19107.d index 8bbfa82717f..e30dcf723d2 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test19107.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test19107.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/test19107.d(24): Error: template `all` is not callable using argument types `!((c) => c)(string[])` fail_compilation/test19107.d(18): Candidate is: `all(alias pred, T)(T t)` - with `pred = __lambda_L24_C15, + with `pred = (c) => c, T = string[]` must satisfy the following constraint: ` is(typeof(I!pred(t)))` diff --git a/gcc/testsuite/gdc.test/fail_compilation/test19971.d b/gcc/testsuite/gdc.test/fail_compilation/test19971.d index b99afddbdd5..1db134f0393 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test19971.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test19971.d @@ -3,7 +3,7 @@ fail_compilation/test19971.d(16): Error: function `f` is not callable using argument types `(string)` fail_compilation/test19971.d(16): cannot pass argument `"%s"` of type `string` to parameter `int x` fail_compilation/test19971.d(13): `test19971.f(int x)` declared here -fail_compilation/test19971.d(17): Error: function literal `__lambda_L17_C5(int x)` is not callable using argument types `(string)` +fail_compilation/test19971.d(17): Error: function literal `(int x) { }` is not callable using argument types `(string)` fail_compilation/test19971.d(17): cannot pass argument `"%s"` of type `string` to parameter `int x` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21062.d b/gcc/testsuite/gdc.test/fail_compilation/test21062.d index 5ab53073733..18839cc3e25 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test21062.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test21062.d @@ -1,11 +1,11 @@ /* TEST_OUTPUT: --- -fail_compilation/test21062.d(16): Error: no identifier for declarator `bool` +fail_compilation/test21062.d(16): Error: variable name expected after type `bool`, not `synchronized` fail_compilation/test21062.d(16): `synchronized` is a keyword, perhaps append `_` to make it an identifier -fail_compilation/test21062.d(17): Error: no identifier for declarator `ubyte*` +fail_compilation/test21062.d(17): Error: variable name expected after type `ubyte*`, not `out` fail_compilation/test21062.d(17): `out` is a keyword, perhaps append `_` to make it an identifier -fail_compilation/test21062.d(21): Error: no identifier for declarator `uint` +fail_compilation/test21062.d(21): Error: variable name expected after type `uint`, not `in` fail_compilation/test21062.d(21): `in` is a keyword, perhaps append `_` to make it an identifier --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21096.d b/gcc/testsuite/gdc.test/fail_compilation/test21096.d index 302eb3da31a..169a9d1a5ca 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test21096.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test21096.d @@ -4,7 +4,7 @@ TEST_OUTPUT: --- fail_compilation/test21096.d(11): Error: identifier or new keyword expected following `(...)`. -fail_compilation/test21096.d(11): Error: no identifier for declarator `char[(__error)]` +fail_compilation/test21096.d(11): Error: variable name expected after type `char[(__error)]`, not `;` --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21912.d b/gcc/testsuite/gdc.test/fail_compilation/test21912.d index 7e236c8a33a..b34f60b68ed 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test21912.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test21912.d @@ -3,16 +3,16 @@ PERMUTE_ARGS: -preview=dip1000 TEST_OUTPUT: --- fail_compilation/test21912.d(28): Error: function `test21912.escapeParam` is `@nogc` yet allocates closure for `escapeParam()` with the GC -fail_compilation/test21912.d(30): delegate `test21912.escapeParam.__lambda_L30_C21` closes over variable `i` +fail_compilation/test21912.d(30): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(28): `i` declared here fail_compilation/test21912.d(33): Error: function `test21912.escapeAssign` is `@nogc` yet allocates closure for `escapeAssign()` with the GC -fail_compilation/test21912.d(35): delegate `test21912.escapeAssign.__lambda_L35_C10` closes over variable `i` +fail_compilation/test21912.d(35): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(33): `i` declared here fail_compilation/test21912.d(44): Error: function `test21912.escapeAssignRef` is `@nogc` yet allocates closure for `escapeAssignRef()` with the GC -fail_compilation/test21912.d(46): delegate `test21912.escapeAssignRef.__lambda_L46_C10` closes over variable `i` +fail_compilation/test21912.d(46): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(44): `i` declared here fail_compilation/test21912.d(55): Error: function `test21912.escapeParamInferred` is `@nogc` yet allocates closure for `escapeParamInferred()` with the GC -fail_compilation/test21912.d(57): delegate `test21912.escapeParamInferred.__lambda_L57_C29` closes over variable `i` +fail_compilation/test21912.d(57): delegate `() => i` closes over variable `i` fail_compilation/test21912.d(55): `i` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22023.d b/gcc/testsuite/gdc.test/fail_compilation/test22023.d index a0f553ba5bf..95586c58ada 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test22023.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test22023.d @@ -1,7 +1,6 @@ /* TEST_OUTPUT: --- fail_compilation/test22023.d(102): Error: typesafe variadic function parameter `a` of type `int[]` cannot be marked `return` -fail_compilation/test22023.d(107): Error: typesafe variadic function parameter `c` of type `test22023.C` cannot be marked `return` --- */ @@ -14,13 +13,3 @@ ref int f(return int[] a ...) { return a[2]; } - -ref int g(return C c ...) -{ - return c.x; -} - -class C -{ - int x; -} diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22818.d b/gcc/testsuite/gdc.test/fail_compilation/test22818.d index 5759415ead2..dcb745f9003 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test22818.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test22818.d @@ -1,6 +1,7 @@ /* REQUIRED_ARGS: -preview=dip1000 * TEST_OUTPUT: --- +fail_compilation/test22818.d(102): Deprecation: typesafe variadic parameters with a `class` type (`C c...`) are deprecated fail_compilation/test22818.d(104): Error: scope parameter `c` may not be returned --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23112.d b/gcc/testsuite/gdc.test/fail_compilation/test23112.d index 9bbab80e48c..9430c95c5bf 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test23112.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test23112.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/test23112.d(106): Error: function `test23112.bar` is `@nogc` yet allocates closure for `bar()` with the GC -fail_compilation/test23112.d(108): function `test23112.bar.f` closes over variable `a` +fail_compilation/test23112.d(108): function `f` closes over variable `a` fail_compilation/test23112.d(106): `a` declared here --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23873.d b/gcc/testsuite/gdc.test/fail_compilation/test23873.d index bb6a71dcc24..948df73603d 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/test23873.d +++ b/gcc/testsuite/gdc.test/fail_compilation/test23873.d @@ -5,7 +5,7 @@ TEST_OUTPUT: --- fail_compilation/imports/import23873.d(1): Error: (expression) expected following `static if` fail_compilation/imports/import23873.d(1): Error: declaration expected following attribute, not `;` -fail_compilation/imports/import23873.d(3): Error: no identifier for declarator `x` +fail_compilation/imports/import23873.d(3): Error: variable name expected after type `x`, not `End of File` --- */ struct Foo diff --git a/gcc/testsuite/gdc.test/fail_compilation/testInference.d b/gcc/testsuite/gdc.test/fail_compilation/testInference.d index 8a72ff116f8..fbbde87c060 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/testInference.d +++ b/gcc/testsuite/gdc.test/fail_compilation/testInference.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/testInference.d(24): Error: cannot implicitly convert expression `this.a` of type `inout(A8998)` to `immutable(A8998)` +fail_compilation/testInference.d(24): Error: return value `this.a` of type `inout(A8998)` does not match return type `immutable(A8998)`, and cannot be implicitly converted --- */ @@ -28,10 +28,10 @@ class C8998 /* TEST_OUTPUT: --- -fail_compilation/testInference.d(39): Error: cannot implicitly convert expression `s` of type `const(char[])` to `string` -fail_compilation/testInference.d(44): Error: cannot implicitly convert expression `a` of type `int[]` to `immutable(int[])` -fail_compilation/testInference.d(49): Error: cannot implicitly convert expression `a` of type `int[]` to `immutable(int[])` -fail_compilation/testInference.d(54): Error: cannot implicitly convert expression `a` of type `int[]` to `immutable(int[])` +fail_compilation/testInference.d(39): Error: return value `s` of type `const(char[])` does not match return type `string`, and cannot be implicitly converted +fail_compilation/testInference.d(44): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted +fail_compilation/testInference.d(49): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted +fail_compilation/testInference.d(54): Error: return value `a` of type `int[]` does not match return type `immutable(int[])`, and cannot be implicitly converted --- */ string foo(in char[] s) pure @@ -58,18 +58,18 @@ immutable(int[]) x3(immutable(int[]) org) /*pure*/ /* TEST_OUTPUT: --- -fail_compilation/testInference.d(94): Error: cannot implicitly convert expression `c` of type `testInference.C1` to `immutable(C1)` -fail_compilation/testInference.d(95): Error: cannot implicitly convert expression `c` of type `testInference.C1` to `immutable(C1)` -fail_compilation/testInference.d(96): Error: cannot implicitly convert expression `c` of type `testInference.C3` to `immutable(C3)` -fail_compilation/testInference.d(97): Error: cannot implicitly convert expression `c` of type `testInference.C3` to `immutable(C3)` +fail_compilation/testInference.d(94): Error: return value `c` of type `testInference.C1` does not match return type `immutable(C1)`, and cannot be implicitly converted +fail_compilation/testInference.d(95): Error: return value `c` of type `testInference.C1` does not match return type `immutable(C1)`, and cannot be implicitly converted +fail_compilation/testInference.d(96): Error: return value `c` of type `testInference.C3` does not match return type `immutable(C3)`, and cannot be implicitly converted +fail_compilation/testInference.d(97): Error: return value `c` of type `testInference.C3` does not match return type `immutable(C3)`, and cannot be implicitly converted fail_compilation/testInference.d(100): Error: undefined identifier `X1`, did you mean function `x1`? -fail_compilation/testInference.d(106): Error: cannot implicitly convert expression `s` of type `S1` to `immutable(S1)` -fail_compilation/testInference.d(109): Error: cannot implicitly convert expression `a` of type `int*[]` to `immutable(int*[])` -fail_compilation/testInference.d(110): Error: cannot implicitly convert expression `a` of type `const(int)*[]` to `immutable(int*[])` -fail_compilation/testInference.d(114): Error: cannot implicitly convert expression `s` of type `S2` to `immutable(S2)` -fail_compilation/testInference.d(115): Error: cannot implicitly convert expression `s` of type `S2` to `immutable(S2)` -fail_compilation/testInference.d(116): Error: cannot implicitly convert expression `s` of type `S2` to `immutable(S2)` -fail_compilation/testInference.d(118): Error: cannot implicitly convert expression `a` of type `const(int)*[]` to `immutable(int*[])` +fail_compilation/testInference.d(106): Error: return value `s` of type `S1` does not match return type `immutable(S1)`, and cannot be implicitly converted +fail_compilation/testInference.d(109): Error: return value `a` of type `int*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted +fail_compilation/testInference.d(110): Error: return value `a` of type `const(int)*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted +fail_compilation/testInference.d(114): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted +fail_compilation/testInference.d(115): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted +fail_compilation/testInference.d(116): Error: return value `s` of type `S2` does not match return type `immutable(S2)`, and cannot be implicitly converted +fail_compilation/testInference.d(118): Error: return value `a` of type `const(int)*[]` does not match return type `immutable(int*[])`, and cannot be implicitly converted --- */ immutable(Object) get(inout int*) pure @@ -122,7 +122,7 @@ immutable(int*[]) bar2c( S2 prm) pure { immutable(int)*[] a; return /* TEST_OUTPUT: --- -fail_compilation/testInference.d(134): Error: cannot implicitly convert expression `f10063(cast(inout(void*))p)` of type `inout(void)*` to `immutable(void)*` +fail_compilation/testInference.d(134): Error: return value `f10063(cast(inout(void*))p)` of type `inout(void)*` does not match return type `immutable(void)*`, and cannot be implicitly converted --- */ inout(void)* f10063(inout void* p) pure @@ -138,8 +138,8 @@ immutable(void)* g10063(inout int* p) pure TEST_OUTPUT: --- fail_compilation/testInference.d(154): Error: `pure` function `testInference.bar14049` cannot call impure function `testInference.foo14049!int.foo14049` -fail_compilation/testInference.d(149): which calls `testInference.foo14049!int.foo14049.__lambda_L147_C14` -fail_compilation/testInference.d(148): which calls `testInference.impure14049` +fail_compilation/testInference.d(149): which calls `() => impure14049()` +fail_compilation/testInference.d(148): which calls `impure14049` fail_compilation/testInference.d(143): and accessing mutable static data `i` makes it fail to infer `pure` --- */ @@ -174,7 +174,7 @@ int* f14160() pure TEST_OUTPUT: --- fail_compilation/testInference.d(180): Error: `pure` function `testInference.test12422` cannot call impure function `testInference.test12422.bar12422!().bar12422` -fail_compilation/testInference.d(179): which calls `testInference.foo12422` +fail_compilation/testInference.d(179): which calls `foo12422` --- */ #line 175 @@ -239,7 +239,7 @@ void test17086_call () TEST_OUTPUT: --- fail_compilation/testInference.d(238): Error: `pure` function `testInference.test20047_pure_function` cannot call impure function `testInference.test20047_pure_function.bug` -fail_compilation/testInference.d(237): which calls `testInference.test20047_impure_function` +fail_compilation/testInference.d(237): which calls `test20047_impure_function` --- */ #line 234 diff --git a/gcc/testsuite/gdc.test/fail_compilation/testsemi.d b/gcc/testsuite/gdc.test/fail_compilation/testsemi.d index 77601a5e446..71f2cd1a78e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/testsemi.d +++ b/gcc/testsuite/gdc.test/fail_compilation/testsemi.d @@ -1,11 +1,11 @@ /* TEST_OUTPUT: --- fail_compilation/testsemi.d(102): Error: found `int` when expecting `;` following static assert -fail_compilation/testsemi.d(102): Error: no identifier for declarator `x` +fail_compilation/testsemi.d(102): Error: variable name expected after type `x`, not `;` fail_compilation/testsemi.d(109): Error: found `alias` when expecting `;` following alias reassignment fail_compilation/testsemi.d(112): Error: found `}` when expecting `;` following invariant fail_compilation/testsemi.d(117): Error: found `int` when expecting `;` following `alias Identifier this` -fail_compilation/testsemi.d(117): Error: no identifier for declarator `x` +fail_compilation/testsemi.d(117): Error: variable name expected after type `x`, not `;` fail_compilation/testsemi.d(123): Error: found `int` when expecting `;` following mixin fail_compilation/testsemi.d(129): Error: found `int` when expecting `;` following `import` Expression fail_compilation/testsemi.d(131): Error: `}` expected following members in `class` declaration diff --git a/gcc/testsuite/gdc.test/fail_compilation/traits_alone.d b/gcc/testsuite/gdc.test/fail_compilation/traits_alone.d index 66062fdab69..eb0b396af49 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/traits_alone.d +++ b/gcc/testsuite/gdc.test/fail_compilation/traits_alone.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/traits_alone.d(11): Error: found `End of File` when expecting `(` fail_compilation/traits_alone.d(11): Error: `__traits(identifier, args...)` expected -fail_compilation/traits_alone.d(11): Error: no identifier for declarator `$r:_?_error_?$` +fail_compilation/traits_alone.d(11): Error: variable name expected after type `$r:_?_error_?$`, not `End of File` --- */ //used to segfault diff --git a/gcc/testsuite/gdc.test/fail_compilation/udaparams.d b/gcc/testsuite/gdc.test/fail_compilation/udaparams.d index 76df55fcfd7..06f4bd8b67b 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/udaparams.d +++ b/gcc/testsuite/gdc.test/fail_compilation/udaparams.d @@ -15,19 +15,19 @@ fail_compilation/udaparams.d(45): Error: `@nogc` attribute for function paramete fail_compilation/udaparams.d(51): Error: cannot put a storage-class in an `alias` declaration. fail_compilation/udaparams.d(52): Error: cannot put a storage-class in an `alias` declaration. fail_compilation/udaparams.d(53): Error: semicolon expected to close `alias` declaration, not `=>` -fail_compilation/udaparams.d(53): Error: declaration expected, not `=>` +fail_compilation/udaparams.d(53): Error: declaration expected, not `1` fail_compilation/udaparams.d(54): Error: semicolon expected to close `alias` declaration, not `=>` -fail_compilation/udaparams.d(54): Error: declaration expected, not `=>` +fail_compilation/udaparams.d(54): Error: declaration expected, not `1` fail_compilation/udaparams.d(57): Error: basic type expected, not `@` fail_compilation/udaparams.d(57): Error: identifier expected for template value parameter fail_compilation/udaparams.d(57): Error: found `@` when expecting `)` fail_compilation/udaparams.d(57): Error: basic type expected, not `3` fail_compilation/udaparams.d(57): Error: found `3` when expecting `)` fail_compilation/udaparams.d(57): Error: semicolon expected following function declaration, not `)` +fail_compilation/udaparams.d(57): Error: variable name expected after type `T`, not `)` fail_compilation/udaparams.d(57): Error: declaration expected, not `)` --- */ - void vararg1(int a, @(10) ...); extern(C) void vararg2(int a, @(10) ...); diff --git a/gcc/testsuite/gdc.test/fail_compilation/var_func_attr.d b/gcc/testsuite/gdc.test/fail_compilation/var_func_attr.d index 0753b13f318..514a86a284c 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/var_func_attr.d +++ b/gcc/testsuite/gdc.test/fail_compilation/var_func_attr.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `__lambda_L19_C27` of type `void function() nothrow @nogc @safe` to `void function() pure` +fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `() { static int g; g++; }` of type `void function() nothrow @nogc @safe` to `void function() pure` --- */ diff --git a/gcc/testsuite/gdc.test/runnable/testaa2.d b/gcc/testsuite/gdc.test/runnable/testaa2.d index ba8ceecc55c..e1abcb4418c 100644 --- a/gcc/testsuite/gdc.test/runnable/testaa2.d +++ b/gcc/testsuite/gdc.test/runnable/testaa2.d @@ -286,6 +286,27 @@ struct PropertyTable10106 CodepointSet10106[string] table; } +/************************************************/ +// strip inout in key and value types +void testinout() +{ + inout(long) func1(inout(long[][int]) aa) + { + return aa[0][0]; + } + long[][int] a = [ 0 : [42] ]; + long b = func1(a); + assert(b == 42); +} + +/************************************************/ +// type info generated for enum creation in InExp? +void testinenum() +{ + enum string[string] aa = [ "one" : "un", "two" : "deux" ]; + assert("one" in aa); +} + /************************************************/ int main() @@ -295,6 +316,8 @@ int main() test4523(); test3825(); test3825x(); + testinout(); + testinenum(); printf("Success\n"); return 0; diff --git a/gcc/testsuite/gdc.test/runnable/testv.d b/gcc/testsuite/gdc.test/runnable/testv.d index d146fd49dbf..51a95a08a61 100644 --- a/gcc/testsuite/gdc.test/runnable/testv.d +++ b/gcc/testsuite/gdc.test/runnable/testv.d @@ -83,39 +83,6 @@ void test3() printf("%d\n", i); } -/*********************************************************/ - -class Foo4 -{ - int a; - float f; - double d; - - this(int a, float f, double d) - { - this.a = a; - this.f = f; - this.d = d; - } -} - -int sum4(Foo4 f ...) -{ - return cast(int)(f.a + f.f + f.d); -} - -void test4() -{ - int i; - Foo4 foo = new Foo4(1, 2f, 3.0); - - i = sum4(foo); - assert(i == 1+2+3); - i = sum4(4, 5f, 6.0); - assert(i == 4+5+6); - - printf("%d\n", i); -} /*********************************************************/ @@ -139,7 +106,6 @@ int main() test1(); test2(); test3(); - test4(); test5(); printf("Success\n"); diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 59d5a184810..66cfdd6ad4a 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -ffbad272b649b7ae3e88cfdc85688bfef3168994 +53a1cc8d13e8db2cb1642219320a8dfc1b0cc6c5 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/libphobos/libdruntime/core/internal/array/appending.d b/libphobos/libdruntime/core/internal/array/appending.d index ba34727a305..1b2b78ea570 100644 --- a/libphobos/libdruntime/core/internal/array/appending.d +++ b/libphobos/libdruntime/core/internal/array/appending.d @@ -52,7 +52,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_arrayappendT, core,internal,array,appending). */ - ref Tarr _d_arrayappendcTXTrace(Tarr : T[], T)(string file, int line, string funcname, return ref scope Tarr px, size_t n) @trusted + ref Tarr _d_arrayappendcTXTrace(Tarr : T[], T)(return ref scope Tarr px, size_t n, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { @@ -115,7 +115,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_arrayappendT, core,internal,array,appending). */ - ref Tarr _d_arrayappendTTrace(Tarr : T[], T)(string file, int line, string funcname, return ref scope Tarr x, scope Tarr y) @trusted + ref Tarr _d_arrayappendTTrace(Tarr : T[], T)(return ref scope Tarr x, scope Tarr y, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { diff --git a/libphobos/libdruntime/core/internal/array/concatenation.d b/libphobos/libdruntime/core/internal/array/concatenation.d index 3063c4c0ea0..13ec5fad40f 100644 --- a/libphobos/libdruntime/core/internal/array/concatenation.d +++ b/libphobos/libdruntime/core/internal/array/concatenation.d @@ -48,7 +48,7 @@ Tret _d_arraycatnTX(Tret, Tarr...)(auto ref Tarr froms) @trusted { // TODO: forward file, line, name from _d_arraycatnTXTrace _d_arraysetlengthTImpl!(typeof(res))._d_arraysetlengthTTrace( - __FILE__, __LINE__, "_d_arraycatnTX", res, totalLen); + res, totalLen, __FILE__, __LINE__, __FUNCTION__); } else { @@ -178,7 +178,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_arraycatnTX, core,internal,array,concatenation). */ - Tret _d_arraycatnTXTrace(Tret, Tarr...)(string file, int line, string funcname, scope auto ref Tarr froms) @trusted + Tret _d_arraycatnTXTrace(Tret, Tarr...)(scope auto ref Tarr froms, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { diff --git a/libphobos/libdruntime/core/internal/array/construction.d b/libphobos/libdruntime/core/internal/array/construction.d index 45a1ce5629d..40e5a61bbde 100644 --- a/libphobos/libdruntime/core/internal/array/construction.d +++ b/libphobos/libdruntime/core/internal/array/construction.d @@ -470,7 +470,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_newitemT, core,lifetime). */ - T[] _d_newarrayTTrace(T)(string file, int line, string funcname, size_t length, bool isShared) @trusted + T[] _d_newarrayTTrace(T)(size_t length, bool isShared, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { @@ -602,7 +602,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_newarraymT, core,internal,array,construction). */ - Tarr _d_newarraymTXTrace(Tarr : U[], T, U)(string file, int line, string funcname, size_t[] dims, bool isShared=false) @trusted + Tarr _d_newarraymTXTrace(Tarr : U[], T, U)(size_t[] dims, bool isShared=false, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { diff --git a/libphobos/libdruntime/core/internal/array/utils.d b/libphobos/libdruntime/core/internal/array/utils.d index 2cda571ba71..deaae3f95da 100644 --- a/libphobos/libdruntime/core/internal/array/utils.d +++ b/libphobos/libdruntime/core/internal/array/utils.d @@ -53,18 +53,6 @@ version (D_ProfileGC) string name = } ~ "`" ~ Type ~ "`;" ~ q{ // FIXME: use rt.tracegc.accumulator when it is accessable in the future. - version (tracegc) - } ~ "{\n" ~ q{ - import core.stdc.stdio : printf; - - printf("%sTrace file = '%.*s' line = %d function = '%.*s' type = %.*s\n", - } ~ "\"" ~ Hook ~ "\".ptr," ~ q{ - file.length, file.ptr, - line, - funcname.length, funcname.ptr, - name.length, name.ptr - ); - } ~ "}\n" ~ q{ ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread; scope(exit) @@ -99,7 +87,7 @@ version (D_ProfileGC) * purity, and throwabilty checks. To prevent breaking existing code, this function template * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. */ - auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, string funcname, Parameters!Hook parameters) @trusted pure + auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(Parameters!Hook parameters, string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted pure { version (D_TypeInfo) { diff --git a/libphobos/libdruntime/core/internal/newaa.d b/libphobos/libdruntime/core/internal/newaa.d index 7c858f33522..47283f28030 100644 --- a/libphobos/libdruntime/core/internal/newaa.d +++ b/libphobos/libdruntime/core/internal/newaa.d @@ -44,7 +44,7 @@ struct Impl Bucket[] buckets; uint used; uint deleted; - TypeInfo_Struct entryTI; + const(TypeInfo) entryTI; uint firstUsed; immutable uint keysz; immutable uint valsz; @@ -75,15 +75,6 @@ private size_t mix(size_t h) @safe pure nothrow @nogc return h; } -struct Entry(K, V) -{ - // can make this const, because we aren't really going to use it aside from - // construction. - const K key; - V value; -} - - // create a binary-compatible AA structure that can be used directly as an // associative array. // NOTE: this must only be called during CTFE @@ -92,7 +83,7 @@ AAShell makeAA(K, V)(V[K] src) @trusted assert(__ctfe, "makeAA Must only be called at compile time"); immutable srclen = src.length; assert(srclen <= uint.max); - alias E = Entry!(K, V); + alias E = TypeInfo_AssociativeArray.Entry!(K, V); if (srclen == 0) return AAShell.init; // first, determine the size that would be used if we grew the bucket list diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d index a088bf6ca2d..49512ab14b4 100644 --- a/libphobos/libdruntime/core/lifetime.d +++ b/libphobos/libdruntime/core/lifetime.d @@ -2788,7 +2788,7 @@ if (is(T == class)) /** * TraceGC wrapper around $(REF _d_newclassT, core,lifetime). */ -T _d_newclassTTrace(T)(string file, int line, string funcname) @trusted +T _d_newclassTTrace(T)(string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { @@ -2985,7 +2985,7 @@ version (D_ProfileGC) /** * TraceGC wrapper around $(REF _d_newitemT, core,lifetime). */ - T* _d_newitemTTrace(T)(string file, int line, string funcname) @trusted + T* _d_newitemTTrace(T)(string file = __FILE__, int line = __LINE__, string funcname = __FUNCTION__) @trusted { version (D_TypeInfo) { diff --git a/libphobos/libdruntime/core/stdc/config.d b/libphobos/libdruntime/core/stdc/config.d index c95fe651407..34f78e03e4a 100644 --- a/libphobos/libdruntime/core/stdc/config.d +++ b/libphobos/libdruntime/core/stdc/config.d @@ -670,3 +670,8 @@ package(core) template muslRedirTime64Mangle(string name, string redirectedName) else enum muslRedirTime64Mangle = name; } + +version (PPC64) + enum PPCUseIEEE128 = real.mant_dig == 113; +else + enum PPCUseIEEE128 = false; diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d index e54d5813995..1f384f9cbd4 100644 --- a/libphobos/libdruntime/core/stdc/math.d +++ b/libphobos/libdruntime/core/stdc/math.d @@ -4284,404 +4284,651 @@ else double acos(double x); /// float acosf(float x); - /// - real acosl(real x); /// double asin(double x); /// float asinf(float x); - /// - real asinl(real x); /// pure double atan(double x); /// pure float atanf(float x); - /// - pure real atanl(real x); /// double atan2(double y, double x); /// float atan2f(float y, float x); - /// - real atan2l(real y, real x); /// pure double cos(double x); /// pure float cosf(float x); - /// - pure real cosl(real x); /// pure double sin(double x); /// pure float sinf(float x); - /// - pure real sinl(real x); /// pure double tan(double x); /// pure float tanf(float x); - /// - pure real tanl(real x); /// double acosh(double x); /// float acoshf(float x); - /// - real acoshl(real x); /// pure double asinh(double x); /// pure float asinhf(float x); - /// - pure real asinhl(real x); /// double atanh(double x); /// float atanhf(float x); - /// - real atanhl(real x); /// double cosh(double x); /// float coshf(float x); - /// - real coshl(real x); /// double sinh(double x); /// float sinhf(float x); - /// - real sinhl(real x); /// pure double tanh(double x); /// pure float tanhf(float x); - /// - pure real tanhl(real x); /// double exp(double x); /// float expf(float x); - /// - real expl(real x); /// double exp2(double x); /// float exp2f(float x); - /// - real exp2l(real x); /// double expm1(double x); /// float expm1f(float x); - /// - real expm1l(real x); /// pure double frexp(double value, int* exp); /// pure float frexpf(float value, int* exp); - /// - pure real frexpl(real value, int* exp); /// int ilogb(double x); /// int ilogbf(float x); - /// - int ilogbl(real x); /// double ldexp(double x, int exp); /// float ldexpf(float x, int exp); - /// - real ldexpl(real x, int exp); /// double log(double x); /// float logf(float x); - /// - real logl(real x); /// double log10(double x); /// float log10f(float x); - /// - real log10l(real x); /// double log1p(double x); /// float log1pf(float x); - /// - real log1pl(real x); /// double log2(double x); /// float log2f(float x); - /// - real log2l(real x); /// double logb(double x); /// float logbf(float x); - /// - real logbl(real x); /// pure double modf(double value, double* iptr); /// pure float modff(float value, float* iptr); - /// - pure real modfl(real value, real *iptr); /// double scalbn(double x, int n); /// float scalbnf(float x, int n); - /// - real scalbnl(real x, int n); /// double scalbln(double x, c_long n); /// float scalblnf(float x, c_long n); - /// - real scalblnl(real x, c_long n); /// pure double cbrt(double x); /// pure float cbrtf(float x); - /// - pure real cbrtl(real x); /// pure double fabs(double x); - version (CRuntime_Microsoft) - { - } - else - { - /// - pure float fabsf(float x); - /// - pure real fabsl(real x); - } /// double hypot(double x, double y); /// float hypotf(float x, float y); - /// - real hypotl(real x, real y); /// double pow(double x, double y); /// float powf(float x, float y); - /// - real powl(real x, real y); /// double sqrt(double x); /// float sqrtf(float x); - /// - real sqrtl(real x); /// pure double erf(double x); /// pure float erff(float x); - /// - pure real erfl(real x); /// double erfc(double x); /// float erfcf(float x); - /// - real erfcl(real x); /// double lgamma(double x); /// float lgammaf(float x); - /// - real lgammal(real x); /// double tgamma(double x); /// float tgammaf(float x); - /// - real tgammal(real x); /// pure double ceil(double x); /// pure float ceilf(float x); - /// - pure real ceill(real x); /// pure double floor(double x); /// pure float floorf(float x); - /// - pure real floorl(real x); /// pure double nearbyint(double x); /// pure float nearbyintf(float x); - /// - pure real nearbyintl(real x); /// pure double rint(double x); /// pure float rintf(float x); - /// - pure real rintl(real x); /// c_long lrint(double x); /// c_long lrintf(float x); - /// - c_long lrintl(real x); /// long llrint(double x); /// long llrintf(float x); - /// - long llrintl(real x); /// pure double round(double x); /// pure float roundf(float x); - /// - pure real roundl(real x); /// c_long lround(double x); /// c_long lroundf(float x); - /// - c_long lroundl(real x); /// long llround(double x); /// long llroundf(float x); - /// - long llroundl(real x); /// pure double trunc(double x); /// pure float truncf(float x); - /// - pure real truncl(real x); /// double fmod(double x, double y); /// float fmodf(float x, float y); - /// - real fmodl(real x, real y); /// double remainder(double x, double y); /// float remainderf(float x, float y); - /// - real remainderl(real x, real y); /// double remquo(double x, double y, int* quo); /// float remquof(float x, float y, int* quo); - /// - real remquol(real x, real y, int* quo); /// pure double copysign(double x, double y); /// pure float copysignf(float x, float y); - /// - pure real copysignl(real x, real y); /// pure double nan(char* tagp); /// pure float nanf(char* tagp); - /// - pure real nanl(char* tagp); /// double nextafter(double x, double y); /// float nextafterf(float x, float y); /// - real nextafterl(real x, real y); - - /// - double nexttoward(double x, real y); - /// - float nexttowardf(float x, real y); - /// - real nexttowardl(real x, real y); /// double fdim(double x, double y); /// float fdimf(float x, float y); - /// - real fdiml(real x, real y); /// pure double fmax(double x, double y); /// pure float fmaxf(float x, float y); - /// - pure real fmaxl(real x, real y); + /// pure double fmin(double x, double y); /// pure float fminf(float x, float y); - /// - pure real fminl(real x, real y); + /// pure double fma(double x, double y, double z); /// pure float fmaf(float x, float y, float z); - /// - pure real fmal(real x, real y, real z); + + + static if (PPCUseIEEE128) { + /// + real __acosieee128(real x); + /// + alias acosl = __acosieee128; + /// + real __asinieee128(real x); + /// + alias asinl = __asinieee128; + /// + pure real __atanieee128(real x); + /// + alias atanl = __atanieee128; + /// + real __atan2ieee128(real y, real x); + /// + alias atan2l = __atan2ieee128; + /// + pure real __cosieee128(real x); + /// + alias cosl = __cosieee128; + /// + pure real __sinieee128(real x); + /// + alias sinl = __sinieee128; + /// + pure real __tanieee128(real x); + /// + alias tanl = __tanieee128; + /// + real __acoshieee128(real x); + /// + alias acoshl = __acoshieee128; + /// + pure real __asinhieee128(real x); + /// + alias asinhl = __asinhieee128; + /// + real __atanhieee128(real x); + /// + alias atanhl = __atanhieee128; + /// + real __coshieee128(real x); + /// + alias coshl = __coshieee128; + /// + real __sinhieee128(real x); + /// + alias sinhl = __sinhieee128; + /// + pure real __tanhieee128(real x); + /// + alias tanhl = __tanhieee128; + /// + real __expieee128(real x); + /// + alias expl = __expieee128; + /// + real __exp2ieee128(real x); + /// + alias exp2l = __exp2ieee128; + /// + real __expm1ieee128(real x); + /// + alias expm1l = __expm1ieee128; + /// + pure real __frexpieee128(real value, int* exp); + /// + alias frexpl = __frexpieee128; + /// + int __ilogbieee128(real x); + /// + alias ilogbl = __ilogbieee128; + /// + real __ldexpieee128(real x, int exp); + /// + alias ldexpl = __ldexpieee128; + /// + real __logieee128(real x); + /// + alias logl = __logieee128; + /// + real __log10ieee128(real x); + /// + alias log10l = __log10ieee128; + /// + real __log1pieee128(real x); + /// + alias log1pl = __log1pieee128; + /// + real __log2ieee128(real x); + /// + alias log2l = __log2ieee128; + /// + real __logbieee128(real x); + /// + alias logbl = __logbieee128; + /// + pure real __modfieee128(real value, real *iptr); + /// + alias modfl = __modfieee128; + /// + real __scalbnieee128(real x, int n); + /// + alias scalbnl = __scalbnieee128; + /// + real __scalblnieee128(real x, c_long n); + /// + alias scalblnl = __scalblnieee128; + /// + pure real __cbrtieee128(real x); + /// + alias cbrtl = __cbrtieee128; + /// + pure float fabsf(float x); + /// + pure real __fabsieee128(real x); + /// + alias fabsl = __fabsieee128; + /// + real __hypotieee128(real x, real y); + /// + alias hypotl = __hypotieee128; + /// + real __powieee128(real x, real y); + /// + alias powl = __powieee128; + /// + real __sqrtieee128(real x); + /// + alias sqrtl = __sqrtieee128; + /// + pure real __erfieee128(real x); + /// + alias erfl = __erfieee128; + /// + real __erfcieee128(real x); + /// + alias erfcl = __erfcieee128; + /// + real __lgammaieee128(real x); + /// + alias lgammal = __lgammaieee128; + /// + real __tgammaieee128(real x); + /// + alias tgammal = __tgammaieee128; + /// + pure real __ceilieee128(real x); + /// + alias ceill = __ceilieee128; + /// + pure real __floorieee128(real x); + /// + alias floorl = __floorieee128; + /// + pure real __nearbyintieee128(real x); + /// + alias nearbyintl = __nearbyintieee128; + /// + pure real __rintieee128(real x); + /// + alias rintl = __rintieee128; + /// + c_long __lrintieee128(real x); + /// + alias lrintl = __lrintieee128; + /// + long __llrintieee128(real x); + /// + alias llrintl = __llrintieee128; + /// + pure real __roundieee128(real x); + /// + alias roundl = __roundieee128; + /// + c_long __lroundieee128(real x); + /// + alias lroundl = __lroundieee128; + /// + long __llroundieee128(real x); + /// + alias llroundl = __llroundieee128; + /// + pure real __truncieee128(real x); + /// + alias truncl = __truncieee128; + /// + real __fmodieee128(real x, real y); + /// + alias fmodl = __fmodieee128; + /// + real __remainderieee128(real x, real y); + /// + alias remainderl = __remainderieee128; + /// + real __remquoieee128(real x, real y, int* quo); + /// + alias remquol = __remquoieee128; + /// + pure real __copysignieee128(real x, real y); + /// + alias copysignl = __copysignieee128; + /// + pure real __nanieee128(char* tagp); + /// + alias nanl = __nanieee128; + /// + real __nextafterieee128(real x, real y); + /// + alias nextafterl = __nextafterieee128; + /// + double __nexttoward_to_ieee128(double x, real y); + /// + alias nexttoward = __nexttoward_to_ieee128; + /// + float __nexttowardf_to_ieee128(float x, real y); + /// + alias nexttowardf = __nexttowardf_to_ieee128; + /// + real __nexttowardieee128(real x, real y); + /// + alias nexttowardl = __nexttowardieee128; + /// + real __fdimieee128(real x, real y); + /// + alias fdiml = __fdimieee128; + /// + pure real __fmaxieee128(real x, real y); + /// + alias fmaxl = __fmaxieee128; + /// + pure real __fminieee128(real x, real y); + /// + alias fminl = __fminieee128; + /// + pure real __fmaieee128(real x, real y, real z); + /// + alias fmal = __fmaieee128; + } + else + { + /// + real acosl(real x); + /// + real asinl(real x); + /// + pure real atanl(real x); + /// + real atan2l(real y, real x); + /// + pure real cosl(real x); + /// + pure real sinl(real x); + /// + pure real tanl(real x); + /// + real acoshl(real x); + /// + pure real asinhl(real x); + /// + real atanhl(real x); + /// + real coshl(real x); + /// + real sinhl(real x); + /// + pure real tanhl(real x); + /// + real expl(real x); + /// + real exp2l(real x); + /// + real expm1l(real x); + /// + pure real frexpl(real value, int* exp); + /// + int ilogbl(real x); + /// + real ldexpl(real x, int exp); + /// + real logl(real x); + /// + real log10l(real x); + /// + real log1pl(real x); + /// + real log2l(real x); + /// + real logbl(real x); + /// + pure real modfl(real value, real *iptr); + /// + real scalbnl(real x, int n); + /// + real scalblnl(real x, c_long n); + /// + pure real cbrtl(real x); + version (CRuntime_Microsoft) + { + } + else + { + /// + pure float fabsf(float x); + /// + pure real fabsl(real x); + } + /// + real hypotl(real x, real y); + /// + real powl(real x, real y); + /// + real sqrtl(real x); + /// + pure real erfl(real x); + /// + real erfcl(real x); + /// + real lgammal(real x); + /// + real tgammal(real x); + /// + pure real ceill(real x); + /// + pure real floorl(real x); + /// + pure real nearbyintl(real x); + /// + pure real rintl(real x); + /// + c_long lrintl(real x); + /// + long llrintl(real x); + /// + pure real roundl(real x); + /// + c_long lroundl(real x); + /// + long llroundl(real x); + /// + pure real truncl(real x); + /// + real fmodl(real x, real y); + /// + real remainderl(real x, real y); + /// + real remquol(real x, real y, int* quo); + /// + pure real copysignl(real x, real y); + /// + pure real nanl(char* tagp); + /// + real nextafterl(real x, real y); + /// + double nexttoward(double x, real y); + /// + float nexttowardf(float x, real y); + /// + real nexttowardl(real x, real y); + /// + real fdiml(real x, real y); + /// + pure real fmaxl(real x, real y); + /// + pure real fminl(real x, real y); + /// + pure real fmal(real x, real y, real z); + } } diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index d3ee2cae8e5..c9b6d7b6b7e 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -1303,54 +1303,118 @@ version (MinGW) } else version (CRuntime_Glibc) { - /// - pragma(printf) - int fprintf(FILE* stream, scope const char* format, scope const ...); - /// - pragma(scanf) - int __isoc99_fscanf(FILE* stream, scope const char* format, scope ...); - /// - alias fscanf = __isoc99_fscanf; - /// - pragma(printf) - int sprintf(scope char* s, scope const char* format, scope const ...); - /// - pragma(scanf) - int __isoc99_sscanf(scope const char* s, scope const char* format, scope ...); - /// - alias sscanf = __isoc99_sscanf; - /// - pragma(printf) - int vfprintf(FILE* stream, scope const char* format, va_list arg); - /// - pragma(scanf) - int __isoc99_vfscanf(FILE* stream, scope const char* format, va_list arg); - /// - alias vfscanf = __isoc99_vfscanf; - /// - pragma(printf) - int vsprintf(scope char* s, scope const char* format, va_list arg); - /// - pragma(scanf) - int __isoc99_vsscanf(scope const char* s, scope const char* format, va_list arg); - /// - alias vsscanf = __isoc99_vsscanf; - /// - pragma(printf) - int vprintf(scope const char* format, va_list arg); - /// - pragma(scanf) - int __isoc99_vscanf(scope const char* format, va_list arg); - /// - alias vscanf = __isoc99_vscanf; - /// - pragma(printf) - int printf(scope const char* format, scope const ...); - /// - pragma(scanf) - int __isoc99_scanf(scope const char* format, scope ...); - /// - alias scanf = __isoc99_scanf; + static if (PPCUseIEEE128) + { + /// + pragma(printf) + int __fprintfieee128(FILE* stream, scope const char* format, scope const ...); + /// + alias fprintf = __fprintfieee128; + /// + pragma(scanf) + int __isoc99_fscanfieee128(FILE* stream, scope const char* format, scope ...); + /// + alias fscanf = __isoc99_fscanfieee128; + /// + pragma(printf) + int __sprintfieee128(scope char* s, scope const char* format, scope const ...); + /// + alias sprintf = __sprintfieee128; + /// + pragma(scanf) + int __isoc99_sscanfieee128(scope const char* s, scope const char* format, scope ...); + /// + alias sscanf = __isoc99_sscanfieee128; + /// + pragma(printf) + int vfprintf(FILE* stream, scope const char* format, va_list arg); + /// + pragma(scanf) + int __isoc99_vfscanfieee128(FILE* stream, scope const char* format, va_list arg); + /// + alias vfscanf = __isoc99_vfscanfieee128; + /// + pragma(printf) + int __vsprintfieee128(scope char* s, scope const char* format, va_list arg); + /// + alias vsprintf = __vsprintfieee128; + /// + pragma(scanf) + int __isoc99_vsscanfieee128(scope const char* s, scope const char* format, va_list arg); + /// + alias vsscanf = __isoc99_vsscanfieee128; + /// + pragma(printf) + int __vprintfieee128(scope const char* format, va_list arg); + /// + alias vprintf = __vprintfieee128; + /// + pragma(scanf) + int __isoc99_vfscanfieee128(scope const char* format, va_list arg); + /// + alias vscanf = __isoc99_vfscanfieee128; + /// + pragma(printf) + int __printfieee128(scope const char* format, scope const ...); + /// + alias printf = __printfieee128; + /// + pragma(scanf) + int __isoc99_scanfieee128(scope const char* format, scope ...); + /// + alias scanf = __isoc99_scanfieee128; + } + else + { + /// + pragma(printf) + int fprintf(FILE* stream, scope const char* format, scope const ...); + /// + pragma(scanf) + int __isoc99_fscanf(FILE* stream, scope const char* format, scope ...); + /// + alias fscanf = __isoc99_fscanf; + /// + pragma(printf) + int sprintf(scope char* s, scope const char* format, scope const ...); + /// + pragma(scanf) + int __isoc99_sscanf(scope const char* s, scope const char* format, scope ...); + /// + alias sscanf = __isoc99_sscanf; + /// + pragma(printf) + int vfprintf(FILE* stream, scope const char* format, va_list arg); + /// + pragma(scanf) + int __isoc99_vfscanf(FILE* stream, scope const char* format, va_list arg); + /// + alias vfscanf = __isoc99_vfscanf; + /// + pragma(printf) + int vsprintf(scope char* s, scope const char* format, va_list arg); + /// + pragma(scanf) + int __isoc99_vsscanf(scope const char* s, scope const char* format, va_list arg); + /// + alias vsscanf = __isoc99_vsscanf; + /// + pragma(printf) + int vprintf(scope const char* format, va_list arg); + /// + pragma(scanf) + int __isoc99_vscanf(scope const char* format, va_list arg); + /// + alias vscanf = __isoc99_vscanf; + /// + pragma(printf) + int printf(scope const char* format, scope const ...); + /// + pragma(scanf) + int __isoc99_scanf(scope const char* format, scope ...); + /// + alias scanf = __isoc99_scanf; + } } else { @@ -1544,12 +1608,28 @@ else version (CRuntime_Glibc) int fileno(FILE *); } - /// - pragma(printf) - int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); - /// - pragma(printf) - int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); + static if (PPCUseIEEE128) + { + /// + pragma(printf) + int __snprintfieee128(scope char* s, size_t n, scope const char* format, scope const ...); + /// + alias snprintf = __snprintfieee128; + /// + pragma(printf) + int __vsnprintfieee128(scope char* s, size_t n, scope const char* format, va_list arg); + /// + alias vsnprintf = __vsnprintfieee128; + } + else + { + /// + pragma(printf) + int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); + /// + pragma(printf) + int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); + } // // Gnu under-the-hood C I/O functions. Uses _iobuf* for the unshared diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d index bd5fc2b15ea..52fa1d0f70c 100644 --- a/libphobos/libdruntime/core/stdc/stdlib.d +++ b/libphobos/libdruntime/core/stdc/stdlib.d @@ -147,8 +147,16 @@ version (CRuntime_Microsoft) } else { - /// Added to Bionic since Lollipop. - real strtold(scope inout(char)* nptr, scope inout(char)** endptr); + static if (PPCUseIEEE128) + { + real __strtoieee128(scope inout(char)* nptr, scope inout(char)** endptr); + alias strtold = __strtoieee128; + } + else + { + /// Added to Bionic since Lollipop. + real strtold(scope inout(char)* nptr, scope inout(char)** endptr); + } } // No unsafe pointer manipulation. diff --git a/libphobos/libdruntime/core/sys/windows/sql.d b/libphobos/libdruntime/core/sys/windows/sql.d index 9054ce589e8..013d9f06e60 100644 --- a/libphobos/libdruntime/core/sys/windows/sql.d +++ b/libphobos/libdruntime/core/sys/windows/sql.d @@ -11,13 +11,15 @@ $(RED Warning: */ module core.sys.windows.sql; + +enum ODBCVER = 0x0400; + +deprecated ("The ODBC 3.5 modules are deprecated. Please use the ODBC4 modules in the `etc.c.odbc` package."): version (Windows): public import core.sys.windows.sqltypes; import core.sys.windows.windef; -enum ODBCVER = 0x0351; - enum SQL_ACCESSIBLE_PROCEDURES=20; enum SQL_ACCESSIBLE_TABLES=19; enum SQL_ALL_TYPES=0; diff --git a/libphobos/libdruntime/core/sys/windows/sqlext.d b/libphobos/libdruntime/core/sys/windows/sqlext.d index b871fbbbb84..a53918394dc 100644 --- a/libphobos/libdruntime/core/sys/windows/sqlext.d +++ b/libphobos/libdruntime/core/sys/windows/sqlext.d @@ -11,6 +11,7 @@ $(RED Warning: */ module core.sys.windows.sqlext; +deprecated ("The ODBC 3.5 modules are deprecated. Please use the ODBC4 modules in the `etc.c.odbc` package."): version (Windows): /* Conversion notes: diff --git a/libphobos/libdruntime/core/sys/windows/sqltypes.d b/libphobos/libdruntime/core/sys/windows/sqltypes.d index 04fac6bac6a..ca91f015851 100644 --- a/libphobos/libdruntime/core/sys/windows/sqltypes.d +++ b/libphobos/libdruntime/core/sys/windows/sqltypes.d @@ -70,6 +70,10 @@ alias long ODBCINT64, SQLBIGINT; alias ulong SQLUBIGINT; //} +//Everything above this line may by used by odbcinst.d +//Everything below this line is deprecated +deprecated ("The ODBC 3.5 modules are deprecated. Please use the ODBC4 modules in the `etc.c.odbc` package."): + struct DATE_STRUCT { SQLSMALLINT year; SQLUSMALLINT month; diff --git a/libphobos/libdruntime/core/sys/windows/sqlucode.d b/libphobos/libdruntime/core/sys/windows/sqlucode.d index e7ae1d276be..d20952d5b4b 100644 --- a/libphobos/libdruntime/core/sys/windows/sqlucode.d +++ b/libphobos/libdruntime/core/sys/windows/sqlucode.d @@ -11,6 +11,7 @@ $(RED Warning: */ module core.sys.windows.sqlucode; +deprecated ("The ODBC 3.5 modules are deprecated. Please use the ODBC4 modules in the `etc.c.odbc` package."): version (Windows): version (ANSI) {} else version = Unicode; diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d index d8389ae491f..e274fd30e8c 100644 --- a/libphobos/libdruntime/object.d +++ b/libphobos/libdruntime/object.d @@ -1324,8 +1324,16 @@ class TypeInfo_AssociativeArray : TypeInfo override @property inout(TypeInfo) next() nothrow pure inout { return value; } override @property uint flags() nothrow pure const { return 1; } + // TypeInfo entry is generated from the type of this template to help rt/aaA.d + static struct Entry(K, V) + { + K key; + V value; + } + TypeInfo value; TypeInfo key; + TypeInfo entry; override @property size_t talign() nothrow pure const { diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d index 2bddeaf41d7..3b4bee04058 100644 --- a/libphobos/libdruntime/rt/aaA.d +++ b/libphobos/libdruntime/rt/aaA.d @@ -66,13 +66,13 @@ private: if ((ti.key.flags | ti.value.flags) & 1) flags |= Flags.hasPointers; - entryTI = fakeEntryTI(this, ti.key, ti.value); + entryTI = ti.entry; } Bucket[] buckets; uint used; uint deleted; - TypeInfo_Struct entryTI; + const(TypeInfo) entryTI; uint firstUsed; immutable uint keysz; immutable uint valsz; @@ -229,15 +229,6 @@ private void* allocEntry(scope const Impl* aa, scope const void* pkey) return res; } -package void entryDtor(void* p, const TypeInfo_Struct sti) -{ - // key and value type info stored after the TypeInfo_Struct by tiEntry() - auto sizeti = __traits(classInstanceSize, TypeInfo_Struct); - auto extra = cast(const(TypeInfo)*)(cast(void*) sti + sizeti); - extra[0].destroy(p); - extra[1].destroy(p + talign(extra[0].tsize, extra[1].talign)); -} - private bool hasDtor(const TypeInfo ti) pure nothrow { import rt.lifetime : unqualify; @@ -258,132 +249,6 @@ private immutable(void)* getRTInfo(const TypeInfo ti) pure nothrow return isNoClass ? ti.rtInfo() : rtinfoHasPointers; } -// build type info for Entry with additional key and value fields -TypeInfo_Struct fakeEntryTI(ref Impl aa, const TypeInfo keyti, const TypeInfo valti) nothrow -{ - import rt.lifetime : unqualify; - - auto kti = unqualify(keyti); - auto vti = unqualify(valti); - - // figure out whether RTInfo has to be generated (indicated by rtisize > 0) - enum pointersPerWord = 8 * (void*).sizeof * (void*).sizeof; - auto rtinfo = rtinfoNoPointers; - size_t rtisize = 0; - immutable(size_t)* keyinfo = void; - immutable(size_t)* valinfo = void; - if (aa.flags & Impl.Flags.hasPointers) - { - // classes are references - keyinfo = cast(immutable(size_t)*) getRTInfo(keyti); - valinfo = cast(immutable(size_t)*) getRTInfo(valti); - - if (keyinfo is rtinfoHasPointers && valinfo is rtinfoHasPointers) - rtinfo = rtinfoHasPointers; - else - rtisize = 1 + (aa.valoff + aa.valsz + pointersPerWord - 1) / pointersPerWord; - } - bool entryHasDtor = hasDtor(kti) || hasDtor(vti); - if (rtisize == 0 && !entryHasDtor) - return null; - - // save kti and vti after type info for struct - enum sizeti = __traits(classInstanceSize, TypeInfo_Struct); - void* p = GC.malloc(sizeti + (2 + rtisize) * (void*).sizeof); - import core.stdc.string : memcpy; - - memcpy(p, __traits(initSymbol, TypeInfo_Struct).ptr, sizeti); - - auto ti = cast(TypeInfo_Struct) p; - auto extra = cast(TypeInfo*)(p + sizeti); - extra[0] = cast() kti; - extra[1] = cast() vti; - - static immutable tiMangledName = "S2rt3aaA__T5EntryZ"; - ti.mangledName = tiMangledName; - - ti.m_RTInfo = rtisize > 0 ? rtinfoEntry(aa, keyinfo, valinfo, cast(size_t*)(extra + 2), rtisize) : rtinfo; - ti.m_flags = ti.m_RTInfo is rtinfoNoPointers ? cast(TypeInfo_Struct.StructFlags)0 : TypeInfo_Struct.StructFlags.hasPointers; - - // we don't expect the Entry objects to be used outside of this module, so we have control - // over the non-usage of the callback methods and other entries and can keep these null - // xtoHash, xopEquals, xopCmp, xtoString and xpostblit - immutable entrySize = aa.valoff + aa.valsz; - ti.m_init = (cast(ubyte*) null)[0 .. entrySize]; // init length, but not ptr - - if (entryHasDtor) - { - // xdtor needs to be built from the dtors of key and value for the GC - ti.xdtorti = &entryDtor; - ti.m_flags |= TypeInfo_Struct.StructFlags.isDynamicType; - } - - ti.m_align = cast(uint) max(kti.talign, vti.talign); - - return ti; -} - -// build appropriate RTInfo at runtime -immutable(void)* rtinfoEntry(ref Impl aa, immutable(size_t)* keyinfo, - immutable(size_t)* valinfo, size_t* rtinfoData, size_t rtinfoSize) pure nothrow -{ - enum bitsPerWord = 8 * size_t.sizeof; - - rtinfoData[0] = aa.valoff + aa.valsz; - rtinfoData[1..rtinfoSize] = 0; - - void copyKeyInfo(string src)() - { - size_t pos = 1; - size_t keybits = aa.keysz / (void*).sizeof; - while (keybits >= bitsPerWord) - { - rtinfoData[pos] = mixin(src); - keybits -= bitsPerWord; - pos++; - } - if (keybits > 0) - rtinfoData[pos] = mixin(src) & ((size_t(1) << keybits) - 1); - } - - if (keyinfo is rtinfoHasPointers) - copyKeyInfo!"~size_t(0)"(); - else if (keyinfo !is rtinfoNoPointers) - copyKeyInfo!"keyinfo[pos]"(); - - void copyValInfo(string src)() - { - size_t bitpos = aa.valoff / (void*).sizeof; - size_t pos = 1; - size_t dstpos = 1 + bitpos / bitsPerWord; - size_t begoff = bitpos % bitsPerWord; - size_t valbits = aa.valsz / (void*).sizeof; - size_t endoff = (bitpos + valbits) % bitsPerWord; - for (;;) - { - const bits = bitsPerWord - begoff; - size_t s = mixin(src); - rtinfoData[dstpos] |= s << begoff; - if (begoff > 0 && valbits > bits) - rtinfoData[dstpos+1] |= s >> bits; - if (valbits < bitsPerWord) - break; - valbits -= bitsPerWord; - dstpos++; - pos++; - } - if (endoff > 0) - rtinfoData[dstpos] &= (size_t(1) << endoff) - 1; - } - - if (valinfo is rtinfoHasPointers) - copyValInfo!"~size_t(0)"(); - else if (valinfo !is rtinfoNoPointers) - copyValInfo!"valinfo[pos]"(); - - return cast(immutable(void)*) rtinfoData; -} - unittest { void test(K, V)() @@ -402,12 +267,10 @@ unittest if (valrti is rtinfoNoPointers && keyrti is rtinfoNoPointers) { assert(!(impl.flags & Impl.Flags.hasPointers)); - assert(impl.entryTI is null); } else if (valrti is rtinfoHasPointers && keyrti is rtinfoHasPointers) { assert(impl.flags & Impl.Flags.hasPointers); - assert(impl.entryTI is null); } else { @@ -977,7 +840,10 @@ unittest aa1 = null; aa2 = null; aa3 = null; - GC.runFinalizers((cast(char*)&entryDtor)[0 .. 1]); + auto dtor1 = typeid(TypeInfo_AssociativeArray.Entry!(int, T)).xdtor; + GC.runFinalizers((cast(char*)dtor1)[0 .. 1]); + auto dtor2 = typeid(TypeInfo_AssociativeArray.Entry!(T, int)).xdtor; + GC.runFinalizers((cast(char*)dtor2)[0 .. 1]); assert(T.dtor == 6 && T.postblit == 2); } diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d index b63a5bf5266..f77d8b9c4e8 100644 --- a/libphobos/libdruntime/rt/lifetime.d +++ b/libphobos/libdruntime/rt/lifetime.d @@ -1587,16 +1587,13 @@ deprecated unittest GC.free(blkinf.base); // associative arrays - import rt.aaA : entryDtor; - // throw away all existing AA entries with dtor - GC.runFinalizers((cast(char*)&entryDtor)[0..1]); - S1[int] aa1; aa1[0] = S1(0); aa1[1] = S1(1); dtorCount = 0; aa1 = null; - GC.runFinalizers((cast(char*)&entryDtor)[0..1]); + auto dtor1 = typeid(TypeInfo_AssociativeArray.Entry!(int, S1)).xdtor; + GC.runFinalizers((cast(char*)dtor1)[0..1]); assert(dtorCount == 2); int[S1] aa2; @@ -1605,7 +1602,8 @@ deprecated unittest aa2[S1(2)] = 2; dtorCount = 0; aa2 = null; - GC.runFinalizers((cast(char*)&entryDtor)[0..1]); + auto dtor2 = typeid(TypeInfo_AssociativeArray.Entry!(S1, int)).xdtor; + GC.runFinalizers((cast(char*)dtor2)[0..1]); assert(dtorCount == 3); S1[2][int] aa3; @@ -1613,7 +1611,8 @@ deprecated unittest aa3[1] = [S1(1),S1(3)]; dtorCount = 0; aa3 = null; - GC.runFinalizers((cast(char*)&entryDtor)[0..1]); + auto dtor3 = typeid(TypeInfo_AssociativeArray.Entry!(int, S1[2])).xdtor; + GC.runFinalizers((cast(char*)dtor3)[0..1]); assert(dtorCount == 4); }