d: Merge dmd, druntime c7902293d7, phobos 03aeafd20
D front-end changes: - Import dmd v2.110.0-rc.1. - An error is now given for subtracting pointers of different types. D runtime changes: - Import druntime v2.110.0-rc.1. Phobos changes: - Import phobos v2.110.0-rc.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd c7902293d7. * dmd/VERSION: Bump version to v2.110.0-rc.1. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c7902293d7. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Rename core/thread/fiber.d to core/thread/fiber/package.d. Add core/thread/fiber/base.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 63fdb282f. gcc/testsuite/ChangeLog: * gdc.dg/asm3.d: Adjust test. * gdc.dg/torture/pr96435.d: Adjust test.
This commit is contained in:
parent
f4fa0b7d49
commit
a2e540bf01
219 changed files with 2334 additions and 1769 deletions
|
@ -1,4 +1,4 @@
|
|||
c57da0cf5945cfb45eed06f1fd820435cda3ee3a
|
||||
c7902293d7df9d02546562cb09fc8439004a70d1
|
||||
|
||||
The first line of this file holds the git revision number of the last
|
||||
merge done from the dlang/dmd repository.
|
||||
|
|
|
@ -1 +1 @@
|
|||
v2.110.0-beta.1
|
||||
v2.110.0-rc.1
|
||||
|
|
|
@ -322,7 +322,7 @@ extern (C++) final class StaticForeach : RootObject
|
|||
{
|
||||
foreach (params; pparams)
|
||||
{
|
||||
auto p = aggrfe ? (*aggrfe.parameters)[i] : rangefe.prm;
|
||||
auto p = aggrfe ? (*aggrfe.parameters)[i] : rangefe.param;
|
||||
params.push(new Parameter(aloc, p.storageClass, p.type, p.ident, null, null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,8 +465,7 @@ Expression resolveSlice(Expression e, UnionExp* pue = null)
|
|||
*pue = Slice(e.type, se.e1, se.lwr, se.upr);
|
||||
return pue.exp();
|
||||
}
|
||||
else
|
||||
return Slice(e.type, se.e1, se.lwr, se.upr).copy();
|
||||
return Slice(e.type, se.e1, se.lwr, se.upr).copy();
|
||||
}
|
||||
|
||||
/* Determine the array length, without interpreting it.
|
||||
|
|
|
@ -491,7 +491,7 @@ MATCH implicitConvTo(Expression e, Type t)
|
|||
case Tint16:
|
||||
if (ty == Tuns64 && value & ~0x7FFFU)
|
||||
return MATCH.nomatch;
|
||||
else if (cast(short)value != value)
|
||||
if (cast(short)value != value)
|
||||
return MATCH.nomatch;
|
||||
break;
|
||||
|
||||
|
@ -3261,7 +3261,7 @@ Expression scaleFactor(BinExp be, Scope* sc)
|
|||
if (eoff.op == EXP.int64 && eoff.toInteger() == 0)
|
||||
{
|
||||
}
|
||||
else if (sc.setUnsafe(false, be.loc, "pointer arithmetic not allowed in @safe functions"))
|
||||
else if (sc.setUnsafe(false, be.loc, "pointer arithmetic"))
|
||||
{
|
||||
return ErrorExp.get();
|
||||
}
|
||||
|
|
|
@ -632,6 +632,8 @@ public:
|
|||
bool nothrowInprocess(bool v);
|
||||
bool nogcInprocess() const;
|
||||
bool nogcInprocess(bool v);
|
||||
bool saferD() const;
|
||||
bool saferD(bool v);
|
||||
bool scopeInprocess() const;
|
||||
bool scopeInprocess(bool v);
|
||||
bool inlineScanned() const;
|
||||
|
|
|
@ -72,8 +72,51 @@ private extern (D) struct BitFields
|
|||
bool canFree; /// is on free list
|
||||
bool fullinst; /// fully instantiate templates
|
||||
bool ctfeBlock; /// inside a `if (__ctfe)` block
|
||||
bool dip1000; /// dip1000 errors enabled for this scope
|
||||
bool dip25; /// dip25 errors enabled for this scope
|
||||
}
|
||||
|
||||
/// State of -preview switches
|
||||
///
|
||||
/// By making them part of a Scope, we reduce reliance on dmd.globals,
|
||||
/// and can enable/disable them per module / edition.
|
||||
private struct Previews
|
||||
{
|
||||
// Run `dmd -preview=h` for the meaning of these switches
|
||||
private extern (D) static struct BitFields
|
||||
{
|
||||
bool bitfields;
|
||||
bool dip1000;
|
||||
bool dip1008;
|
||||
bool dip1021;
|
||||
bool dip25;
|
||||
bool fixAliasThis;
|
||||
bool fixImmutableConv;
|
||||
bool in_;
|
||||
bool inclusiveInContracts;
|
||||
bool noSharedAccess;
|
||||
bool rvalueRefParam;
|
||||
bool safer;
|
||||
FeatureState systemVariables;
|
||||
}
|
||||
|
||||
import dmd.common.bitfields : generateBitFields;
|
||||
mixin(generateBitFields!(BitFields, ushort));
|
||||
|
||||
void setFromParams(ref Param params) @nogc nothrow pure @safe
|
||||
{
|
||||
this.bitfields = params.bitfields;
|
||||
this.dip1000 = params.useDIP1000 == FeatureState.enabled;
|
||||
this.dip1008 = params.ehnogc;
|
||||
this.dip1021 = params.useDIP1021; // == FeatureState.enabled;
|
||||
this.dip25 = params.useDIP25 == FeatureState.enabled;
|
||||
this.fixAliasThis = params.fixAliasThis;
|
||||
this.fixImmutableConv = params.fixImmutableConv;
|
||||
this.in_ = params.previewIn;
|
||||
this.inclusiveInContracts = params.inclusiveInContracts;
|
||||
this.noSharedAccess = params.noSharedAccess == FeatureState.enabled;
|
||||
this.rvalueRefParam = params.rvalueRefParam == FeatureState.enabled;
|
||||
this.safer = params.safer == FeatureState.enabled;
|
||||
this.systemVariables = params.systemVariables;
|
||||
}
|
||||
}
|
||||
|
||||
extern (C++) struct Scope
|
||||
|
@ -136,7 +179,9 @@ extern (C++) struct Scope
|
|||
DeprecatedDeclaration depdecl; /// customized deprecation message
|
||||
|
||||
import dmd.common.bitfields : generateBitFields;
|
||||
mixin(generateBitFields!(BitFields, uint));
|
||||
mixin(generateBitFields!(BitFields, ushort));
|
||||
|
||||
Previews previews;
|
||||
|
||||
// user defined attributes
|
||||
UserAttributeDeclaration userAttribDecl;
|
||||
|
@ -181,10 +226,8 @@ extern (C++) struct Scope
|
|||
m = m.parent;
|
||||
m.addMember(null, sc.scopesym);
|
||||
m.parent = null; // got changed by addMember()
|
||||
if (global.params.useDIP1000 == FeatureState.enabled)
|
||||
sc.dip1000 = true;
|
||||
if (global.params.useDIP25 == FeatureState.enabled)
|
||||
sc.dip25 = true;
|
||||
sc.previews.setFromParams(global.params);
|
||||
|
||||
if (_module.filetype == FileType.c)
|
||||
sc.inCfile = true;
|
||||
// Create the module scope underneath the global scope
|
||||
|
@ -236,9 +279,7 @@ extern (C++) struct Scope
|
|||
s.ignoresymbolvisibility = this.ignoresymbolvisibility;
|
||||
s.inCfile = this.inCfile;
|
||||
s.ctfeBlock = this.ctfeBlock;
|
||||
s.dip1000 = this.dip1000;
|
||||
s.dip25 = this.dip25;
|
||||
|
||||
s.previews = this.previews;
|
||||
s.lastdc = null;
|
||||
assert(&this != s);
|
||||
return s;
|
||||
|
@ -519,7 +560,7 @@ extern (C++) struct Scope
|
|||
}
|
||||
|
||||
NotFound:
|
||||
if (global.params.fixAliasThis)
|
||||
if (sc.previews.fixAliasThis)
|
||||
{
|
||||
Expression exp = new ThisExp(loc);
|
||||
if (Dsymbol aliasSym = checkAliasThis(sc.scopesym.isAggregateDeclaration(), ident, flags, &exp))
|
||||
|
@ -856,13 +897,13 @@ extern (C++) struct Scope
|
|||
/// Returns: whether to raise DIP1000 warnings (FeatureStabe.default) or errors (FeatureState.enabled)
|
||||
extern (D) FeatureState useDIP1000()
|
||||
{
|
||||
return (this.dip1000 || hasEdition(Edition.v2024)) ? FeatureState.enabled : FeatureState.disabled;
|
||||
return (this.previews.dip1000 || hasEdition(Edition.v2024)) ? FeatureState.enabled : FeatureState.disabled;
|
||||
}
|
||||
|
||||
/// Returns: whether to raise DIP25 warnings (FeatureStabe.default) or errors (FeatureState.enabled)
|
||||
extern (D) FeatureState useDIP25()
|
||||
{
|
||||
return (this.dip25 || hasEdition(Edition.v2024)) ? FeatureState.enabled : FeatureState.disabled;
|
||||
return (this.previews.dip25 || hasEdition(Edition.v2024)) ? FeatureState.enabled : FeatureState.disabled;
|
||||
}
|
||||
|
||||
/// Returns: whether this scope compiles with `edition` or later
|
||||
|
|
|
@ -577,7 +577,7 @@ extern (C++) class Dsymbol : ASTNode
|
|||
continue;
|
||||
if (sa == p1)
|
||||
return true;
|
||||
else if (p2 && sa == p2)
|
||||
if (p2 && sa == p2)
|
||||
return true;
|
||||
}
|
||||
outer = ti.tempdecl.toParent();
|
||||
|
|
|
@ -717,7 +717,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
|||
// Calculate type size + safety checks
|
||||
if (dsym.storage_class & STC.gshared && !dsym.isMember())
|
||||
{
|
||||
sc.setUnsafe(false, dsym.loc, "__gshared not allowed in safe functions; use shared");
|
||||
sc.setUnsafe(false, dsym.loc, "using `__gshared` instead of `shared`");
|
||||
}
|
||||
|
||||
Dsymbol parent = dsym.toParent();
|
||||
|
@ -1146,22 +1146,22 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
|||
|
||||
if (dsym.type.hasPointers()) // also computes type size
|
||||
sc.setUnsafe(false, dsym.loc,
|
||||
"`void` initializers for pointers not allowed in safe functions");
|
||||
"`void` initializing a pointer");
|
||||
else if (dsym.type.hasInvariant())
|
||||
sc.setUnsafe(false, dsym.loc,
|
||||
"`void` initializers for structs with invariants are not allowed in safe functions");
|
||||
"`void` initializing a struct with an invariant");
|
||||
else if (dsym.type.toBasetype().ty == Tbool)
|
||||
sc.setUnsafePreview(global.params.systemVariables, false, dsym.loc,
|
||||
"a `bool` must be 0 or 1, so void intializing it is not allowed in safe functions");
|
||||
"void intializing a bool (which must always be 0 or 1)");
|
||||
else if (dsym.type.hasUnsafeBitpatterns())
|
||||
sc.setUnsafePreview(global.params.systemVariables, false, dsym.loc,
|
||||
"`void` initializers for types with unsafe bit patterns are not allowed in safe functions");
|
||||
"`void` initializing a type with unsafe bit patterns");
|
||||
}
|
||||
else if (!dsym._init &&
|
||||
!(dsym.storage_class & (STC.static_ | STC.extern_ | STC.gshared | STC.manifest | STC.field | STC.parameter)) &&
|
||||
dsym.type.hasVoidInitPointers())
|
||||
{
|
||||
sc.setUnsafe(false, dsym.loc, "`void` initializers for pointers not allowed in safe functions");
|
||||
sc.setUnsafe(false, dsym.loc, "`void` initializers for pointers");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1323,7 +1323,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
|||
{
|
||||
import dmd.escape : setUnsafeDIP1000;
|
||||
const inSafeFunc = sc.func && sc.func.isSafeBypassingInference(); // isSafeBypassingInference may call setUnsafe().
|
||||
if (setUnsafeDIP1000(*sc, false, dsym.loc, "`scope` allocation of `%s` requires that constructor be annotated with `scope`", dsym))
|
||||
if (setUnsafeDIP1000(*sc, false, dsym.loc, "`scope` allocation of `%s` with a non-`scope` constructor", dsym))
|
||||
errorSupplemental(ne.member.loc, "is the location of the constructor");
|
||||
}
|
||||
ne.onstack = 1;
|
||||
|
@ -1577,7 +1577,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
|||
if (dsym.errors)
|
||||
return;
|
||||
|
||||
if (!(global.params.bitfields || sc.inCfile))
|
||||
if (!(sc.previews.bitfields || sc.inCfile))
|
||||
{
|
||||
version (IN_GCC)
|
||||
.error(dsym.loc, "%s `%s` use `-fpreview=bitfields` for bitfield support", dsym.kind, dsym.toPrettyChars);
|
||||
|
|
|
@ -211,11 +211,11 @@ Dsymbol getDsymbol(RootObject oarg)
|
|||
// Try to convert Expression to symbol
|
||||
if (auto ve = ea.isVarExp())
|
||||
return ve.var;
|
||||
else if (auto fe = ea.isFuncExp())
|
||||
if (auto fe = ea.isFuncExp())
|
||||
return fe.td ? fe.td : fe.fd;
|
||||
else if (auto te = ea.isTemplateExp())
|
||||
if (auto te = ea.isTemplateExp())
|
||||
return te.td;
|
||||
else if (auto te = ea.isScopeExp())
|
||||
if (auto te = ea.isScopeExp())
|
||||
return te.sds;
|
||||
else
|
||||
return null;
|
||||
|
|
|
@ -354,7 +354,7 @@ bool checkParamArgumentEscape(ref Scope sc, FuncDeclaration fdc, Identifier parI
|
|||
if (assertmsg)
|
||||
{
|
||||
result |= sc.setUnsafeDIP1000(gag, arg.loc,
|
||||
desc ~ " `%s` assigned to non-scope parameter calling `assert()`", v);
|
||||
"assigning" ~ desc ~ " `%s` to non-scope parameter calling `assert()`", v);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -362,9 +362,9 @@ bool checkParamArgumentEscape(ref Scope sc, FuncDeclaration fdc, Identifier parI
|
|||
|
||||
const(char)* msg =
|
||||
(isThis) ? (desc ~ " `%s` calling non-scope member function `%s.%s()`") :
|
||||
(fdc && parId) ? (desc ~ " `%s` assigned to non-scope parameter `%s` calling `%s`") :
|
||||
(fdc && !parId) ? (desc ~ " `%s` assigned to non-scope anonymous parameter calling `%s`") :
|
||||
(!fdc && parId) ? (desc ~ " `%s` assigned to non-scope parameter `%s`") :
|
||||
(fdc && parId) ? ("assigning " ~ desc ~ " `%s` to non-scope parameter `%s` calling `%s`") :
|
||||
(fdc && !parId) ? ("assigning " ~ desc ~ " `%s` to non-scope anonymous parameter calling `%s`") :
|
||||
(!fdc && parId) ? ("assigning " ~ desc ~ " `%s` to non-scope parameter `%s`") :
|
||||
(desc ~ " `%s` assigned to non-scope anonymous parameter");
|
||||
|
||||
if (isThis ?
|
||||
|
@ -440,8 +440,8 @@ bool checkParamArgumentEscape(ref Scope sc, FuncDeclaration fdc, Identifier parI
|
|||
if (parStc & STC.scope_)
|
||||
return;
|
||||
const(char)* msg = parId ?
|
||||
"reference to stack allocated value returned by `%s` assigned to non-scope parameter `%s`" :
|
||||
"reference to stack allocated value returned by `%s` assigned to non-scope anonymous parameter";
|
||||
"assigning reference to stack allocated value returned by `%s` to non-scope parameter `%s`" :
|
||||
"assigning reference to stack allocated value returned by `%s` to non-scope anonymous parameter";
|
||||
|
||||
result |= sc.setUnsafeDIP1000(gag, ee.loc, msg, ee, parId);
|
||||
}
|
||||
|
@ -726,16 +726,16 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
{
|
||||
case EnclosedBy.none: assert(0);
|
||||
case EnclosedBy.returnScope:
|
||||
msg = "scope variable `%s` assigned to return scope `%s`";
|
||||
msg = "assigning scope variable `%s` to return scope `%s`";
|
||||
break;
|
||||
case EnclosedBy.longerScope:
|
||||
msg = "scope variable `%s` assigned to `%s` with longer lifetime";
|
||||
msg = "assigning scope variable `%s` to `%s` with longer lifetime";
|
||||
break;
|
||||
case EnclosedBy.refVar:
|
||||
msg = "scope variable `%s` assigned to `ref` variable `%s` with longer lifetime";
|
||||
msg = "assigning scope variable `%s` to `ref` variable `%s` with longer lifetime";
|
||||
break;
|
||||
case EnclosedBy.global:
|
||||
msg = "scope variable `%s` assigned to global variable `%s`";
|
||||
msg = "assigning scope variable `%s` to global variable `%s`";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
}
|
||||
return;
|
||||
}
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc, "scope variable `%s` assigned to non-scope `%s`", v, e1);
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc, "assigning scope variable `%s` to non-scope `%s`", v, e1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -794,7 +794,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
else
|
||||
{
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc,
|
||||
"address of local variable `%s` assigned to return scope `%s`", v, va);
|
||||
"assigning address of local variable `%s` to return scope `%s`", v, va);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,7 +809,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
// If va's lifetime encloses v's, then error
|
||||
if (va && !(vaIsFirstRef && v.isReturn()) && va.enclosesLifetimeOf(v))
|
||||
{
|
||||
if (sc.setUnsafeDIP1000(gag, ae.loc, "address of variable `%s` assigned to `%s` with longer lifetime", v, va))
|
||||
if (sc.setUnsafeDIP1000(gag, ae.loc, "assigning address of variable `%s` to `%s` with longer lifetime", v, va))
|
||||
{
|
||||
result = true;
|
||||
return;
|
||||
|
@ -829,7 +829,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
return;
|
||||
}
|
||||
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc, "reference to local variable `%s` assigned to non-scope `%s`", v, e1);
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc, "assigning reference to local variable `%s` to non-scope `%s`", v, e1);
|
||||
}
|
||||
|
||||
void onFunc(FuncDeclaration func, bool called)
|
||||
|
@ -869,7 +869,7 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
return;
|
||||
}
|
||||
result |= sc.setUnsafeDIP1000(gag, ae.loc,
|
||||
"reference to local `%s` assigned to non-scope `%s` in @safe code", v, e1);
|
||||
"assigning reference to local `%s` to non-scope `%s`", v, e1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,8 +889,8 @@ bool checkAssignEscape(ref Scope sc, Expression e, bool gag, bool byRef)
|
|||
}
|
||||
|
||||
const(char)* msg = (ee.op == EXP.structLiteral) ?
|
||||
"address of struct literal `%s` assigned to `%s` with longer lifetime" :
|
||||
"address of expression temporary returned by `%s` assigned to `%s` with longer lifetime";
|
||||
"assigning address of struct literal `%s` to `%s` with longer lifetime" :
|
||||
"assigning address of expression temporary returned by `%s` to `%s` with longer lifetime";
|
||||
|
||||
result |= sc.setUnsafeDIP1000(gag, ee.loc, msg, ee, e1);
|
||||
}
|
||||
|
@ -930,7 +930,7 @@ bool checkThrowEscape(ref Scope sc, Expression e, bool gag)
|
|||
// despite being `scope`
|
||||
{
|
||||
// https://issues.dlang.org/show_bug.cgi?id=17029
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be thrown", v);
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "throwing scope variable `%s`", v);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -989,7 +989,7 @@ bool checkNewEscape(ref Scope sc, Expression e, bool gag)
|
|||
!(p.parent == sc.func))
|
||||
{
|
||||
// https://issues.dlang.org/show_bug.cgi?id=20868
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be copied into allocated memory", v);
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "copying scope variable `%s` into allocated memory", v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1009,9 +1009,9 @@ bool checkNewEscape(ref Scope sc, Expression e, bool gag)
|
|||
bool escapingRef(VarDeclaration v, FeatureState fs)
|
||||
{
|
||||
const(char)* msg = v.isParameter() ?
|
||||
"copying `%s` into allocated memory escapes a reference to parameter `%s`" :
|
||||
"copying `%s` into allocated memory escapes a reference to local variable `%s`";
|
||||
return setUnsafePreview(&sc, fs, gag, e.loc, msg, e, v);
|
||||
"escaping a reference to parameter `%s` by copying `%s` into allocated memory" :
|
||||
"escaping a reference to local variable `%s` by copying `%s` into allocated memory";
|
||||
return setUnsafePreview(&sc, fs, gag, e.loc, msg, v, e);
|
||||
}
|
||||
|
||||
Dsymbol p = v.toParent2();
|
||||
|
@ -1064,14 +1064,14 @@ bool checkNewEscape(ref Scope sc, Expression e, bool gag)
|
|||
{
|
||||
if (called)
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc,
|
||||
"nested function `%s` returns `scope` values and escapes them into allocated memory", fd);
|
||||
"escaping a `scope` value returned from nested function `%s` into allocated memory", fd);
|
||||
}
|
||||
|
||||
void onExp(Expression ee, bool retRefTransition)
|
||||
{
|
||||
if (log) printf("byexp %s\n", ee.toChars());
|
||||
if (!gag)
|
||||
sc.eSink.error(ee.loc, "storing reference to stack allocated value returned by `%s` into allocated memory causes it to escape",
|
||||
sc.eSink.error(ee.loc, "escaping reference to stack allocated value returned by `%s` into allocated memory",
|
||||
ee.toChars());
|
||||
result = true;
|
||||
}
|
||||
|
@ -1210,7 +1210,7 @@ private bool checkReturnEscapeImpl(ref Scope sc, Expression e, bool refs, bool g
|
|||
else
|
||||
{
|
||||
// https://issues.dlang.org/show_bug.cgi?id=17029
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "scope variable `%s` may not be returned", v);
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, "returning scope variable `%s`", v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1233,13 +1233,12 @@ private bool checkReturnEscapeImpl(ref Scope sc, Expression e, bool refs, bool g
|
|||
// depending on the flag passed to the CLI for DIP25
|
||||
void escapingRef(VarDeclaration v, FeatureState featureState)
|
||||
{
|
||||
const(char)* msg = v.isParameter() ?
|
||||
"returning `%s` escapes a reference to parameter `%s`" :
|
||||
"returning `%s` escapes a reference to local variable `%s`";
|
||||
|
||||
const(char)* safeMsg = v.isParameter() ?
|
||||
"escaping a reference to parameter `%s` by returning `%s`" :
|
||||
"escaping a reference to local variable `%s` by returning `%s` ";
|
||||
if (v.isParameter() && v.isReference())
|
||||
{
|
||||
if (setUnsafePreview(&sc, featureState, gag, e.loc, msg, e, v) ||
|
||||
if (setUnsafePreview(&sc, featureState, gag, e.loc, safeMsg, v, e) ||
|
||||
sc.func.isSafeBypassingInference())
|
||||
{
|
||||
result = true;
|
||||
|
@ -1260,10 +1259,13 @@ private bool checkReturnEscapeImpl(ref Scope sc, Expression e, bool refs, bool g
|
|||
{
|
||||
if (retRefTransition)
|
||||
{
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, msg, e, v);
|
||||
result |= sc.setUnsafeDIP1000(gag, e.loc, safeMsg, v, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
const(char)* msg = v.isParameter() ?
|
||||
"returning `%s` escapes a reference to parameter `%s`" :
|
||||
"returning `%s` escapes a reference to local variable `%s`";
|
||||
if (!gag)
|
||||
previewErrorFunc(sc.isDeprecated(), featureState)(e.loc, msg, e.toChars(), v.toChars());
|
||||
result = true;
|
||||
|
@ -2228,7 +2230,7 @@ private bool checkScopeVarAddr(VarDeclaration v, Expression e, ref Scope sc, boo
|
|||
|
||||
// take address of `scope` variable not allowed, requires transitive scope
|
||||
return sc.setUnsafeDIP1000(gag, e.loc,
|
||||
"cannot take address of `scope` variable `%s` since `scope` applies to first indirection only", v);
|
||||
"taking address of `scope` variable `%s` with pointers", v);
|
||||
}
|
||||
|
||||
/****************************
|
||||
|
|
|
@ -1607,8 +1607,8 @@ Lagain:
|
|||
{
|
||||
if (sd.isSystem())
|
||||
{
|
||||
if (sc.setUnsafePreview(global.params.systemVariables, false, loc,
|
||||
"cannot access `@system` variable `%s` in @safe code", sd))
|
||||
if (sc.setUnsafePreview(sc.previews.systemVariables, false, loc,
|
||||
"access `@system` variable `%s`", sd))
|
||||
{
|
||||
if (auto v = sd.isVarDeclaration())
|
||||
{
|
||||
|
@ -2237,8 +2237,7 @@ private bool checkPurity(VarDeclaration v, const ref Loc loc, Scope* sc)
|
|||
*/
|
||||
if (v.storage_class & STC.gshared)
|
||||
{
|
||||
if (sc.setUnsafe(false, loc,
|
||||
"`@safe` function `%s` cannot access `__gshared` data `%s`", sc.func, v))
|
||||
if (sc.setUnsafe(false, loc, "accessing `__gshared` data `%s`", v))
|
||||
{
|
||||
err = true;
|
||||
}
|
||||
|
@ -3328,7 +3327,7 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
|
|||
}
|
||||
else if (p.storageClass & STC.ref_)
|
||||
{
|
||||
if (global.params.rvalueRefParam == FeatureState.enabled &&
|
||||
if (sc.previews.rvalueRefParam &&
|
||||
!arg.isLvalue() &&
|
||||
targ.isCopyable())
|
||||
{ /* allow rvalues to be passed to ref parameters by copying
|
||||
|
@ -3729,7 +3728,7 @@ private bool functionParameters(const ref Loc loc, Scope* sc,
|
|||
|
||||
/* Test compliance with DIP1021 Argument Ownership and Function Calls
|
||||
*/
|
||||
if (global.params.useDIP1021 && (tf.trust == TRUST.safe || tf.trust == TRUST.default_) ||
|
||||
if (sc.previews.dip1021 && (tf.trust == TRUST.safe || tf.trust == TRUST.default_) ||
|
||||
tf.isLive)
|
||||
err |= checkMutableArguments(*sc, fd, tf, ethis, arguments, false);
|
||||
|
||||
|
@ -4012,7 +4011,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
}
|
||||
}
|
||||
|
||||
if (global.params.fixAliasThis)
|
||||
if (sc.previews.fixAliasThis)
|
||||
{
|
||||
if (ExpressionDsymbol expDsym = scopesym.isExpressionDsymbol())
|
||||
{
|
||||
|
@ -4028,7 +4027,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
return;
|
||||
}
|
||||
|
||||
if (!global.params.fixAliasThis && hasThis(sc))
|
||||
if (!sc.previews.fixAliasThis && hasThis(sc))
|
||||
{
|
||||
for (AggregateDeclaration ad = sc.getStructClassScope(); ad;)
|
||||
{
|
||||
|
@ -5175,7 +5174,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
|
||||
// When using `@nogc` exception handling, lower `throw new E(args)` to
|
||||
// `throw (__tmp = _d_newThrowable!E(), __tmp.__ctor(args), __tmp)`.
|
||||
if (global.params.ehnogc && exp.thrownew &&
|
||||
if (sc.previews.dip1008 && exp.thrownew &&
|
||||
!cd.isCOMclass() && !cd.isCPPclass())
|
||||
{
|
||||
assert(cd.ctor);
|
||||
|
@ -8596,8 +8595,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
*/
|
||||
if (1)
|
||||
{
|
||||
if (sc.setUnsafe(false, exp.loc,
|
||||
"cannot take address of lazy parameter `%s` in `@safe` function `%s`", ve, sc.func))
|
||||
if (sc.setUnsafe(false, exp.loc, "taking address of lazy parameter `%s`", ve))
|
||||
{
|
||||
setError();
|
||||
return;
|
||||
|
@ -8746,9 +8744,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
}
|
||||
if (sc.func && !sc.intypeof && !sc.debug_)
|
||||
{
|
||||
sc.setUnsafe(false, exp.loc,
|
||||
"`this` reference necessary to take address of member `%s` in `@safe` function `%s`",
|
||||
f, sc.func);
|
||||
sc.setUnsafe(false, exp.loc, "taking address of member `%s` without `this` reference", f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9240,7 +9236,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
if (!isSafeCast(ex, t1b, tob, msg))
|
||||
{
|
||||
if (sc.setUnsafe(false, exp.loc,
|
||||
"cast from `%s` to `%s` not allowed in safe code", exp.e1.type, exp.to))
|
||||
"cast from `%s` to `%s`", exp.e1.type, exp.to))
|
||||
{
|
||||
if (msg.length)
|
||||
errorSupplemental(exp.loc, "%.*s", msg.fTuple.expand);
|
||||
|
@ -9250,7 +9246,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
else if (msg.length) // deprecated unsafe
|
||||
{
|
||||
const err = sc.setUnsafePreview(FeatureState.default_, false, exp.loc,
|
||||
"cast from `%s` to `%s` not allowed in safe code", exp.e1.type, exp.to);
|
||||
"cast from `%s` to `%s`", exp.e1.type, exp.to);
|
||||
// if message was printed
|
||||
if (sc.func && sc.func.isSafeBypassingInference() && !sc.isDeprecated())
|
||||
deprecationSupplemental(exp.loc, "%.*s", msg.fTuple.expand);
|
||||
|
@ -9503,7 +9499,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
|
||||
return setError();
|
||||
}
|
||||
if (sc.setUnsafe(false, exp.loc, "pointer slicing not allowed in safe functions"))
|
||||
if (sc.setUnsafe(false, exp.loc, "pointer slicing"))
|
||||
return setError();
|
||||
}
|
||||
else if (t1b.ty == Tarray)
|
||||
|
@ -9991,7 +9987,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
if (exp.e2.op == EXP.int64 && exp.e2.toInteger() == 0)
|
||||
{
|
||||
}
|
||||
else if (sc.setUnsafe(false, exp.loc, "`@safe` function `%s` cannot index pointer `%s`", sc.func, exp.e1))
|
||||
else if (sc.setUnsafe(false, exp.loc, "indexing pointer `%s`", exp.e1))
|
||||
{
|
||||
return setError();
|
||||
}
|
||||
|
@ -11449,17 +11445,17 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
{
|
||||
if (t2.nextOf().implicitConvTo(t1.nextOf()))
|
||||
{
|
||||
if (sc.setUnsafe(false, exp.loc, "cannot copy `%s` to `%s` in `@safe` code", t2, t1))
|
||||
if (sc.setUnsafe(false, exp.loc, "copying `%s` to `%s`", t2, t1))
|
||||
return setError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// copying from non-void to void was overlooked, deprecate
|
||||
if (sc.setUnsafePreview(FeatureState.default_, false, exp.loc,
|
||||
"cannot copy `%s` to `%s` in `@safe` code", t2, t1))
|
||||
"copying `%s` to `%s`", t2, t1))
|
||||
return setError();
|
||||
}
|
||||
if (global.params.fixImmutableConv && !t2.implicitConvTo(t1))
|
||||
if (sc.previews.fixImmutableConv && !t2.implicitConvTo(t1))
|
||||
{
|
||||
error(exp.loc, "cannot copy `%s` to `%s`",
|
||||
t2.toChars(), t1.toChars());
|
||||
|
@ -11848,7 +11844,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
(exp.e2.implicitConvTo(exp.e1.type) ||
|
||||
(tb2.nextOf().implicitConvTo(tb1next) &&
|
||||
// Do not strip const(void)[]
|
||||
(!global.params.fixImmutableConv || tb1next.ty != Tvoid) &&
|
||||
(!sc.previews.fixImmutableConv || tb1next.ty != Tvoid) &&
|
||||
(tb2.nextOf().size(Loc.initial) == tb1next.size(Loc.initial)))))
|
||||
{
|
||||
// EXP.concatenateAssign
|
||||
|
@ -12245,12 +12241,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
|
||||
if (!p1.equivalent(p2))
|
||||
{
|
||||
// Deprecation to remain for at least a year, after which this should be
|
||||
// changed to an error
|
||||
// See https://github.com/dlang/dmd/pull/7332
|
||||
deprecation(exp.loc,
|
||||
"cannot subtract pointers to different types: `%s` and `%s`.",
|
||||
error(exp.loc, "cannot subtract pointers to different types: `%s` and `%s`.",
|
||||
t1.toChars(), t2.toChars());
|
||||
return setError();
|
||||
}
|
||||
|
||||
// Need to divide the result by the stride
|
||||
|
@ -12590,7 +12584,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
|
|||
if (exp.type.ty == Tarray && tb1next && tb2next && tb1next.mod != tb2next.mod)
|
||||
{
|
||||
// Do not strip const(void)[]
|
||||
if (!global.params.fixImmutableConv || tb.nextOf().ty != Tvoid)
|
||||
if (!sc.previews.fixImmutableConv || tb.nextOf().ty != Tvoid)
|
||||
exp.type = exp.type.nextOf().toHeadMutable().arrayOf();
|
||||
}
|
||||
if (Type tbn = tb.nextOf())
|
||||
|
@ -14890,8 +14884,8 @@ private bool checkSharedAccessBin(BinExp binExp, Scope* sc)
|
|||
*/
|
||||
bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
|
||||
{
|
||||
if (global.params.noSharedAccess != FeatureState.enabled ||
|
||||
!sc ||
|
||||
if (!sc ||
|
||||
!sc.previews.noSharedAccess ||
|
||||
sc.intypeof ||
|
||||
sc.ctfe)
|
||||
{
|
||||
|
@ -15588,7 +15582,7 @@ private Expression toLvalueImpl(Expression _this, Scope* sc, const(char)* action
|
|||
with (_this)
|
||||
if (!trusted && !e1.type.pointerTo().implicitConvTo(to.pointerTo()))
|
||||
sc.setUnsafePreview(FeatureState.default_, false, loc,
|
||||
"cast from `%s` to `%s` cannot be used as an lvalue in @safe code",
|
||||
"using the result of a cast from `%s` to `%s` as an lvalue",
|
||||
e1.type, to);
|
||||
|
||||
return _this;
|
||||
|
@ -15956,7 +15950,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression
|
|||
|
||||
Expression visitDelegatePtr(DelegatePtrExp exp)
|
||||
{
|
||||
if (sc.setUnsafe(false, exp.loc, "cannot modify delegate pointer in `@safe` code `%s`", exp))
|
||||
if (sc.setUnsafe(false, exp.loc, "modifying delegate pointer `%s`", exp))
|
||||
{
|
||||
return ErrorExp.get();
|
||||
}
|
||||
|
@ -15965,7 +15959,7 @@ private Expression modifiableLvalueImpl(Expression _this, Scope* sc, Expression
|
|||
|
||||
Expression visitDelegateFuncptr(DelegateFuncptrExp exp)
|
||||
{
|
||||
if (sc.setUnsafe(false, exp.loc, "cannot modify delegate function pointer in `@safe` code `%s`", exp))
|
||||
if (sc.setUnsafe(false, exp.loc, "modifying delegate function pointer `%s`", exp))
|
||||
{
|
||||
return ErrorExp.get();
|
||||
}
|
||||
|
@ -16034,7 +16028,7 @@ private bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v)
|
|||
{
|
||||
if (sc.useDIP1000 != FeatureState.enabled &&
|
||||
!(v.storage_class & STC.temp) &&
|
||||
sc.setUnsafe(false, exp.loc, "cannot take address of local `%s` in `@safe` function `%s`", v, sc.func))
|
||||
sc.setUnsafe(false, exp.loc, "taking the address of stack-allocated local variable `%s`", v))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -16307,7 +16301,7 @@ private bool fit(StructDeclaration sd, const ref Loc loc, Scope* sc, Expressions
|
|||
if ((!stype.alignment.isDefault() && stype.alignment.get() < target.ptrsize ||
|
||||
(v.offset & (target.ptrsize - 1))) &&
|
||||
(sc.setUnsafe(false, loc,
|
||||
"field `%s.%s` cannot assign to misaligned pointers in `@safe` code", sd, v)))
|
||||
"field `%s.%s` assigning to misaligned pointers", sd, v)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ private struct FUNCFLAG
|
|||
bool safetyInprocess; /// working on determining safety
|
||||
bool nothrowInprocess; /// working on determining nothrow
|
||||
bool nogcInprocess; /// working on determining @nogc
|
||||
bool saferD; /// do -preview=safer checks if this function has default safety
|
||||
bool scopeInprocess; /// infer `return` and `scope` for parameters
|
||||
bool inlineScanned; /// function has been scanned for inline possibilities
|
||||
bool hasCatches; /// function has try-catch statements
|
||||
|
|
|
@ -1616,9 +1616,26 @@ FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymbol s,
|
|||
const(char)* lastprms = parametersTypeToChars(tf1.parameterList);
|
||||
const(char)* nextprms = parametersTypeToChars(tf2.parameterList);
|
||||
|
||||
.error(loc, "`%s.%s` called with argument types `%s` matches both:\n%s: `%s%s%s`\nand:\n%s: `%s%s%s`",
|
||||
string match = "";
|
||||
final switch (m.last)
|
||||
{
|
||||
case MATCH.convert:
|
||||
match = "after implicit conversions";
|
||||
break;
|
||||
case MATCH.constant:
|
||||
match = "after qualifier conversion";
|
||||
break;
|
||||
case MATCH.exact:
|
||||
match = "exactly";
|
||||
break;
|
||||
case MATCH.nomatch:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
.error(loc, "`%s.%s` called with argument types `%s` matches multiple overloads %.*s:\n%s: `%s%s%s`\nand:\n%s: `%s%s%s`",
|
||||
s.parent.toPrettyChars(), s.ident.toChars(),
|
||||
fargsBuf.peekChars(),
|
||||
match.fTuple.expand,
|
||||
m.lastf.loc.toChars(), m.lastf.toPrettyChars(), lastprms, tf1.modToChars(),
|
||||
m.nextf.loc.toChars(), m.nextf.toPrettyChars(), nextprms, tf2.modToChars());
|
||||
return null;
|
||||
|
|
|
@ -400,6 +400,7 @@ extern (C++) struct Global
|
|||
params.v.color = detectTerminal();
|
||||
}
|
||||
|
||||
params.v.errorPrintMode = ErrorPrintMode.printErrorContext; // Enable error context globally by default
|
||||
compileEnv.versionNumber = parseVersionNumber(versionString());
|
||||
|
||||
/* Initialize date, time, and timestamp
|
||||
|
|
|
@ -418,10 +418,10 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, ref HdrGenState h
|
|||
{
|
||||
buf.writestring(Token.toString(s.op));
|
||||
buf.writestring(" (");
|
||||
if (s.prm.type)
|
||||
typeToBuffer(s.prm.type, s.prm.ident, buf, hgs);
|
||||
if (s.param.type)
|
||||
typeToBuffer(s.param.type, s.param.ident, buf, hgs);
|
||||
else
|
||||
buf.writestring(s.prm.ident.toString());
|
||||
buf.writestring(s.param.ident.toString());
|
||||
buf.writestring("; ");
|
||||
s.lwr.expressionToBuffer(buf, hgs);
|
||||
buf.writestring(" .. ");
|
||||
|
@ -465,7 +465,7 @@ private void statementToBuffer(Statement s, ref OutBuffer buf, ref HdrGenState h
|
|||
void visitIf(IfStatement s)
|
||||
{
|
||||
buf.writestring("if (");
|
||||
printConditionAssignment(s.prm, s.condition);
|
||||
printConditionAssignment(s.param, s.condition);
|
||||
buf.writeByte(')');
|
||||
buf.writenl();
|
||||
if (s.ifbody.isScopeStatement())
|
||||
|
@ -1168,14 +1168,14 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs)
|
|||
|
||||
void foreachRangeWithoutBody(ForeachRangeStatement s)
|
||||
{
|
||||
/* s.op ( prm ; lwr .. upr )
|
||||
/* s.op ( param ; lwr .. upr )
|
||||
*/
|
||||
buf.writestring(Token.toString(s.op));
|
||||
buf.writestring(" (");
|
||||
if (s.prm.type)
|
||||
typeToBuffer(s.prm.type, s.prm.ident, buf, hgs);
|
||||
if (s.param.type)
|
||||
typeToBuffer(s.param.type, s.param.ident, buf, hgs);
|
||||
else
|
||||
buf.writestring(s.prm.ident.toString());
|
||||
buf.writestring(s.param.ident.toString());
|
||||
buf.writestring("; ");
|
||||
s.lwr.expressionToBuffer(buf, hgs);
|
||||
buf.writestring(" .. ");
|
||||
|
|
|
@ -1592,7 +1592,7 @@ Expressions* resolveStructLiteralNamedArgs(StructDeclaration sd, Type t, Scope*
|
|||
(vd.offset & (target.ptrsize - 1))))
|
||||
{
|
||||
if (sc.setUnsafe(false, argLoc,
|
||||
"field `%s.%s` cannot assign to misaligned pointers in `@safe` code", sd, vd))
|
||||
"field `%s.%s` assigning to misaligned pointers", sd, vd))
|
||||
{
|
||||
errors = true;
|
||||
elems[fieldi] = ErrorExp.get(); // for better diagnostics on multiple errors
|
||||
|
|
|
@ -69,7 +69,7 @@ struct SignExtendedNumber
|
|||
}
|
||||
if (value < a.value)
|
||||
return -1;
|
||||
else if (value > a.value)
|
||||
if (value > a.value)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
@ -121,10 +121,10 @@ struct SignExtendedNumber
|
|||
SignExtendedNumber opBinary(string op : "+")(SignExtendedNumber rhs)
|
||||
{
|
||||
uinteger_t sum = value + rhs.value;
|
||||
bool carry = sum < value && sum < rhs.value;
|
||||
const carry = sum < value && sum < rhs.value;
|
||||
if (negative != rhs.negative)
|
||||
return SignExtendedNumber(sum, !carry);
|
||||
else if (negative)
|
||||
if (negative)
|
||||
return SignExtendedNumber(carry ? sum : 0, true);
|
||||
else
|
||||
return SignExtendedNumber(carry ? ulong.max : sum, false);
|
||||
|
@ -154,7 +154,7 @@ struct SignExtendedNumber
|
|||
{
|
||||
if (!negative)
|
||||
return this;
|
||||
else if (rhs.negative)
|
||||
if (rhs.negative)
|
||||
return max();
|
||||
else
|
||||
return rhs.value == 0 ? rhs : this;
|
||||
|
@ -248,7 +248,7 @@ struct SignExtendedNumber
|
|||
// shifts will give huge result.
|
||||
if (value == 0)
|
||||
return this;
|
||||
else if (rhs.negative)
|
||||
if (rhs.negative)
|
||||
return extreme(negative);
|
||||
|
||||
uinteger_t v = copySign(value, negative);
|
||||
|
@ -277,7 +277,7 @@ struct SignExtendedNumber
|
|||
{
|
||||
if (rhs.negative || rhs.value > 63)
|
||||
return negative ? SignExtendedNumber(-1, true) : SignExtendedNumber(0);
|
||||
else if (isMinimum())
|
||||
if (isMinimum())
|
||||
return rhs.value == 0 ? this : SignExtendedNumber(-1UL << (64 - rhs.value), true);
|
||||
|
||||
uinteger_t x = value ^ -cast(int)negative;
|
||||
|
@ -445,11 +445,10 @@ struct IntRange
|
|||
{
|
||||
if (!type.isIntegral() || type.toBasetype().isTypeVector())
|
||||
return this;
|
||||
else if (!type.isUnsigned())
|
||||
if (!type.isUnsigned())
|
||||
return castSigned(type.sizemask());
|
||||
else if (type.toBasetype().ty == Tdchar)
|
||||
if (type.toBasetype().ty == Tdchar)
|
||||
return castDchar();
|
||||
else
|
||||
return castUnsigned(type.sizemask());
|
||||
}
|
||||
|
||||
|
@ -457,10 +456,9 @@ struct IntRange
|
|||
{
|
||||
if (!type.isIntegral() || type.toBasetype().isTypeVector())
|
||||
return castUnsigned(ulong.max);
|
||||
else if (type.toBasetype().ty == Tdchar)
|
||||
if (type.toBasetype().ty == Tdchar)
|
||||
return castDchar();
|
||||
else
|
||||
return castUnsigned(type.sizemask());
|
||||
return castUnsigned(type.sizemask());
|
||||
}
|
||||
|
||||
bool contains(IntRange a) @safe
|
||||
|
@ -478,14 +476,11 @@ struct IntRange
|
|||
{
|
||||
if (imax.negative)
|
||||
return this;
|
||||
else if (!imin.negative)
|
||||
if (!imin.negative)
|
||||
return IntRange(-imax, -imin);
|
||||
else
|
||||
{
|
||||
SignExtendedNumber imaxAbsNeg = -imax;
|
||||
return IntRange(imaxAbsNeg < imin ? imaxAbsNeg : imin,
|
||||
SignExtendedNumber(0));
|
||||
}
|
||||
SignExtendedNumber imaxAbsNeg = -imax;
|
||||
return IntRange(imaxAbsNeg < imin ? imaxAbsNeg : imin,
|
||||
SignExtendedNumber(0));
|
||||
}
|
||||
|
||||
IntRange unionWith(const ref IntRange other) const @safe
|
||||
|
@ -573,13 +568,13 @@ struct IntRange
|
|||
swap(l, r); // r spans [-1,0]
|
||||
}
|
||||
|
||||
auto minAndNeg = minAnd(l, IntRange(r.imin, SignExtendedNumber(-1)));
|
||||
auto minAndPos = minAnd(l, IntRange(SignExtendedNumber(0), r.imax));
|
||||
auto maxAndNeg = maxAnd(l, IntRange(r.imin, SignExtendedNumber(-1)));
|
||||
auto maxAndPos = maxAnd(l, IntRange(SignExtendedNumber(0), r.imax));
|
||||
const minAndNeg = minAnd(l, IntRange(r.imin, SignExtendedNumber(-1)));
|
||||
const minAndPos = minAnd(l, IntRange(SignExtendedNumber(0), r.imax));
|
||||
const maxAndNeg = maxAnd(l, IntRange(r.imin, SignExtendedNumber(-1)));
|
||||
const maxAndPos = maxAnd(l, IntRange(SignExtendedNumber(0), r.imax));
|
||||
|
||||
auto min = minAndNeg < minAndPos ? minAndNeg : minAndPos;
|
||||
auto max = maxAndNeg > maxAndPos ? maxAndNeg : maxAndPos;
|
||||
const min = minAndNeg < minAndPos ? minAndNeg : minAndPos;
|
||||
const max = maxAndNeg > maxAndPos ? maxAndNeg : maxAndPos;
|
||||
|
||||
auto range = IntRange(min, max);
|
||||
return range;
|
||||
|
@ -681,22 +676,19 @@ struct IntRange
|
|||
{
|
||||
return IntRange(imin / rhs.imax, imax / rhs.imin);
|
||||
}
|
||||
else if (rhs.imin.negative && !rhs.imax.negative) // divisor spans [-1, 0, 1]
|
||||
if (rhs.imin.negative && !rhs.imax.negative) // divisor spans [-1, 0, 1]
|
||||
{
|
||||
SignExtendedNumber[4] bdy = [-imin, imin, -imax, imax];
|
||||
return IntRange.fromNumbers4(bdy.ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// [a,b] / [c,d] = [min (a/c, a/d, b/c, b/d), max (a/c, a/d, b/c, b/d)]
|
||||
SignExtendedNumber[4] bdy;
|
||||
bdy[0] = imin / rhs.imin;
|
||||
bdy[1] = imin / rhs.imax;
|
||||
bdy[2] = imax / rhs.imin;
|
||||
bdy[3] = imax / rhs.imax;
|
||||
// [a,b] / [c,d] = [min (a/c, a/d, b/c, b/d), max (a/c, a/d, b/c, b/d)]
|
||||
SignExtendedNumber[4] bdy;
|
||||
bdy[0] = imin / rhs.imin;
|
||||
bdy[1] = imin / rhs.imax;
|
||||
bdy[2] = imax / rhs.imin;
|
||||
bdy[3] = imax / rhs.imax;
|
||||
|
||||
return IntRange.fromNumbers4(bdy.ptr);
|
||||
}
|
||||
return IntRange.fromNumbers4(bdy.ptr);
|
||||
}
|
||||
|
||||
IntRange opBinary(string op : "%")(IntRange rhs)
|
||||
|
|
|
@ -992,35 +992,34 @@ void json_generate(ref Modules modules, ref OutBuffer buf)
|
|||
// of modules representing their syntax.
|
||||
json.generateModules(modules);
|
||||
json.removeComma();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generate the new format which is an object where each
|
||||
// output option is its own field.
|
||||
|
||||
json.objectStart();
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.compilerInfo)
|
||||
{
|
||||
json.propertyStart("compilerInfo");
|
||||
json.generateCompilerInfo();
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.buildInfo)
|
||||
{
|
||||
json.propertyStart("buildInfo");
|
||||
json.generateBuildInfo();
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.modules)
|
||||
{
|
||||
json.propertyStart("modules");
|
||||
json.generateModules(modules);
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.semantics)
|
||||
{
|
||||
json.propertyStart("semantics");
|
||||
json.generateSemantics();
|
||||
}
|
||||
json.objectEnd();
|
||||
// Generate the new format which is an object where each
|
||||
// output option is its own field.
|
||||
|
||||
json.objectStart();
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.compilerInfo)
|
||||
{
|
||||
json.propertyStart("compilerInfo");
|
||||
json.generateCompilerInfo();
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.buildInfo)
|
||||
{
|
||||
json.propertyStart("buildInfo");
|
||||
json.generateBuildInfo();
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.modules)
|
||||
{
|
||||
json.propertyStart("modules");
|
||||
json.generateModules(modules);
|
||||
}
|
||||
if (global.params.jsonFieldFlags & JsonFieldFlags.semantics)
|
||||
{
|
||||
json.propertyStart("semantics");
|
||||
json.generateSemantics();
|
||||
}
|
||||
json.objectEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
* Follows Itanium C++ ABI 1.86 section 5.1
|
||||
* http://refspecs.linux-foundation.org/cxxabi-1.86.html#mangling
|
||||
* which is where the grammar comments come from.
|
||||
*
|
||||
* Bugs:
|
||||
* https://issues.dlang.org/query.cgi
|
||||
* enter `C++, mangling` as the keywords.
|
||||
*/
|
||||
|
||||
module dmd.mangle.cpp;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
FuncDeclaration f;
|
||||
bool checkOnly; // don't print errors
|
||||
bool err;
|
||||
bool nogcExceptions; // -preview=dip1008 enabled
|
||||
|
||||
extern (D) this(FuncDeclaration f) scope @safe
|
||||
{
|
||||
|
@ -143,7 +144,7 @@ public:
|
|||
}
|
||||
if (e.onstack)
|
||||
return;
|
||||
if (global.params.ehnogc && e.thrownew)
|
||||
if (nogcExceptions && e.thrownew)
|
||||
return; // separate allocator is called for this, not the GC
|
||||
|
||||
if (setGC(e, "cannot use `new` in `@nogc` %s `%s`"))
|
||||
|
@ -224,6 +225,7 @@ Expression checkGC(Scope* sc, Expression e)
|
|||
{
|
||||
scope NOGCVisitor gcv = new NOGCVisitor(f);
|
||||
gcv.checkOnly = betterC;
|
||||
gcv.nogcExceptions = sc.previews.dip1008;
|
||||
walkPostorder(e, gcv);
|
||||
if (gcv.err)
|
||||
{
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/ob.d, _ob.d)
|
||||
* Documentation: https://dlang.org/phobos/dmd_escape.html
|
||||
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/ob.d
|
||||
* Bug reports: use 'live' keyword:
|
||||
* https://issues.dlang.org/buglist.cgi?bug_status=NEW&bug_status=REOPENED&keywords=live
|
||||
* References: https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md Argument Ownership and Function Calls
|
||||
*/
|
||||
|
||||
|
|
|
@ -5683,7 +5683,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
|||
}
|
||||
|
||||
/***
|
||||
* Parse an assignment condition for if or while statements.
|
||||
* Parse an assignment condition for `if`, `switch` or `while` statements.
|
||||
*
|
||||
* Returns:
|
||||
* The variable that is declared inside the condition
|
||||
|
|
|
@ -365,13 +365,23 @@ auto splitLines(const char[] text)
|
|||
public this(const char[] text)
|
||||
{
|
||||
this.text = text;
|
||||
this.index = 0;
|
||||
this.eolIndex = 0;
|
||||
this.nextIndex = 0;
|
||||
}
|
||||
|
||||
public bool empty() { return index == text.length; }
|
||||
public bool empty() { advance(); return index >= text.length; }
|
||||
|
||||
public void popFront() { advance(); index = nextIndex; }
|
||||
|
||||
public const(char)[] front() { advance(); return text[index .. eolIndex]; }
|
||||
public const(char)[] front()
|
||||
{
|
||||
advance();
|
||||
if (index > eolIndex || index >= text.length) {
|
||||
return "";
|
||||
}
|
||||
return text[index .. eolIndex];
|
||||
}
|
||||
|
||||
private void advance()
|
||||
{
|
||||
|
@ -418,7 +428,7 @@ auto splitLines(const char[] text)
|
|||
if (i + 2 < text.length &&
|
||||
text[i + 1] == 0x80 &&
|
||||
(text[i + 2] == 0xA8 || text[i + 2] == 0xA9)
|
||||
)
|
||||
)
|
||||
{
|
||||
eolIndex = i;
|
||||
nextIndex = i + 3;
|
||||
|
@ -430,6 +440,10 @@ auto splitLines(const char[] text)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No newline found; set indices to the end of the text
|
||||
eolIndex = text.length;
|
||||
nextIndex = text.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import core.stdc.stdio;
|
|||
|
||||
import dmd.aggregate;
|
||||
import dmd.astenums;
|
||||
import dmd.common.outbuffer;
|
||||
import dmd.dcast : implicitConvTo;
|
||||
import dmd.dclass;
|
||||
import dmd.declaration;
|
||||
|
@ -67,11 +68,10 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
if (!ad)
|
||||
return false;
|
||||
|
||||
import dmd.globals : global;
|
||||
if (v.isSystem())
|
||||
{
|
||||
if (sc.setUnsafePreview(global.params.systemVariables, !printmsg, e.loc,
|
||||
"cannot access `@system` field `%s.%s` in `@safe` code", ad, v))
|
||||
if (sc.setUnsafePreview(sc.previews.systemVariables, !printmsg, e.loc,
|
||||
"accessing `@system` field `%s.%s`", ad, v))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
if (v.overlapped)
|
||||
{
|
||||
if (sc.func.isSafeBypassingInference() && sc.setUnsafe(!printmsg, e.loc,
|
||||
"field `%s.%s` cannot access pointers in `@safe` code that overlap other fields", ad, v))
|
||||
"accessing overlapped field `%s.%s` with pointers", ad, v))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
// To turn into an error, remove `isSafeBypassingInference` check in the
|
||||
// above if statement and remove the else branch
|
||||
sc.setUnsafePreview(FeatureState.default_, !printmsg, e.loc,
|
||||
"field `%s.%s` cannot access pointers in `@safe` code that overlap other fields", ad, v);
|
||||
"accessing overlapped field `%s.%s` with pointers", ad, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
if (v.overlapped)
|
||||
{
|
||||
if (sc.setUnsafe(!printmsg, e.loc,
|
||||
"field `%s.%s` cannot access structs with invariants in `@safe` code that overlap other fields",
|
||||
"accessing overlapped field `%s.%s` with a structs invariant",
|
||||
ad, v))
|
||||
return true;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
// Should probably be turned into an error in a new edition
|
||||
if (v.type.hasUnsafeBitpatterns() && v.overlapped && sc.setUnsafePreview(
|
||||
FeatureState.default_, !printmsg, e.loc,
|
||||
"cannot access overlapped field `%s.%s` with unsafe bit patterns in `@safe` code", ad, v)
|
||||
"accessing overlapped field `%s.%s` with unsafe bit patterns", ad, v)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
@ -140,7 +140,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
(v.offset & (target.ptrsize - 1)))
|
||||
{
|
||||
if (sc.setUnsafe(!printmsg, e.loc,
|
||||
"field `%s.%s` cannot modify misaligned pointers in `@safe` code", ad, v))
|
||||
"modifying misaligned pointers through field `%s.%s`", ad, v))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ bool checkUnsafeAccess(Scope* sc, Expression e, bool readonly, bool printmsg)
|
|||
if (v.overlapUnsafe)
|
||||
{
|
||||
if (sc.setUnsafe(!printmsg, e.loc,
|
||||
"field `%s.%s` cannot modify fields in `@safe` code that overlap fields with other storage classes",
|
||||
"modifying field `%s.%s` which overlaps with fields with other storage classes",
|
||||
ad, v))
|
||||
{
|
||||
return true;
|
||||
|
@ -181,6 +181,10 @@ bool isSafeCast(Expression e, Type tfrom, Type tto, ref string msg)
|
|||
auto tfromb = tfrom.toBasetype();
|
||||
auto ttob = tto.toBasetype();
|
||||
|
||||
// Casting to void* is always safe, https://github.com/dlang/dmd/issues/20514
|
||||
if (ttob.isTypePointer() && ttob.nextOf().toBasetype().ty == Tvoid)
|
||||
return true;
|
||||
|
||||
if (ttob.ty == Tclass && tfromb.ty == Tclass)
|
||||
{
|
||||
ClassDeclaration cdfrom = tfromb.isClassHandle();
|
||||
|
@ -310,9 +314,9 @@ bool checkUnsafeDotExp(Scope* sc, Expression e, Identifier id, int flag)
|
|||
if (!(flag & DotExpFlag.noDeref)) // this use is attempting a dereference
|
||||
{
|
||||
if (id == Id.ptr)
|
||||
return sc.setUnsafe(false, e.loc, "`%s.ptr` cannot be used in `@safe` code, use `&%s[0]` instead", e, e);
|
||||
return sc.setUnsafe(false, e.loc, "using `%s.ptr` (instead of `&%s[0])`", e, e);
|
||||
else
|
||||
return sc.setUnsafe(false, e.loc, "`%s.%s` cannot be used in `@safe` code", e, id);
|
||||
return sc.setUnsafe(false, e.loc, "using `%s.%s`", e, id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -323,8 +327,7 @@ bool checkUnsafeDotExp(Scope* sc, Expression e, Identifier id, int flag)
|
|||
*/
|
||||
bool isSaferD(FuncDeclaration fd)
|
||||
{
|
||||
return fd.type.toTypeFunction().trust == TRUST.default_ &&
|
||||
global.params.safer == FeatureState.enabled;
|
||||
return fd.type.toTypeFunction().trust == TRUST.default_ && fd.saferD;
|
||||
}
|
||||
|
||||
bool isSafe(FuncDeclaration fd)
|
||||
|
@ -378,7 +381,15 @@ extern (D) void reportSafeError(FuncDeclaration fd, bool gag, Loc loc,
|
|||
else if (fd.isSafe() || fd.isSaferD())
|
||||
{
|
||||
if (!gag && format)
|
||||
.error(loc, format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
{
|
||||
OutBuffer buf;
|
||||
buf.printf(format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
if (fd.isSafe())
|
||||
buf.writestring(" is not allowed in a `@safe` function");
|
||||
else
|
||||
buf.writestring(" is not allowed in a function with default safety with `-preview=safer`");
|
||||
.error(loc, buf.extractChars());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +468,11 @@ bool setUnsafe(Scope* sc,
|
|||
{
|
||||
if (sc.varDecl.storage_class & STC.safe)
|
||||
{
|
||||
.error(loc, format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
OutBuffer buf;
|
||||
buf.printf(format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
buf.printf(" can't initialize `@safe` variable `%s`", sc.varDecl.toChars());
|
||||
.error(loc, buf.extractChars());
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (!(sc.varDecl.storage_class & STC.trusted))
|
||||
|
@ -476,7 +491,10 @@ bool setUnsafe(Scope* sc,
|
|||
{
|
||||
// Message wil be gagged, but still call error() to update global.errors and for
|
||||
// -verrors=spec
|
||||
.error(loc, format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
OutBuffer buf;
|
||||
buf.printf(format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
buf.writestring(" is not allowed in a `@safe` function");
|
||||
.error(loc, buf.extractChars());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -534,7 +552,10 @@ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)
|
|||
{
|
||||
if (!gag && !sc.isDeprecated())
|
||||
{
|
||||
deprecation(loc, format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
OutBuffer buf;
|
||||
buf.printf(format, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
|
||||
buf.writestring(" will become `@system` in a future release");
|
||||
deprecation(loc, buf.extractChars());
|
||||
}
|
||||
}
|
||||
else if (!sc.func.safetyViolation)
|
||||
|
|
|
@ -102,7 +102,8 @@ struct Scope final
|
|||
|
||||
DeprecatedDeclaration *depdecl; // customized deprecation message
|
||||
|
||||
unsigned flags;
|
||||
uint16_t flags;
|
||||
uint16_t previews; // state of preview switches
|
||||
|
||||
bool ctor() const;
|
||||
bool ctor(bool v);
|
||||
|
@ -130,10 +131,6 @@ struct Scope final
|
|||
bool fullinst(bool v);
|
||||
bool ctfeBlock() const;
|
||||
bool ctfeBlock(bool v);
|
||||
bool dip1000() const;
|
||||
bool dip1000(bool v);
|
||||
bool dip25() const;
|
||||
bool dip25(bool v);
|
||||
|
||||
UserAttributeDeclaration *userAttribDecl; // user defined attributes
|
||||
|
||||
|
|
|
@ -298,6 +298,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
|
|||
return;
|
||||
funcdecl.semanticRun = PASS.semantic3;
|
||||
funcdecl.hasSemantic3Errors = false;
|
||||
funcdecl.saferD = sc.previews.safer;
|
||||
|
||||
if (!funcdecl.type || funcdecl.type.ty != Tfunction)
|
||||
return;
|
||||
|
@ -975,7 +976,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
|
|||
sc2 = sc2.pop();
|
||||
}
|
||||
|
||||
if (global.params.inclusiveInContracts)
|
||||
if (sc.previews.inclusiveInContracts)
|
||||
{
|
||||
funcdecl.frequire = funcdecl.mergeFrequireInclusivePreview(
|
||||
funcdecl.frequire, funcdecl.fdrequireParams);
|
||||
|
@ -1393,7 +1394,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
|
|||
}
|
||||
|
||||
// Do live analysis
|
||||
if (global.params.useDIP1021 && funcdecl.fbody && funcdecl.type.ty != Terror &&
|
||||
if (sc.previews.dip1021 && funcdecl.fbody && funcdecl.type.ty != Terror &&
|
||||
funcdecl.type.isTypeFunction().isLive)
|
||||
{
|
||||
oblive(funcdecl);
|
||||
|
|
|
@ -890,7 +890,7 @@ extern (C++) final class ForeachStatement : Statement
|
|||
extern (C++) final class ForeachRangeStatement : Statement
|
||||
{
|
||||
TOK op; // TOK.foreach_ or TOK.foreach_reverse_
|
||||
Parameter prm; // loop index variable
|
||||
Parameter param; // loop index variable
|
||||
Expression lwr;
|
||||
Expression upr;
|
||||
Statement _body;
|
||||
|
@ -898,11 +898,11 @@ extern (C++) final class ForeachRangeStatement : Statement
|
|||
|
||||
VarDeclaration key;
|
||||
|
||||
extern (D) this(const ref Loc loc, TOK op, Parameter prm, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe
|
||||
extern (D) this(const ref Loc loc, TOK op, Parameter param, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe
|
||||
{
|
||||
super(loc, STMT.ForeachRange);
|
||||
this.op = op;
|
||||
this.prm = prm;
|
||||
this.param = param;
|
||||
this.lwr = lwr;
|
||||
this.upr = upr;
|
||||
this._body = _body;
|
||||
|
@ -911,7 +911,7 @@ extern (C++) final class ForeachRangeStatement : Statement
|
|||
|
||||
override ForeachRangeStatement syntaxCopy()
|
||||
{
|
||||
return new ForeachRangeStatement(loc, op, prm.syntaxCopy(), lwr.syntaxCopy(), upr.syntaxCopy(), _body ? _body.syntaxCopy() : null, endloc);
|
||||
return new ForeachRangeStatement(loc, op, param.syntaxCopy(), lwr.syntaxCopy(), upr.syntaxCopy(), _body ? _body.syntaxCopy() : null, endloc);
|
||||
}
|
||||
|
||||
override bool hasBreak() const pure nothrow
|
||||
|
@ -935,17 +935,17 @@ extern (C++) final class ForeachRangeStatement : Statement
|
|||
*/
|
||||
extern (C++) final class IfStatement : Statement
|
||||
{
|
||||
Parameter prm;
|
||||
Parameter param;
|
||||
Expression condition;
|
||||
Statement ifbody;
|
||||
Statement elsebody;
|
||||
VarDeclaration match; // for MatchExpression results
|
||||
Loc endloc; // location of closing curly bracket
|
||||
|
||||
extern (D) this(const ref Loc loc, Parameter prm, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe
|
||||
extern (D) this(const ref Loc loc, Parameter param, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe
|
||||
{
|
||||
super(loc, STMT.If);
|
||||
this.prm = prm;
|
||||
this.param = param;
|
||||
this.condition = condition;
|
||||
this.ifbody = ifbody;
|
||||
this.elsebody = elsebody;
|
||||
|
@ -955,7 +955,7 @@ extern (C++) final class IfStatement : Statement
|
|||
override IfStatement syntaxCopy()
|
||||
{
|
||||
return new IfStatement(loc,
|
||||
prm ? prm.syntaxCopy() : null,
|
||||
param ? param.syntaxCopy() : null,
|
||||
condition.syntaxCopy(),
|
||||
ifbody ? ifbody.syntaxCopy() : null,
|
||||
elsebody ? elsebody.syntaxCopy() : null,
|
||||
|
|
|
@ -346,7 +346,7 @@ class ForeachRangeStatement final : public Statement
|
|||
{
|
||||
public:
|
||||
TOK op; // TOKforeach or TOKforeach_reverse
|
||||
Parameter *prm; // loop index variable
|
||||
Parameter *param; // loop index variable
|
||||
Expression *lwr;
|
||||
Expression *upr;
|
||||
Statement *_body;
|
||||
|
@ -364,7 +364,7 @@ public:
|
|||
class IfStatement final : public Statement
|
||||
{
|
||||
public:
|
||||
Parameter *prm;
|
||||
Parameter *param;
|
||||
Expression *condition;
|
||||
Statement *ifbody;
|
||||
Statement *elsebody;
|
||||
|
|
|
@ -1471,25 +1471,25 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
return setError();
|
||||
}
|
||||
|
||||
if (fs.prm.type)
|
||||
if (fs.param.type)
|
||||
{
|
||||
fs.prm.type = fs.prm.type.typeSemantic(loc, sc);
|
||||
fs.prm.type = fs.prm.type.addStorageClass(fs.prm.storageClass);
|
||||
fs.lwr = fs.lwr.implicitCastTo(sc, fs.prm.type);
|
||||
fs.param.type = fs.param.type.typeSemantic(loc, sc);
|
||||
fs.param.type = fs.param.type.addStorageClass(fs.param.storageClass);
|
||||
fs.lwr = fs.lwr.implicitCastTo(sc, fs.param.type);
|
||||
|
||||
if (fs.upr.implicitConvTo(fs.prm.type) || (fs.prm.storageClass & STC.ref_))
|
||||
if (fs.upr.implicitConvTo(fs.param.type) || (fs.param.storageClass & STC.ref_))
|
||||
{
|
||||
fs.upr = fs.upr.implicitCastTo(sc, fs.prm.type);
|
||||
fs.upr = fs.upr.implicitCastTo(sc, fs.param.type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// See if upr-1 fits in prm.type
|
||||
// See if upr-1 fits in param.type
|
||||
Expression limit = new MinExp(loc, fs.upr, IntegerExp.literal!1);
|
||||
limit = limit.expressionSemantic(sc);
|
||||
limit = limit.optimize(WANTvalue);
|
||||
if (!limit.implicitConvTo(fs.prm.type))
|
||||
if (!limit.implicitConvTo(fs.param.type))
|
||||
{
|
||||
fs.upr = fs.upr.implicitCastTo(sc, fs.prm.type);
|
||||
fs.upr = fs.upr.implicitCastTo(sc, fs.param.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1502,26 +1502,26 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
{
|
||||
/* Just picking the first really isn't good enough.
|
||||
*/
|
||||
fs.prm.type = fs.lwr.type;
|
||||
fs.param.type = fs.lwr.type;
|
||||
}
|
||||
else if (fs.lwr.type == fs.upr.type)
|
||||
{
|
||||
/* Same logic as CondExp ?lwr:upr
|
||||
*/
|
||||
fs.prm.type = fs.lwr.type;
|
||||
fs.param.type = fs.lwr.type;
|
||||
}
|
||||
else
|
||||
{
|
||||
scope AddExp ea = new AddExp(loc, fs.lwr, fs.upr);
|
||||
if (typeCombine(ea, sc))
|
||||
return setError();
|
||||
fs.prm.type = ea.type;
|
||||
fs.param.type = ea.type;
|
||||
fs.lwr = ea.e1;
|
||||
fs.upr = ea.e2;
|
||||
}
|
||||
fs.prm.type = fs.prm.type.addStorageClass(fs.prm.storageClass);
|
||||
fs.param.type = fs.param.type.addStorageClass(fs.param.storageClass);
|
||||
}
|
||||
if (fs.prm.type.ty == Terror || fs.lwr.op == EXP.error || fs.upr.op == EXP.error)
|
||||
if (fs.param.type.ty == Terror || fs.lwr.op == EXP.error || fs.upr.op == EXP.error)
|
||||
{
|
||||
return setError();
|
||||
}
|
||||
|
@ -1566,7 +1566,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
if (fs.op == TOK.foreach_reverse_)
|
||||
{
|
||||
cond = new PostExp(EXP.minusMinus, loc, new VarExp(loc, fs.key));
|
||||
if (fs.prm.type.isScalar())
|
||||
if (fs.param.type.isScalar())
|
||||
{
|
||||
// key-- > tmp
|
||||
cond = new CmpExp(EXP.greaterThan, loc, cond, new VarExp(loc, tmp));
|
||||
|
@ -1579,7 +1579,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (fs.prm.type.isScalar())
|
||||
if (fs.param.type.isScalar())
|
||||
{
|
||||
// key < tmp
|
||||
cond = new CmpExp(EXP.lessThan, loc, new VarExp(loc, fs.key), new VarExp(loc, tmp));
|
||||
|
@ -1598,30 +1598,30 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
//increment = new AddAssignExp(loc, new VarExp(loc, fs.key), IntegerExp.literal!1);
|
||||
increment = new PreExp(EXP.prePlusPlus, loc, new VarExp(loc, fs.key));
|
||||
}
|
||||
if ((fs.prm.storageClass & STC.ref_) && fs.prm.type.equals(fs.key.type))
|
||||
if ((fs.param.storageClass & STC.ref_) && fs.param.type.equals(fs.key.type))
|
||||
{
|
||||
fs.key.range = null;
|
||||
auto v = new AliasDeclaration(loc, fs.prm.ident, fs.key);
|
||||
auto v = new AliasDeclaration(loc, fs.param.ident, fs.key);
|
||||
fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body);
|
||||
}
|
||||
else
|
||||
{
|
||||
ie = new ExpInitializer(loc, new CastExp(loc, new VarExp(loc, fs.key), fs.prm.type));
|
||||
auto v = new VarDeclaration(loc, fs.prm.type, fs.prm.ident, ie);
|
||||
v.storage_class |= STC.temp | STC.foreach_ | (fs.prm.storageClass & STC.ref_);
|
||||
ie = new ExpInitializer(loc, new CastExp(loc, new VarExp(loc, fs.key), fs.param.type));
|
||||
auto v = new VarDeclaration(loc, fs.param.type, fs.param.ident, ie);
|
||||
v.storage_class |= STC.temp | STC.foreach_ | (fs.param.storageClass & STC.ref_);
|
||||
fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body);
|
||||
if (fs.key.range && !fs.prm.type.isMutable())
|
||||
if (fs.key.range && !fs.param.type.isMutable())
|
||||
{
|
||||
/* Limit the range of the key to the specified range
|
||||
*/
|
||||
v.range = new IntRange(fs.key.range.imin, fs.key.range.imax - SignExtendedNumber(1));
|
||||
}
|
||||
}
|
||||
if (fs.prm.storageClass & STC.ref_)
|
||||
if (fs.param.storageClass & STC.ref_)
|
||||
{
|
||||
if (fs.key.type.constConv(fs.prm.type) == MATCH.nomatch)
|
||||
if (fs.key.type.constConv(fs.param.type) == MATCH.nomatch)
|
||||
{
|
||||
error(fs.loc, "argument type mismatch, `%s` to `ref %s`", fs.key.type.toChars(), fs.prm.type.toChars());
|
||||
error(fs.loc, "argument type mismatch, `%s` to `ref %s`", fs.key.type.toChars(), fs.param.type.toChars());
|
||||
return setError();
|
||||
}
|
||||
}
|
||||
|
@ -1644,15 +1644,15 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
sym.parent = sc.scopesym;
|
||||
sym.endlinnum = ifs.endloc.linnum;
|
||||
Scope* scd = sc.push(sym);
|
||||
if (ifs.prm)
|
||||
if (ifs.param)
|
||||
{
|
||||
/* Declare prm, which we will set to be the
|
||||
/* Declare param, which we will set to be the
|
||||
* result of condition.
|
||||
*/
|
||||
auto ei = new ExpInitializer(ifs.loc, ifs.condition);
|
||||
ifs.match = new VarDeclaration(ifs.loc, ifs.prm.type, ifs.prm.ident, ei);
|
||||
ifs.match = new VarDeclaration(ifs.loc, ifs.param.type, ifs.param.ident, ei);
|
||||
ifs.match.parent = scd.func;
|
||||
ifs.match.storage_class |= ifs.prm.storageClass;
|
||||
ifs.match.storage_class |= ifs.param.storageClass;
|
||||
ifs.match.dsymbolSemantic(scd);
|
||||
|
||||
auto de = new DeclarationExp(ifs.loc, ifs.match);
|
||||
|
@ -1688,8 +1688,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
if (checkNonAssignmentArrayOp(ifs.condition))
|
||||
ifs.condition = ErrorExp.get();
|
||||
|
||||
// Convert to boolean after declaring prm so this works:
|
||||
// if (S prm = S()) {}
|
||||
// Convert to boolean after declaring param so this works:
|
||||
// if (S param = S()) {}
|
||||
// where S is a struct that defines opCast!bool.
|
||||
ifs.condition = ifs.condition.toBoolean(scd);
|
||||
|
||||
|
@ -2677,7 +2677,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
|
||||
// If we previously assumed the function could be ref when
|
||||
// checking for `shared`, make sure we were right
|
||||
if (global.params.noSharedAccess == FeatureState.enabled && rs.exp.type.isShared())
|
||||
if (sc.previews.noSharedAccess && rs.exp.type.isShared())
|
||||
{
|
||||
.error(fd.loc, "%s `%s` function returns `shared` but cannot be inferred `ref`", fd.kind, fd.toPrettyChars);
|
||||
supplemental();
|
||||
|
@ -3634,7 +3634,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
|
|||
deprecation(cas.loc, "`asm` statement cannot be marked `@safe`, use `@system` or `@trusted` instead");
|
||||
if (!(cas.stc & (STC.trusted | STC.safe)))
|
||||
{
|
||||
sc.setUnsafe(false, cas.loc, "`asm` statement is assumed to be `@system` - mark it with `@trusted` if it is not");
|
||||
sc.setUnsafe(false, cas.loc, "`asm` statement without `@trusted` annotation");
|
||||
}
|
||||
|
||||
sc.pop();
|
||||
|
@ -3997,12 +3997,12 @@ private FuncExp foreachBodyToFunction(Scope* sc, ForeachStatement fs, TypeFuncti
|
|||
p.type = p.type.addStorageClass(p.storageClass);
|
||||
if (tfld)
|
||||
{
|
||||
Parameter prm = tfld.parameterList[i];
|
||||
//printf("\tprm = %s%s\n", (prm.storageClass&STC.ref_?"ref ":"").ptr, prm.ident.toChars());
|
||||
stc = (prm.storageClass & STC.ref_) | (p.storageClass & STC.scope_);
|
||||
if ((p.storageClass & STC.ref_) != (prm.storageClass & STC.ref_))
|
||||
Parameter param = tfld.parameterList[i];
|
||||
//printf("\tparam = %s%s\n", (param.storageClass&STC.ref_?"ref ":"").ptr, param.ident.toChars());
|
||||
stc = (param.storageClass & STC.ref_) | (p.storageClass & STC.scope_);
|
||||
if ((p.storageClass & STC.ref_) != (param.storageClass & STC.ref_))
|
||||
{
|
||||
if (!(prm.storageClass & STC.ref_))
|
||||
if (!(param.storageClass & STC.ref_))
|
||||
{
|
||||
error(fs.loc, "`foreach`: cannot make `%s` `ref`", p.ident.toChars());
|
||||
return null;
|
||||
|
@ -4115,7 +4115,7 @@ void catchSemantic(Catch c, Scope* sc)
|
|||
}
|
||||
if (!c.internalCatch)
|
||||
{
|
||||
if (sc.setUnsafe(false, c.loc, "cannot catch C++ class objects in `@safe` code"))
|
||||
if (sc.setUnsafe(false, c.loc, "catching C++ class objects"))
|
||||
c.errors = true;
|
||||
}
|
||||
}
|
||||
|
@ -4127,18 +4127,18 @@ void catchSemantic(Catch c, Scope* sc)
|
|||
else if (!c.internalCatch && ClassDeclaration.exception &&
|
||||
cd != ClassDeclaration.exception && !ClassDeclaration.exception.isBaseOf(cd, null) &&
|
||||
sc.setUnsafe(false, c.loc,
|
||||
"can only catch class objects derived from `Exception` in `@safe` code, not `%s`", c.type))
|
||||
"catching class objects derived from `%s` instead of `Exception`", c.type))
|
||||
{
|
||||
c.errors = true;
|
||||
}
|
||||
else if (global.params.ehnogc)
|
||||
else if (sc.previews.dip1008)
|
||||
{
|
||||
stc |= STC.scope_;
|
||||
}
|
||||
|
||||
// DIP1008 requires destruction of the Throwable, even if the user didn't specify an identifier
|
||||
auto ident = c.ident;
|
||||
if (!ident && global.params.ehnogc)
|
||||
if (!ident && sc.previews.dip1008)
|
||||
ident = Identifier.generateAnonymousId("var");
|
||||
|
||||
if (ident)
|
||||
|
@ -4148,7 +4148,7 @@ void catchSemantic(Catch c, Scope* sc)
|
|||
c.var.dsymbolSemantic(sc);
|
||||
sc.insert(c.var);
|
||||
|
||||
if (global.params.ehnogc && stc & STC.scope_)
|
||||
if (sc.previews.dip1008 && stc & STC.scope_)
|
||||
{
|
||||
/* Add a destructor for c.var
|
||||
* try { handler } finally { if (!__ctfe) _d_delThrowable(var); }
|
||||
|
|
|
@ -1362,7 +1362,7 @@ extern (D) MATCHpair deduceFunctionTemplateMatch(TemplateDeclaration td, Templat
|
|||
{
|
||||
// Allow conversion from T[lwr .. upr] to ref T[upr-lwr]
|
||||
}
|
||||
else if (global.params.rvalueRefParam == FeatureState.enabled)
|
||||
else if (sc.previews.rvalueRefParam)
|
||||
{
|
||||
// Allow implicit conversion to ref
|
||||
}
|
||||
|
|
|
@ -1122,7 +1122,7 @@ private extern(D) MATCH argumentMatchParameter (FuncDeclaration fd, TypeFunction
|
|||
// Need to make this a rvalue through a temporary
|
||||
m = MATCH.convert;
|
||||
}
|
||||
else if (global.params.rvalueRefParam != FeatureState.enabled ||
|
||||
else if (!(sc && sc.previews.rvalueRefParam) ||
|
||||
p.storageClass & STC.out_ ||
|
||||
!arg.type.isCopyable()) // can't copy to temp for ref parameter
|
||||
{
|
||||
|
@ -2335,8 +2335,7 @@ Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
|
|||
|
||||
// default arg must be an lvalue
|
||||
if (isRefOrOut && !isAuto &&
|
||||
!(fparam.storageClass & STC.constscoperef) &&
|
||||
global.params.rvalueRefParam != FeatureState.enabled)
|
||||
!(fparam.storageClass & STC.constscoperef) && !sc.previews.rvalueRefParam)
|
||||
e = e.toLvalue(sc, "create default argument for `ref` / `out` parameter from");
|
||||
|
||||
fparam.defaultArg = e;
|
||||
|
|
|
@ -153,8 +153,8 @@ package(dmd.visitor) mixin template ParseVisitMethods(AST)
|
|||
override void visit(AST.ForeachRangeStatement s)
|
||||
{
|
||||
//printf("Visiting ForeachRangeStatement\n");
|
||||
if (s.prm.type)
|
||||
visitType(s.prm.type);
|
||||
if (s.param.type)
|
||||
visitType(s.param.type);
|
||||
s.lwr.accept(this);
|
||||
s.upr.accept(this);
|
||||
if (s._body)
|
||||
|
@ -174,8 +174,8 @@ package(dmd.visitor) mixin template ParseVisitMethods(AST)
|
|||
override void visit(AST.IfStatement s)
|
||||
{
|
||||
//printf("Visiting IfStatement\n");
|
||||
if (s.prm && s.prm.type)
|
||||
visitType(s.prm.type);
|
||||
if (s.param && s.param.type)
|
||||
visitType(s.param.type);
|
||||
s.condition.accept(this);
|
||||
s.ifbody.accept(this);
|
||||
if (s.elsebody)
|
||||
|
|
|
@ -19,6 +19,6 @@ void test3() @nogc
|
|||
|
||||
void test4() @safe
|
||||
{
|
||||
asm { } // { dg-error "'asm' statement is assumed to be '@system' - mark it with '@trusted' if it is not" }
|
||||
asm { } // { dg-error "'asm' statement without '@trusted' annotation is not allowed in a '@safe' function" }
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
union U { int i; bool b; }
|
||||
U u;
|
||||
u.i = 0x81818181;
|
||||
assert(array[u.b] == 678); // { dg-warning "cannot access overlapped field" }
|
||||
return u.b; // { dg-warning "cannot access overlapped field" }
|
||||
assert(array[u.b] == 678); // { dg-warning "accessing overlapped field" }
|
||||
return u.b; // { dg-warning "accessing overlapped field" }
|
||||
}
|
||||
|
||||
@safe void main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* REQUIRED_ARGS: -m64
|
||||
/* REQUIRED_ARGS: -verrors=simple -m64
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/b16976.d(33): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=20643
|
||||
// https://issues.dlang.org/show_bug.cgi?id=20644
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
----
|
||||
compilable/chkformat.d(14): Deprecation: more format specifiers than 0 arguments
|
||||
compilable/chkformat.d(15): Deprecation: more format specifiers than 0 arguments
|
||||
----
|
||||
*/
|
||||
import core.stdc.stdio;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// COMPILABLE_MATH_TEST
|
||||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// EXTRA_FILES: imports/a12506.d
|
||||
/* TEST_OUTPUT:
|
||||
---
|
||||
compilable/compile1.d(230): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/compile1.d(231): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
// REQUIRED_ARGS: -verrors=simple -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
// REQUIRED_ARGS: -verrors=simple -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
// REQUIRED_ARGS: -verrors=simple -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
// REQUIRED_ARGS: -verrors=simple -D -Dd${RESULTS_DIR}/compilable -wi -o-
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
REQUIRED_ARGS: -dw
|
||||
REQUIRED_ARGS: -verrors=simple -dw
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/depmsg.d(39): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message!
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=22668
|
||||
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// Overrides with same deprecated'ness are allowed
|
||||
|
||||
class SameParent
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
REQUIRED_ARGS: -verrors=3
|
||||
REQUIRED_ARGS: -verrors=simple -verrors=3
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/deprecationlimit.d(18): Deprecation: function `deprecationlimit.f` is deprecated
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/+
|
||||
REQUIRED_ARGS: -HC -c -o- -wi -extern-std=c++20
|
||||
REQUIRED_ARGS: -verrors=simple -HC -c -o- -wi -extern-std=c++20
|
||||
PERMUTE_ARGS:
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// PERMUTE_ARGS: -inline
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/interpret3.d(6350): Deprecation: identity comparison of static arrays implicitly coerces them to slices, which are compared by reference
|
||||
compilable/interpret3.d(6351): Deprecation: identity comparison of static arrays implicitly coerces them to slices, which are compared by reference
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// PERMUTE_ARGS:
|
||||
// REQUIRED_ARGS: -unittest -verrors=0
|
||||
// REQUIRED_ARGS: -verrors=simple -unittest -verrors=0
|
||||
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// REQUIRED_ARGS:
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// EXTRA_FILES: imports/a12567.d
|
||||
// PERMUTE_ARGS:
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=19227
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
/* TEST_OUTPUT:
|
||||
---
|
||||
compilable/test19227.d(16): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead
|
||||
compilable/test19227.d(17): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead
|
||||
Deprecation: use of complex type `const(cfloat)` is deprecated, use `std.complex.Complex!(float)` instead
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=19609
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// EXTRA_FILES: imports/test19609a.d imports/test19609b.d imports/test19609c.d
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/test19609.d(11): Deprecation: module `imports.test19609a` is deprecated
|
||||
compilable/test19609.d(12): Deprecation: module `imports.test19609b` is deprecated - hello
|
||||
compilable/test19609.d(13): Deprecation: module `imports.test19609c` is deprecated
|
||||
compilable/test19609.d(12): Deprecation: module `imports.test19609a` is deprecated
|
||||
compilable/test19609.d(13): Deprecation: module `imports.test19609b` is deprecated - hello
|
||||
compilable/test19609.d(14): Deprecation: module `imports.test19609c` is deprecated
|
||||
---
|
||||
*/
|
||||
import imports.test19609a;
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=21514
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// DISABLED: win32 win64
|
||||
/* TEST_OUTPUT:
|
||||
---
|
||||
compilable/test21514.d(16): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(16): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(17): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(17): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(19): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(19): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(20): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(20): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(17): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(17): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(18): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(18): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(20): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(20): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
|
||||
compilable/test21514.d(21): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
compilable/test21514.d(21): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* https://issues.dlang.org/show_bug.cgi?id=23097
|
||||
REQUIRED_ARGS: -verrors=spec
|
||||
REQUIRED_ARGS: -verrors=simple -verrors=spec
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
(spec:2) compilable/test23097.d(14): Error: `inout` constructor `test23097.S23097.this` creates const object, not mutable
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// https://issues.dlang.org/show_bug.cgi?id=9701
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
compilable/test9701.d(68): Deprecation: enum member `test9701.Enum.value7` is deprecated
|
||||
compilable/test9701.d(68): Deprecation: enum member `test9701.Enum.value8` is deprecated - message
|
||||
compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value7` is deprecated
|
||||
compilable/test9701.d(69): Deprecation: enum member `test9701.Enum.value8` is deprecated - message
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// REQUIRED_ARGS:
|
||||
// REQUIRED_ARGS: -verrors=simple
|
||||
// PERMUTE_ARGS:
|
||||
// EXTRA_FILES: imports/udamodule1.d
|
||||
/*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
PERMUTE_ARGS:
|
||||
REQUIRED_ARGS: -verrors=spec
|
||||
REQUIRED_ARGS: -verrors=simple -verrors=spec
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
(spec:1) compilable/verrors_spec.d(13): Error: cannot implicitly convert expression `& i` of type `int*` to `int`
|
||||
|
|
|
@ -5,11 +5,11 @@ fail_compilation/attributediagnostic.d(24): Error: `@safe` function `attributedi
|
|||
fail_compilation/attributediagnostic.d(26): which calls `attributediagnostic.layer0`
|
||||
fail_compilation/attributediagnostic.d(28): which calls `attributediagnostic.system`
|
||||
fail_compilation/attributediagnostic.d(30): which wasn't inferred `@safe` because of:
|
||||
fail_compilation/attributediagnostic.d(30): `asm` statement is assumed to be `@system` - mark it with `@trusted` if it is not
|
||||
fail_compilation/attributediagnostic.d(30): `asm` statement without `@trusted` annotation
|
||||
fail_compilation/attributediagnostic.d(25): `attributediagnostic.layer1` is declared here
|
||||
fail_compilation/attributediagnostic.d(46): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system1`
|
||||
fail_compilation/attributediagnostic.d(35): which wasn't inferred `@safe` because of:
|
||||
fail_compilation/attributediagnostic.d(35): cast from `uint` to `int*` not allowed in safe code
|
||||
fail_compilation/attributediagnostic.d(35): cast from `uint` to `int*`
|
||||
fail_compilation/attributediagnostic.d(33): `attributediagnostic.system1` is declared here
|
||||
fail_compilation/attributediagnostic.d(47): Error: `@safe` function `D main` cannot call `@system` function `attributediagnostic.system2`
|
||||
fail_compilation/attributediagnostic.d(41): which wasn't inferred `@safe` because of:
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
REQUIRED_ARGS: -de -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/bool_cast.d(17): Deprecation: cast from `ubyte[]` to `bool[]` not allowed in safe code
|
||||
fail_compilation/bool_cast.d(17): Deprecation: cast from `ubyte[]` to `bool[]` will become `@system` in a future release
|
||||
fail_compilation/bool_cast.d(17): Source element may have bytes which are not 0 or 1
|
||||
fail_compilation/bool_cast.d(22): Deprecation: cast from `int*` to `bool*` not allowed in safe code
|
||||
fail_compilation/bool_cast.d(22): Deprecation: cast from `int*` to `bool*` will become `@system` in a future release
|
||||
fail_compilation/bool_cast.d(22): Source element may have bytes which are not 0 or 1
|
||||
fail_compilation/bool_cast.d(24): Deprecation: cast from `bool*` to `byte*` not allowed in safe code
|
||||
fail_compilation/bool_cast.d(24): Deprecation: cast from `bool*` to `byte*` will become `@system` in a future release
|
||||
fail_compilation/bool_cast.d(24): Target element could be assigned a byte which is not 0 or 1
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/bug19569.d(70): Error: `bug19569.test0` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(70): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(56): `bug19569.test0()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(57): `bug19569.test0()`
|
||||
fail_compilation/bug19569.d(71): Error: `bug19569.test1` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(71): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(59): `bug19569.test1()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(60): `bug19569.test1()`
|
||||
fail_compilation/bug19569.d(72): Error: `bug19569.test2` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(72): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(62): `bug19569.test2!().test2()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(63): `bug19569.test2!().test2()`
|
||||
fail_compilation/bug19569.d(73): Error: `bug19569.test3` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(73): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(65): `bug19569.test3!().test3()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(66): `bug19569.test3!().test3()`
|
||||
fail_compilation/bug19569.d(78): Error: `bug19569.test0` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(78): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(56): `bug19569.test0()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(57): `bug19569.test0()`
|
||||
fail_compilation/bug19569.d(79): Error: `bug19569.test1` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(79): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(59): `bug19569.test1()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(60): `bug19569.test1()`
|
||||
fail_compilation/bug19569.d(80): Error: `bug19569.test2` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(80): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(62): `bug19569.test2!().test2()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(63): `bug19569.test2!().test2()`
|
||||
fail_compilation/bug19569.d(81): Error: `bug19569.test3` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(81): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(65): `bug19569.test3!().test3()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(66): `bug19569.test3!().test3()`
|
||||
fail_compilation/bug19569.d(86): Error: `bug19569.test0` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(86): Error: `bug19569.test0` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(56): `bug19569.test0()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(57): `bug19569.test0()`
|
||||
fail_compilation/bug19569.d(87): Error: `bug19569.test1` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(87): Error: `bug19569.test1` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(59): `bug19569.test1()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(60): `bug19569.test1()`
|
||||
fail_compilation/bug19569.d(88): Error: `bug19569.test2` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(88): Error: `bug19569.test2` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(62): `bug19569.test2!().test2()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(63): `bug19569.test2!().test2()`
|
||||
fail_compilation/bug19569.d(89): Error: `bug19569.test3` called with argument types `()` matches both:
|
||||
fail_compilation/bug19569.d(89): Error: `bug19569.test3` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/bug19569.d(65): `bug19569.test3!().test3()`
|
||||
and:
|
||||
fail_compilation/bug19569.d(66): `bug19569.test3!().test3()`
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
REQUIRED_ARGS: -preview=dip1000 -de
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/cast_qual.d(17): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code
|
||||
fail_compilation/cast_qual.d(19): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code
|
||||
fail_compilation/cast_qual.d(25): Error: cast from `const(Object)` to `object.Object` not allowed in safe code
|
||||
fail_compilation/cast_qual.d(17): Deprecation: using the result of a cast from `const(int)` to `int` as an lvalue will become `@system` in a future release
|
||||
fail_compilation/cast_qual.d(19): Deprecation: using the result of a cast from `const(int)` to `int` as an lvalue will become `@system` in a future release
|
||||
fail_compilation/cast_qual.d(25): Error: cast from `const(Object)` to `object.Object` is not allowed in a `@safe` function
|
||||
fail_compilation/cast_qual.d(25): Incompatible type qualifier
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
REQUIRED_ARGS: -de
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/cpp_cast.d(19): Error: cast from `cpp_cast.I` to `cpp_cast.C` not allowed in safe code
|
||||
fail_compilation/cpp_cast.d(19): Error: cast from `cpp_cast.I` to `cpp_cast.C` is not allowed in a `@safe` function
|
||||
fail_compilation/cpp_cast.d(19): No dynamic type information for extern(C++) classes
|
||||
fail_compilation/cpp_cast.d(21): Deprecation: cast from `cpp_cast.C` to `cpp_cast.D` not allowed in safe code
|
||||
fail_compilation/cpp_cast.d(21): Deprecation: cast from `cpp_cast.C` to `cpp_cast.D` will become `@system` in a future release
|
||||
fail_compilation/cpp_cast.d(21): No dynamic type information for extern(C++) classes
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/cppeh1.d(26): Error: cannot catch C++ class objects in `@safe` code
|
||||
fail_compilation/cppeh1.d(26): Error: catching C++ class objects is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ fail_compilation/diag10319.d(26): which wasn't inferred `pure` because of
|
|||
fail_compilation/diag10319.d(26): `pure` function `diag10319.bar!int.bar` cannot access mutable static data `g`
|
||||
fail_compilation/diag10319.d(34): Error: `@safe` function `D main` cannot call `@system` function `diag10319.bar!int.bar`
|
||||
fail_compilation/diag10319.d(27): which wasn't inferred `@safe` because of:
|
||||
fail_compilation/diag10319.d(27): cannot take address of local `x` in `@safe` function `bar`
|
||||
fail_compilation/diag10319.d(27): taking the address of stack-allocated local variable `x`
|
||||
fail_compilation/diag10319.d(24): `diag10319.bar!int.bar` is declared here
|
||||
fail_compilation/diag10319.d(33): Error: function `diag10319.foo` is not `nothrow`
|
||||
fail_compilation/diag10319.d(34): Error: function `diag10319.bar!int.bar` is not `nothrow`
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/diag10359.d(10): Error: pointer slicing not allowed in safe functions
|
||||
fail_compilation/diag10359.d(10): Error: pointer slicing is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/diag11769.d(18): Error: `diag11769.foo!string.bar` called with argument types `(string)` matches both:
|
||||
fail_compilation/diag11769.d(18): Error: `diag11769.foo!string.bar` called with argument types `(string)` matches multiple overloads after implicit conversions:
|
||||
fail_compilation/diag11769.d(13): `diag11769.foo!string.bar(wstring __param_0)`
|
||||
and:
|
||||
fail_compilation/diag11769.d(14): `diag11769.foo!string.bar(dstring __param_0)`
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/diag23295.d(21): Error: scope variable `x` assigned to non-scope parameter `y` calling `foo`
|
||||
fail_compilation/diag23295.d(21): Error: assigning scope variable `x` to non-scope parameter `y` calling `foo` is not allowed in a `@safe` function
|
||||
fail_compilation/diag23295.d(32): which is assigned to non-scope parameter `z`
|
||||
fail_compilation/diag23295.d(34): which is not `scope` because of `f = & z`
|
||||
fail_compilation/diag23295.d(24): Error: scope variable `ex` assigned to non-scope parameter `e` calling `thro`
|
||||
fail_compilation/diag23295.d(24): Error: assigning scope variable `ex` to non-scope parameter `e` calling `thro` is not allowed in a `@safe` function
|
||||
fail_compilation/diag23295.d(39): which is not `scope` because of `throw e`
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
REQUIRED_ARGS:
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/dip25.d(17): Error: returning `this.buffer[]` escapes a reference to parameter `this`
|
||||
fail_compilation/dip25.d(17): Error: escaping a reference to parameter `this` by returning `this.buffer[]` is not allowed in a `@safe` function
|
||||
fail_compilation/dip25.d(15): perhaps annotate the function with `return`
|
||||
fail_compilation/dip25.d(22): Error: returning `identity(x)` escapes a reference to parameter `x`
|
||||
fail_compilation/dip25.d(23): Error: returning `identity(x)` escapes a reference to parameter `x`
|
||||
fail_compilation/dip25.d(23): Error: escaping a reference to parameter `x` by returning `identity(x)` is not allowed in a `@safe` function
|
||||
fail_compilation/dip25.d(23): perhaps annotate the parameter with `return`
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail14554.d(28): Error: `fail14554.issue14554_1.foo` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail14554.d(28): Error: `fail14554.issue14554_1.foo` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail14554.d(17): `fail14554.issue14554_1.foo!bool.foo(int j)`
|
||||
and:
|
||||
fail_compilation/fail14554.d(18): `fail14554.issue14554_1.foo!bool.foo(int j)`
|
||||
fail_compilation/fail14554.d(29): Error: `fail14554.issue14554_2.foo` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail14554.d(29): Error: `fail14554.issue14554_2.foo` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail14554.d(22): `fail14554.issue14554_2.foo!bool.foo(int j)`
|
||||
and:
|
||||
fail_compilation/fail14554.d(23): `fail14554.issue14554_2.foo!bool.foo(int j)`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail16600.d(22): Error: `fail16600.S.__ctor` called with argument types `(string) const` matches both:
|
||||
fail_compilation/fail16600.d(22): Error: `fail16600.S.__ctor` called with argument types `(string) const` matches multiple overloads exactly:
|
||||
fail_compilation/fail16600.d(16): `fail16600.S.this(string __param_0)`
|
||||
and:
|
||||
fail_compilation/fail16600.d(17): `fail16600.S.this(string __param_0) immutable`
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail17842.d(14): Error: scope variable `p` assigned to non-scope `*q`
|
||||
fail_compilation/fail17842.d(23): Error: scope variable `obj` may not be copied into allocated memory
|
||||
fail_compilation/fail17842.d(14): Error: assigning scope variable `p` to non-scope `*q` is not allowed in a `@safe` function
|
||||
fail_compilation/fail17842.d(23): Error: copying scope variable `obj` into allocated memory is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail19729.d(35): Error: `fail19729.C.__ctor` called with argument types `(string)` matches both:
|
||||
fail_compilation/fail19729.d(35): Error: `fail19729.C.__ctor` called with argument types `(string)` matches multiple overloads exactly:
|
||||
fail_compilation/fail19729.d(18): `fail19729.C.Templ!string.this(string t)`
|
||||
and:
|
||||
fail_compilation/fail19729.d(18): `fail19729.C.Templ!string.this(string t)`
|
||||
fail_compilation/fail19729.d(36): Error: `fail19729.D.__ctor` called with argument types `(string)` matches both:
|
||||
fail_compilation/fail19729.d(36): Error: `fail19729.D.__ctor` called with argument types `(string)` matches multiple overloads after qualifier conversion:
|
||||
fail_compilation/fail19729.d(18): `fail19729.D.Templ!(const(char)[]).this(const(char)[] t)`
|
||||
and:
|
||||
fail_compilation/fail19729.d(18): `fail19729.D.Templ!(const(char)*).this(const(char)* t)`
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail19881.d(13): Error: address of local variable `local` assigned to return scope `input`
|
||||
fail_compilation/fail19881.d(13): Error: address of variable `local` assigned to `input` with longer lifetime
|
||||
fail_compilation/fail19881.d(13): Error: assigning address of local variable `local` to return scope `input` is not allowed in a `@safe` function
|
||||
fail_compilation/fail19881.d(13): Error: assigning address of variable `local` to `input` with longer lifetime is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail19965.d(36): Error: address of variable `f` assigned to `a` with longer lifetime
|
||||
fail_compilation/fail19965.d(36): Error: assigning address of variable `f` to `a` with longer lifetime is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20000.d(37): Error: cast from `fail20000.DClass` to `fail20000.CppClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(37): Error: cast from `fail20000.DClass` to `fail20000.CppClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(37): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(38): Error: cast from `fail20000.DInterface` to `fail20000.CppClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(38): Error: cast from `fail20000.DInterface` to `fail20000.CppClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(38): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(39): Error: cast from `fail20000.CppClass2` to `fail20000.CppClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(39): Error: cast from `fail20000.CppClass2` to `fail20000.CppClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(39): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(40): Error: cast from `fail20000.CppInterface2` to `fail20000.CppClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(40): Error: cast from `fail20000.CppInterface2` to `fail20000.CppClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(40): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(42): Error: cast from `fail20000.DClass` to `fail20000.CppInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(42): Error: cast from `fail20000.DClass` to `fail20000.CppInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(42): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(43): Error: cast from `fail20000.DInterface` to `fail20000.CppInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(43): Error: cast from `fail20000.DInterface` to `fail20000.CppInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(43): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(44): Error: cast from `fail20000.CppClass2` to `fail20000.CppInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(44): Error: cast from `fail20000.CppClass2` to `fail20000.CppInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(44): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(45): Error: cast from `fail20000.CppInterface2` to `fail20000.CppInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(45): Error: cast from `fail20000.CppInterface2` to `fail20000.CppInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(45): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(47): Error: cast from `fail20000.CppClass` to `fail20000.DClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(47): Error: cast from `fail20000.CppClass` to `fail20000.DClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(47): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(48): Error: cast from `fail20000.CppInterface` to `fail20000.DClass` not allowed in safe code
|
||||
fail_compilation/fail20000.d(48): Error: cast from `fail20000.CppInterface` to `fail20000.DClass` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(48): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(50): Error: cast from `fail20000.CppClass` to `fail20000.DInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(50): Error: cast from `fail20000.CppClass` to `fail20000.DInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(50): Source object type is incompatible with target type
|
||||
fail_compilation/fail20000.d(51): Error: cast from `fail20000.CppInterface` to `fail20000.DInterface` not allowed in safe code
|
||||
fail_compilation/fail20000.d(51): Error: cast from `fail20000.CppInterface` to `fail20000.DInterface` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20000.d(51): Source object type is incompatible with target type
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20084.d(109): Error: returning `v.front()` escapes a reference to parameter `v`
|
||||
fail_compilation/fail20084.d(109): Error: escaping a reference to parameter `v` by returning `v.front()` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20108.d(15): Error: address of variable `y` assigned to `x` with longer lifetime
|
||||
fail_compilation/fail20108.d(15): Error: assigning address of variable `y` to `x` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/fail20108.d(16): Error: scope parameter `x` may not be returned
|
||||
fail_compilation/fail20108.d(23): Error: address of variable `y` assigned to `x` with longer lifetime
|
||||
fail_compilation/fail20108.d(24): Error: scope variable `x` may not be returned
|
||||
fail_compilation/fail20108.d(23): Error: assigning address of variable `y` to `x` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/fail20108.d(24): Error: returning scope variable `x` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ TEST_OUTPUT:
|
|||
fail_compilation/fail20183.d(1016): Error: function `addr` is not callable using argument types `(int)`
|
||||
fail_compilation/fail20183.d(1016): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b`
|
||||
fail_compilation/fail20183.d(1004): `fail20183.addr(return ref int b)` declared here
|
||||
fail_compilation/fail20183.d(1017): Error: address of expression temporary returned by `s()` assigned to `q` with longer lifetime
|
||||
fail_compilation/fail20183.d(1018): Error: address of struct literal `S(0)` assigned to `r` with longer lifetime
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -34,7 +32,9 @@ void test()
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20183.d(1107): Error: address of expression temporary returned by `s()` assigned to `this.ptr` with longer lifetime
|
||||
fail_compilation/fail20183.d(1017): Error: assigning address of expression temporary returned by `s()` to `q` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/fail20183.d(1018): Error: assigning address of struct literal `S(0)` to `r` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/fail20183.d(1107): Error: assigning address of expression temporary returned by `s()` to `this.ptr` with longer lifetime is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
#line 1100
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20461.d(106): Error: reference to local variable `buffer` assigned to non-scope parameter calling `assert()`
|
||||
fail_compilation/fail20461.d(106): Error: assigningreference to local variable `buffer` to non-scope parameter calling `assert()` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20551.d(15): Error: cannot take address of lazy parameter `e` in `@safe` function `opAssign`
|
||||
fail_compilation/fail20551.d(15): Error: taking address of lazy parameter `e` is not allowed in a `@safe` function
|
||||
fail_compilation/fail20551.d(26): Error: template instance `fail20551.LazyStore!int.LazyStore.opAssign!int` error instantiating
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20658.d(14): Error: field `U.m` cannot modify fields in `@safe` code that overlap fields with other storage classes
|
||||
fail_compilation/fail20658.d(14): Error: modifying field `U.m` which overlaps with fields with other storage classes is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail20691.d(106): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
|
||||
fail_compilation/fail20691.d(107): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
|
||||
fail_compilation/fail20691.d(108): Error: cannot take address of `scope` variable `sa` since `scope` applies to first indirection only
|
||||
fail_compilation/fail20691.d(106): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function
|
||||
fail_compilation/fail20691.d(107): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function
|
||||
fail_compilation/fail20691.d(108): Error: taking address of `scope` variable `sa` with pointers is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail21868b.d(19): Error: returning `&s.x` escapes a reference to parameter `s`
|
||||
fail_compilation/fail21868b.d(19): Error: escaping a reference to parameter `s` by returning `&s.x` is not allowed in a `@safe` function
|
||||
fail_compilation/fail21868b.d(17): perhaps change the `return scope` into `scope return`
|
||||
---
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail22138.d(107): Error: scope variable `e` may not be returned
|
||||
fail_compilation/fail22138.d(107): Error: returning scope variable `e` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail22157.d(32): Error: `fail22157.S!true.S.foo` called with argument types `()` matches both:
|
||||
fail_compilation/fail22157.d(32): Error: `fail22157.S!true.S.foo` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/fail22157.d(21): `fail22157.S!true.S.foo()`
|
||||
and:
|
||||
fail_compilation/fail22157.d(22): `fail22157.S!true.S.foo()`
|
||||
fail_compilation/fail22157.d(33): Error: `fail22157.S!false.S.foo` called with argument types `()` matches both:
|
||||
fail_compilation/fail22157.d(33): Error: `fail22157.S!false.S.foo` called with argument types `()` matches multiple overloads exactly:
|
||||
fail_compilation/fail22157.d(26): `fail22157.S!false.S.foo()`
|
||||
and:
|
||||
fail_compilation/fail22157.d(27): `fail22157.S!false.S.foo()`
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail22366.d(22): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(25): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(26): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(27): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(28): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(31): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(32): Error: scope variable `s` may not be copied into allocated memory
|
||||
fail_compilation/fail22366.d(22): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(25): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(26): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(27): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(28): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(31): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
fail_compilation/fail22366.d(32): Error: copying scope variable `s` into allocated memory is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail23626b.d(26): Error: `fail23626b.AmbigOpApply.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches both:
|
||||
fail_compilation/fail23626b.d(26): Error: `fail23626b.AmbigOpApply.opApply` called with argument types `(int delegate(int i) pure nothrow @nogc @system)` matches multiple overloads after qualifier conversion:
|
||||
fail_compilation/fail23626b.d(12): `fail23626b.AmbigOpApply.opApply(int delegate(int) dg)`
|
||||
and:
|
||||
fail_compilation/fail23626b.d(17): `fail23626b.AmbigOpApply.opApply(int delegate(int) dg)`
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail24208.d(19): Error: reference to local variable `n` assigned to non-scope parameter `p` calling `escape`
|
||||
fail_compilation/fail24208.d(19): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `escape` is not allowed in a `@safe` function
|
||||
fail_compilation/fail24208.d(15): which is not `scope` because of `escaped = p`
|
||||
---
|
||||
+/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail24212.d(29): Error: reference to local variable `n` assigned to non-scope parameter `p` calling `fun`
|
||||
fail_compilation/fail24212.d(29): Error: assigning reference to local variable `n` to non-scope parameter `p` calling `fun` is not allowed in a `@safe` function
|
||||
---
|
||||
+/
|
||||
class Base
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail24213.d(16): Error: reference to local variable `n` assigned to non-scope parameter `p`
|
||||
fail_compilation/fail24213.d(16): Error: assigning reference to local variable `n` to non-scope parameter `p` is not allowed in a `@safe` function
|
||||
---
|
||||
+/
|
||||
alias Dg = void delegate(int* p) @safe pure nothrow;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail6497.d(12): Error: cannot take address of local `n` in `@safe` function `main`
|
||||
fail_compilation/fail6497.d(12): Error: cannot take address of local `n` in `@safe` function `main`
|
||||
fail_compilation/fail6497.d(12): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function
|
||||
fail_compilation/fail6497.d(12): Error: taking the address of stack-allocated local variable `n` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail8313.d(13): Error: `fail8313.bar` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail8313.d(13): Error: `fail8313.bar` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail8313.d(11): `fail8313.bar!().bar(int x)`
|
||||
and:
|
||||
fail_compilation/fail8313.d(12): `fail8313.bar!().bar(int x)`
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail8373.d(21): Error: `fail8373.fun1` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail8373.d(21): Error: `fail8373.fun1` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail8373.d(15): `fail8373.fun1!().fun1!int.fun1(int)`
|
||||
and:
|
||||
fail_compilation/fail8373.d(16): `fail8373.fun1!int.fun1(int)`
|
||||
fail_compilation/fail8373.d(22): Error: `fail8373.fun2` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail8373.d(22): Error: `fail8373.fun2` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail8373.d(18): `fail8373.fun2!int.fun2(int)`
|
||||
and:
|
||||
fail_compilation/fail8373.d(19): `fail8373.fun2!().fun2!int.fun2(int)`
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
REQUIRED_ARGS: -verrors=context
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fail_pretty_errors.d(24): Error: undefined identifier `a`
|
||||
fail_compilation/fail_pretty_errors.d(27): Error: undefined identifier `a`
|
||||
a = 1;
|
||||
^
|
||||
fail_compilation/fail_pretty_errors.d-mixin-29(29): Error: undefined identifier `b`
|
||||
fail_compilation/fail_pretty_errors.d(34): Error: cannot implicitly convert expression `5` of type `int` to `string`
|
||||
fail_compilation/fail_pretty_errors.d-mixin-32(32): Error: undefined identifier `b`
|
||||
fail_compilation/fail_pretty_errors.d(37): Error: cannot implicitly convert expression `5` of type `int` to `string`
|
||||
string x = 5;
|
||||
^
|
||||
fail_compilation/fail_pretty_errors.d(39): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating
|
||||
fail_compilation/fail_pretty_errors.d(42): Error: mixin `fail_pretty_errors.testMixin2.mixinTemplate!()` error instantiating
|
||||
mixin mixinTemplate;
|
||||
^
|
||||
fail_compilation/fail_pretty_errors.d(45): Error: invalid array operation `"" + ""` (possible missing [])
|
||||
fail_compilation/fail_pretty_errors.d(48): Error: invalid array operation `"" + ""` (possible missing [])
|
||||
auto x = ""+"";
|
||||
^
|
||||
fail_compilation/fail_pretty_errors.d(45): did you mean to concatenate (`"" ~ ""`) instead ?
|
||||
fail_compilation/fail_pretty_errors.d(48): did you mean to concatenate (`"" ~ ""`) instead ?
|
||||
fail_compilation/fail_pretty_errors.d(51): Error: cannot implicitly convert expression `1111` of type `int` to `byte`
|
||||
byte ɑ = 1111;
|
||||
^
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -43,4 +46,7 @@ void f()
|
|||
{
|
||||
// check supplemental error doesn't show context
|
||||
auto x = ""+"";
|
||||
|
||||
// Check correct spacing with the presence of unicode characters and tabs
|
||||
byte ɑ = 1111;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ TEST_OUTPUT:
|
|||
---
|
||||
fail_compilation/fail_scope.d(43): Error: returning `cast(char[])string` escapes a reference to local variable `string`
|
||||
fail_compilation/fail_scope.d(61): Error: returning `s.bar()` escapes a reference to local variable `s`
|
||||
fail_compilation/fail_scope.d(72): Error: `fail_scope.foo8` called with argument types `(int)` matches both:
|
||||
fail_compilation/fail_scope.d(72): Error: `fail_scope.foo8` called with argument types `(int)` matches multiple overloads exactly:
|
||||
fail_compilation/fail_scope.d(66): `fail_scope.foo8(ref int x)`
|
||||
and:
|
||||
fail_compilation/fail_scope.d(67): `fail_scope.foo8(return ref int x)`
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fix22108.d(12): Error: scope variable `p` may not be returned
|
||||
fail_compilation/fix22108.d(12): Error: returning scope variable `p` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* REQUIRED_ARGS: -preview=dip1000
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fix5212.d(14): Error: scope variable `args_` assigned to non-scope `this.args`
|
||||
fail_compilation/fix5212.d(14): Error: assigning scope variable `args_` to non-scope `this.args` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ fail_compilation/named_arguments_overload.d(18): `named_a
|
|||
fail_compilation/named_arguments_overload.d(34): Error: none of the overloads of `snoopy` are callable using argument types `(immutable(T), immutable(S))`
|
||||
fail_compilation/named_arguments_overload.d(17): Candidates are: `named_arguments_overload.snoopy(S s, int i = 0, T t = T())`
|
||||
fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)`
|
||||
fail_compilation/named_arguments_overload.d(35): Error: `named_arguments_overload.snoopy` called with argument types `(immutable(S), immutable(T), immutable(int))` matches both:
|
||||
fail_compilation/named_arguments_overload.d(35): Error: `named_arguments_overload.snoopy` called with argument types `(immutable(S), immutable(T), immutable(int))` matches multiple overloads after qualifier conversion:
|
||||
fail_compilation/named_arguments_overload.d(17): `named_arguments_overload.snoopy(S s, int i = 0, T t = T())`
|
||||
and:
|
||||
fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)`
|
||||
|
|
|
@ -11,11 +11,11 @@ fail_compilation/previewin.d(11): `previewin.takeFunction(void function(i
|
|||
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(11): `previewin.takeFunction(void function(in real) f)` declared here
|
||||
fail_compilation/previewin.d(15): Error: scope variable `arg` assigned to global variable `myGlobal`
|
||||
fail_compilation/previewin.d(16): Error: scope variable `arg` assigned to global variable `myGlobal`
|
||||
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
|
||||
fail_compilation/previewin.d(17): Error: scope parameter `arg` may not be returned
|
||||
fail_compilation/previewin.d(18): Error: scope variable `arg` assigned to `ref` variable `escape` with longer lifetime
|
||||
fail_compilation/previewin.d(22): Error: returning `arg` escapes a reference to parameter `arg`
|
||||
fail_compilation/previewin.d(18): Error: assigning scope variable `arg` to `ref` variable `escape` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/previewin.d(22): Error: escaping a reference to parameter `arg` by returning `arg` is not allowed in a `@safe` function
|
||||
fail_compilation/previewin.d(22): perhaps annotate the parameter with `return`
|
||||
----
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/pull12941.d(110): Error: `pull12941.foo` called with argument types `(int*)` matches both:
|
||||
fail_compilation/pull12941.d(110): Error: `pull12941.foo` called with argument types `(int*)` matches multiple overloads exactly:
|
||||
fail_compilation/pull12941.d(101): `pull12941.foo(return ref scope int* p)`
|
||||
and:
|
||||
fail_compilation/pull12941.d(102): `pull12941.foo(return out scope int* p)`
|
||||
|
|
|
@ -3,11 +3,11 @@ REQUIRED_ARGS: -preview=dip1000
|
|||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(22): Error: scope parameter `p` may not be returned
|
||||
fail_compilation/retscope.d(32): Error: returning `b ? nested1(& i) : nested2(& j)` escapes a reference to local variable `j`
|
||||
fail_compilation/retscope.d(45): Error: scope variable `p` assigned to global variable `q`
|
||||
fail_compilation/retscope.d(47): Error: address of variable `i` assigned to `q` with longer lifetime
|
||||
fail_compilation/retscope.d(48): Error: scope variable `a` assigned to global variable `b`
|
||||
fail_compilation/retscope.d(49): Error: address of expression temporary returned by `(*fp2)()` assigned to `q` with longer lifetime
|
||||
fail_compilation/retscope.d(32): Error: escaping a reference to local variable `j` by returning `b ? nested1(& i) : nested2(& j)` is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(45): Error: assigning scope variable `p` to global variable `q` is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(47): Error: assigning address of variable `i` to `q` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(48): Error: assigning scope variable `a` to global variable `b` is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(49): Error: assigning address of expression temporary returned by `(*fp2)()` to `q` with longer lifetime is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -85,7 +85,6 @@ struct HTTP
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(96): Error: reference to local variable `sa` assigned to non-scope parameter `a` calling `bar8`
|
||||
---
|
||||
*/
|
||||
// https://issues.dlang.org/show_bug.cgi?id=8838
|
||||
|
@ -107,7 +106,8 @@ int[] bar8(int[] a) @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(123): Error: returning `foo9(cast(char[])tmp)` escapes a reference to local variable `tmp`
|
||||
fail_compilation/retscope.d(95): Error: assigning reference to local variable `sa` to non-scope parameter `a` calling `bar8` is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(123): Error: escaping a reference to local variable `tmp` by returning `foo9(cast(char[])tmp)` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -164,7 +164,6 @@ class C11
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(177): Error: address of variable `i` assigned to `p` with longer lifetime
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -181,7 +180,6 @@ void foo11() @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(197): Error: scope variable `e` may not be returned
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -201,7 +199,9 @@ void* escapeDg1(scope void* d) @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(212): Error: scope variable `p` assigned to non-scope `e.e`
|
||||
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
|
||||
---
|
||||
*/
|
||||
struct Escaper3 { void* e; }
|
||||
|
@ -254,7 +254,6 @@ void escape4() @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(266): Error: cannot take address of `scope` variable `p` since `scope` applies to first indirection only
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -271,7 +270,8 @@ void escape5() @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(286): Error: returning `foo6(& b)` escapes a reference to local variable `b`
|
||||
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,7 +323,6 @@ ref int[3] asStatic2( scope int[] p) @safe { return p[0 .. 3]; }
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(335): Error: reference to local variable `i` assigned to non-scope `f`
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -347,7 +346,8 @@ int* bar10( scope int** ptr ) @safe
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(358): Error: cannot take address of `scope` variable `aa` since `scope` applies to first indirection only
|
||||
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,7 +399,6 @@ struct Foo12
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1103): Error: scope variable `f` may not be returned
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -419,7 +418,6 @@ class Foo13
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1205): Error: scope variable `f14` calling non-scope member function `Foo14.foo()`
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -442,7 +440,6 @@ struct Foo14
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1311): Error: scope variable `u2` assigned to `ek` with longer lifetime
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -470,7 +467,6 @@ fail_compilation/retscope.d(1311): Error: scope variable `u2` assigned to `ek` w
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assigned to non-scope anonymous parameter calling `myprintf`
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -488,7 +484,11 @@ fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assi
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1509): Error: reference to stack allocated value returned by `(*fp15)()` assigned to non-scope anonymous parameter
|
||||
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
|
||||
---
|
||||
*/
|
||||
|
||||
|
@ -678,8 +678,8 @@ int test21()
|
|||
/*********************************************
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/retscope.d(1907): Error: scope variable `x` assigned to `ref` variable `this` with longer lifetime
|
||||
fail_compilation/retscope.d(1913): Error: scope variable `x` may not be returned
|
||||
fail_compilation/retscope.d(1907): Error: assigning scope variable `x` to `ref` variable `this` with longer lifetime is not allowed in a `@safe` function
|
||||
fail_compilation/retscope.d(1913): Error: returning scope variable `x` is not allowed in a `@safe` function
|
||||
---
|
||||
*/
|
||||
#line 1900
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue