Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge stable into master #13279

Merged
merged 20 commits into from Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
99a01e6
ImportC: add support for __builtin_va_start and __builtin_va_end
WalterBright Oct 20, 2021
9b6455a
Use correct phobos when running C++ tests in GitHub action (#13222)
tim-dlang Oct 24, 2021
2d495c7
Fix Issue 20133 - [REG2.084.0] Bogus slice assignment in recursive CT…
BorisCarvajal Oct 27, 2021
8a6fcaa
Fix Issue 21930 - ICE (illegal instruction) with bad code
BorisCarvajal Oct 28, 2021
3bfb90e
Fix Issue 22462 - OpenBSD: bash lives in /usr/local
ibara Nov 1, 2021
5a52c1a
Fix Issue 22463 - OpenBSD: Allow DMD to work on 32-bit OpenBSD
ibara Nov 1, 2021
54fa6ee
OpenBSD has had fmodl since 5.0 (2011)
ibara Nov 1, 2021
b142905
Fix 22472 - Correct error message for invalid `void` return
MoonlightSentinel Nov 3, 2021
85f1d0e
Fix Issue 22478 - OpenBSD: Add to fail_compilation/invalid_lib.d
ibara Nov 4, 2021
f605704
Add openbsd32 and openbsd64 to the ignore list
ibara Nov 4, 2021
47657b8
Fix Issue 22474 - OpenBSD: Add support to test/runnable/dhry.d
ibara Nov 4, 2021
2fe76b0
Add openbsd to ignore list
ibara Nov 4, 2021
93a9f7b
Add openbsd to ignore list
ibara Nov 4, 2021
0a9502c
Fix Issue 21380 - A case of compiler crash when using auto ref
BorisCarvajal Nov 4, 2021
c9733e8
Fix Issue 20998 - error in static struct initialization causes wrong …
BorisCarvajal Nov 5, 2021
904fde4
Fix Issue 21039 - `alias this` returns 'null' for ref types when put …
BorisCarvajal Nov 8, 2021
d893291
Fix Issue 21093 - [ICE] AssertError@dmd/optimize.d(691): Assertion fa…
BorisCarvajal Nov 8, 2021
65dd51c
cirrus: Switch to big-sur image, use catalina for bootstrap only
ibuclaw Oct 6, 2021
9653009
Merge remote-tracking branch 'upstream/stable' into merge_stable
PetarKirov Nov 8, 2021
004a2a2
fix(fail_compilation/test21930): Adjust test output in accordance wit…
PetarKirov Nov 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions .cirrus.yml
Expand Up @@ -83,9 +83,9 @@ task:

# Mac
task:
name: macOS 10.15 x64, $TASK_NAME_SUFFIX
name: macOS 11.x x64, $TASK_NAME_SUFFIX
osx_instance:
image: catalina-xcode
image: big-sur-xcode
timeout_in: 60m
environment:
OS_NAME: darwin
Expand All @@ -97,10 +97,22 @@ task:
- TASK_NAME_SUFFIX: DMD (latest)
- TASK_NAME_SUFFIX: DMD (coverage)
<< : *COVERAGE_ENVIRONMENT_TEMPLATE
- TASK_NAME_SUFFIX: DMD (bootstrap)
# de-facto bootstrap version on OSX
# See: https://forum.dlang.org/post/qfsgt2$1goc$1@digitalmars.com
HOST_DMD: dmd-2.088.0
<< : *COMMON_STEPS_TEMPLATE

task:
name: macOS 10.15 x64, DMD (bootstrap)
osx_instance:
image: big-sur-xcode
timeout_in: 60m
environment:
OS_NAME: darwin
# override Cirrus default OS (`darwin`)
OS: osx
# 12 CPU cores and 24 GB of memory are available
N: 12
# de-facto bootstrap version on OSX
# See: https://forum.dlang.org/post/qfsgt2$1goc$1@digitalmars.com
HOST_DMD: dmd-2.088.0
<< : *COMMON_STEPS_TEMPLATE

# FreeBSD
Expand Down
2 changes: 1 addition & 1 deletion cirrusci.sh
Expand Up @@ -30,7 +30,7 @@ if [ "$OS_NAME" == "linux" ]; then
elif [ "$OS_NAME" == "darwin" ]; then
# required for dlang install.sh
brew update-reset
brew install gnupg
brew install gnupg libarchive xz
elif [ "$OS_NAME" == "freebsd" ]; then
packages="git gmake"
if [ "$HOST_DMD" == "dmd-2.079.0" ] ; then
Expand Down
16 changes: 8 additions & 8 deletions src/dmd/backend/cod1.d
Expand Up @@ -2157,13 +2157,13 @@ void getClibInfo(uint clib, Symbol** ps, ClibInfo** pinfo)

case CLIB.ldiv:
cinfo.retregs16 = mDX|mAX;
if (config.exe & (EX_LINUX | EX_FREEBSD))
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
{
s = symboly("__divdi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
cinfo.retregs32 = mDX|mAX;
}
else if (config.exe & (EX_OPENBSD | EX_SOLARIS))
else if (config.exe & EX_SOLARIS)
{
s = symboly("__LDIV2__", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand All @@ -2185,13 +2185,13 @@ void getClibInfo(uint clib, Symbol** ps, ClibInfo** pinfo)

case CLIB.lmod:
cinfo.retregs16 = mCX|mBX;
if (config.exe & (EX_LINUX | EX_FREEBSD))
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
{
s = symboly("__moddi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
cinfo.retregs32 = mDX|mAX;
}
else if (config.exe & (EX_OPENBSD | EX_SOLARIS))
else if (config.exe & EX_SOLARIS)
{
s = symboly("__LDIV2__", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand All @@ -2213,13 +2213,13 @@ void getClibInfo(uint clib, Symbol** ps, ClibInfo** pinfo)

case CLIB.uldiv:
cinfo.retregs16 = mDX|mAX;
if (config.exe & (EX_LINUX | EX_FREEBSD))
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
{
s = symboly("__udivdi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
cinfo.retregs32 = mDX|mAX;
}
else if (config.exe & (EX_OPENBSD | EX_SOLARIS))
else if (config.exe & EX_SOLARIS)
{
s = symboly("__ULDIV2__", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand All @@ -2241,13 +2241,13 @@ void getClibInfo(uint clib, Symbol** ps, ClibInfo** pinfo)

case CLIB.ulmod:
cinfo.retregs16 = mCX|mBX;
if (config.exe & (EX_LINUX | EX_FREEBSD))
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
{
s = symboly("__umoddi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
cinfo.retregs32 = mDX|mAX;
}
else if (config.exe & (EX_OPENBSD | EX_SOLARIS))
else if (config.exe & EX_SOLARIS)
{
s = symboly("__LDIV2__", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand Down
18 changes: 1 addition & 17 deletions src/dmd/backend/fp.d
Expand Up @@ -42,22 +42,6 @@ version (SPP) {} else

longdouble _modulo(longdouble x, longdouble y)
{
version(FreeBSD)
enum HOST_IS_BSD = true;
else version(DragonFlyBSD)
enum HOST_IS_BSD = true;
else version(OpenBSD)
enum HOST_IS_BSD = true;
else
enum HOST_IS_BSD = false;

static if (HOST_IS_BSD)
{
return fmod(x, y);
}
else
{
return fmodl(x, y);
}
return fmodl(x, y);
}
}
35 changes: 35 additions & 0 deletions src/dmd/cparse.d
Expand Up @@ -72,6 +72,7 @@ final class CParser(AST) : Parser!AST
{
//printf("cparseTranslationUnit()\n");
symbols = new AST.Dsymbols();
addBuiltinDeclarations();
while (1)
{
if (token.value == TOK.endOfFile)
Expand Down Expand Up @@ -4361,5 +4362,39 @@ final class CParser(AST) : Parser!AST
return s;
}

/***********************************
* Add global target-dependent builtin declarations.
*/
private void addBuiltinDeclarations()
{
void genBuiltinFunc(Identifier id, AST.VarArg va)
{
auto tva_list = new AST.TypeIdentifier(Loc.initial, Id.builtin_va_list);
auto parameters = new AST.Parameters();
parameters.push(new AST.Parameter(STC.parameter | STC.ref_, tva_list, null, null, null));
auto pl = AST.ParameterList(parameters, va, 0);
auto tf = new AST.TypeFunction(pl, AST.Type.tvoid, LINK.c, 0);
auto s = new AST.FuncDeclaration(Loc.initial, Loc.initial, id, AST.STC.static_, tf, false);
symbols.push(s);
}

/* void __builtin_va_start(__builtin_va_list, ...);
* The second argument is supposed to be of any type, so fake it with the ...
*/
genBuiltinFunc(Id.builtin_va_start, AST.VarArg.variadic);

/* void __builtin_va_end(__builtin_va_list);
*/
genBuiltinFunc(Id.builtin_va_end, AST.VarArg.none);

/* struct __va_list_tag
* {
* uint, uint, void*, void*
* }
*/
auto s = new AST.StructDeclaration(Loc.initial, Id.va_list_tag, false);
symbols.push(s);
}

//}
}
27 changes: 25 additions & 2 deletions src/dmd/dcast.d
Expand Up @@ -3182,6 +3182,14 @@ Lagain:
Lcc:
while (1)
{
MATCH i1woat = MATCH.exact;
MATCH i2woat = MATCH.exact;

if (auto t2c = t2.isTypeClass())
i1woat = t2c.implicitConvToWithoutAliasThis(t1);
if (auto t1c = t1.isTypeClass())
i2woat = t1c.implicitConvToWithoutAliasThis(t2);

MATCH i1 = e2.implicitConvTo(t1);
MATCH i2 = e1.implicitConvTo(t2);

Expand All @@ -3194,11 +3202,26 @@ Lagain:
i2 = MATCH.nomatch;
}

if (i2)
// Match but without 'alias this' on classes
if (i2 && i2woat)
return coerce(t2);
if (i1)
if (i1 && i1woat)
return coerce(t1);

// Here use implicitCastTo() instead of castTo() to try 'alias this' on classes
Type coerceImplicit(Type towards)
{
e1 = e1.implicitCastTo(sc, towards);
e2 = e2.implicitCastTo(sc, towards);
return Lret(towards);
}

// Implicit conversion with 'alias this'
if (i2)
return coerceImplicit(t2);
if (i1)
return coerceImplicit(t1);

if (t1.ty == Tclass && t2.ty == Tclass)
{
TypeClass tc1 = t1.isTypeClass();
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/dinterpret.d
Expand Up @@ -76,6 +76,7 @@ public Expression ctfeInterpret(Expression e)
case TOK.template_: // non-eponymous template/instance
case TOK.scope_: // ditto
case TOK.dotTemplateDeclaration: // ditto, e.e1 doesn't matter here
case TOK.dotTemplateInstance: // ditto
case TOK.dot: // ditto
if (e.type.ty == Terror)
return ErrorExp.get();
Expand Down Expand Up @@ -2196,7 +2197,7 @@ public:
Expression ev = getValue(v);
if (ev.op == TOK.variable ||
ev.op == TOK.index ||
ev.op == TOK.slice ||
(ev.op == TOK.slice && ev.type.toBasetype().ty == Tsarray) ||
ev.op == TOK.dotVariable)
{
result = interpret(pue, ev, istate, goal);
Expand Down
78 changes: 66 additions & 12 deletions src/dmd/e2ir.d
Expand Up @@ -5440,18 +5440,8 @@ elem *callfunc(const ref Loc loc,
}
else if (op == OPind)
e = el_una(op,mTYvolatile | tyret,ep);
else if (op == OPva_start && target.is64bit)
{
// (OPparam &va &arg)
// call as (OPva_start &va)
ep.Eoper = cast(ubyte)op;
ep.Ety = tyret;
e = ep;

elem *earg = e.EV.E2;
e.EV.E2 = null;
e = el_combine(earg, e);
}
else if (op == OPva_start)
e = constructVa_start(ep);
else if (op == OPtoPrec)
{
static int X(int fty, int tty) { return fty * TMAX + tty; }
Expand Down Expand Up @@ -5494,6 +5484,11 @@ elem *callfunc(const ref Loc loc,
else
e = el_una(op,tyret,ep);
}
else if (irs.Cfile && (e = builtinC(fd, ep)) !is null)
{
// handled magic C builtins
el_free(ec);
}
else
{
/* Do not do "no side effect" calls if a hidden parameter is passed,
Expand Down Expand Up @@ -6723,3 +6718,62 @@ elem* setEthis2(const ref Loc loc, IRState* irs, FuncDeclaration fd, elem* ethis

return ethis2;
}

/*********************************************
* Handle magic C __builtin functions.
* Params:
* fd = magic function declaration
* e = function parameters
* Returns:
* if not null, then the rewrite of the magic function call
*/
private
elem* builtinC(FuncDeclaration fd, elem* e)
{
if (!fd)
return null;
const id = fd.ident;
if (id == Id.builtin_va_start)
{
return constructVa_start(e);
}
else if (id == Id.builtin_va_end)
{
assert(e.Eoper != OPparam); // one parameter only
return el_una(OPbool, TYbool, e); // evaluate ep for side effects only
}
return null;
}

/*******************************
* Construct OPva_start node
* Params:
* e = function parameters
* Returns:
* OPva_start node
*/
private
elem* constructVa_start(elem* e)
{
assert(e.Eoper == OPparam);

e.Eoper = OPva_start;
e.Ety = TYvoid;
if (target.is64bit)
{
// (OPparam &va &arg)
// call as (OPva_start &va)
auto earg = e.EV.E2;
e.EV.E2 = null;
return el_combine(earg, e);
}
else // 32 bit
{
// (OPparam &arg &va) note arguments are swapped from 64 bit path
// call as (OPva_start &va)
auto earg = e.EV.E1;
e.EV.E1 = e.EV.E2;
e.EV.E2 = null;
return el_combine(earg, e);
}
}
25 changes: 25 additions & 0 deletions src/dmd/expression.d
Expand Up @@ -4885,6 +4885,31 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp
return ti.updateTempDecl(sc, s);
}

override bool checkType()
{
// Same logic as ScopeExp.checkType()
if (ti.tempdecl &&
ti.semantictiargsdone &&
ti.semanticRun == PASS.init)
{
error("partial %s `%s` has no type", ti.kind(), toChars());
return true;
}
return false;
}

override bool checkValue()
{
if (ti.tempdecl &&
ti.semantictiargsdone &&
ti.semanticRun == PASS.init)

error("partial %s `%s` has no value", ti.kind(), toChars());
else
error("%s `%s` has no value", ti.kind(), ti.toChars());
return true;
}

override void accept(Visitor v)
{
v.visit(this);
Expand Down
2 changes: 2 additions & 0 deletions src/dmd/expression.h
Expand Up @@ -783,6 +783,8 @@ class DotTemplateInstanceExp : public UnaExp

DotTemplateInstanceExp *syntaxCopy();
bool findTempDecl(Scope *sc);
bool checkType();
bool checkValue();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down