diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-04-02 13:29:22 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-04-04 01:26:20 +0200 |
commit | 5a0aa603b2452dca48ad86d97d4b918187d259fc (patch) | |
tree | 67439099b8129248a45826b5791912b20ff3c3fb /gcc/d/dmd/hdrgen.c | |
parent | ba0f6902666430e5d065a92b3d5292cba91813d3 (diff) |
d: Merge upstream dmd 3b808e838, druntime 483bc129, phobos f89dc217a
D front-end changes:
- Explicit package visibility attribute is now always applied to
introducing scopes.
- Added `__traits(totype, string)' to convert mangled type string to an
existing type.
- Printf-like and scanf-like functions are now detected by prefixing
them with `pragma(printf)' for printf-like functions or
`pragma(scanf)' for scanf-like functions.
- Added `__c_wchar_t', `__c_complex_float', `__c_complex_double', and
`__c_complex_real' types for interfacing with C and C++.
- Template alias parameters can now be instantiated with basic types,
such as `int` or `void function()`.
- Mixins can now be used as types in the form `mixin(string) var'.
- Mixin expressions can take an argument list, same as `pragma(msg)'.
- Implement DIP1034, add `typeof(*null)' types to represent `noreturn'.
- `pragma(msg)' can print expressions of type `void'.
- It is now an error to use private variables selectively imported from
other modules. Due to a bug, some imported private members were
visible from other modules, violating the specification.
- Added new syntax to declare an alias to a function type using the
`alias' syntax based on the assignment operator.
- Function literals can now return a value by reference.
Phobos changes:
- Synchronize C bindings with the latest port fixes in upstream druntime.
- Added alias for a `noreturn' type in object.d
- Make use of the new `pragma(printf)' and `pragma(scanf)' pragmas, fix
all code that got flagged as being incorrect.
- Fixed code that relied on bugs in the D import package system.
Reviewed-on: https://github.com/dlang/dmd/pull/12339
https://github.com/dlang/druntime/pull/3422
https://github.com/dlang/phobos/pull/7932
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 3b808e838.
* Make-lang.in (D_FRONTEND_OBJS): Add d/chkformat.o.
* d-codegen.cc (build_struct_literal): Handle special enums.
* d-convert.cc (convert_expr): Handle noreturn type.
(convert_for_condition): Likewise.
* d-target.cc (Target::_init): Set type for wchar_t.
(TargetCPP::derivedClassOffset): New method.
(Target::libraryObjectMonitors): New method.
* decl.cc (get_symbol_decl): Set TREE_THIS_VOLATILE for functions of
type noreturn.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Handle returning
noreturn types.
* types.cc (TypeVisitor::visit (TypeNoreturn *)): New method.
(TypeVisitor::visit (TypeEnum *)): Handle special enums.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 483bc129.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_DARWIN): Add
core/sys/darwin/fcntl.d.
(DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/unistd.d.
(DRUNTIME_DSOURCES_WINDOWS): Add core/sys/windows/stdc/malloc.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos f89dc217a.
* src/Makefile.am (PHOBOS_DSOURCES): Add std/regex/internal/tests2.d.
* src/Makefile.in: Regenerate.
* testsuite/libphobos.exceptions/chain.d: Fix format arguments.
* testsuite/libphobos.exceptions/line_trace.d: Likewise.
Diffstat (limited to 'gcc/d/dmd/hdrgen.c')
-rw-r--r-- | gcc/d/dmd/hdrgen.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c index a11c9c353d9..9eba88f1118 100644 --- a/gcc/d/dmd/hdrgen.c +++ b/gcc/d/dmd/hdrgen.c @@ -122,7 +122,7 @@ public: void visit(CompileStatement *s) { buf->writestring("mixin("); - s->exp->accept(this); + argsToBuffer(s->exps); buf->writestring(");"); if (!hgs->forStmtInit) buf->writenl(); @@ -1104,6 +1104,18 @@ public: buf->writestring("typeof(null)"); } + void visit(TypeMixin *t) + { + buf->writestring("mixin("); + argsToBuffer(t->exps); + buf->writeByte(')'); + } + + void visit(TypeNoreturn *) + { + buf->writestring("noreturn"); + } + //////////////////////////////////////////////////////////////////////////// void visit(Dsymbol *s) @@ -1418,7 +1430,7 @@ public: void visit(CompileDeclaration *d) { buf->writestring("mixin("); - d->exp->accept(this); + argsToBuffer(d->exps); buf->writestring(");"); buf->writenl(); } @@ -2408,8 +2420,15 @@ public: buf->writeByte(')'); if (target.ptrsize == 8) goto L4; - else + else if (target.ptrsize == 4 || + target.ptrsize == 2) goto L3; + else + assert(0); + + case Tvoid: + buf->writestring("cast(void)0"); + break; default: /* This can happen if errors, such as @@ -2822,7 +2841,7 @@ public: void visit(CompileExp *e) { buf->writestring("mixin("); - expToBuffer(e->e1, PREC_assign); + argsToBuffer(e->exps); buf->writeByte(')'); } @@ -3528,6 +3547,13 @@ void arrayObjectsToBuffer(OutBuffer *buf, Objects *objects) } } +/************************************************************* + * Pretty print function parameters. + * Params: + * parameters = parameters to print, such as TypeFunction.parameters. + * varargs = kind of varargs, see TypeFunction.varargs. + * Returns: Null-terminated string representing parameters. + */ const char *parametersTypeToChars(ParameterList pl) { OutBuffer buf; @@ -3536,3 +3562,26 @@ const char *parametersTypeToChars(ParameterList pl) v.parametersToBuffer(pl.parameters, pl.varargs); return buf.extractChars(); } + +/************************************************************* + * Pretty print function parameter. + * Params: + * parameter = parameter to print. + * tf = TypeFunction which holds parameter. + * fullQual = whether to fully qualify types. + * Returns: Null-terminated string representing parameters. + */ +const char *parameterToChars(Parameter *parameter, TypeFunction *tf, bool fullQual) +{ + OutBuffer buf; + HdrGenState hgs; + hgs.fullQual = fullQual; + PrettyPrintVisitor v(&buf, &hgs); + + parameter->accept(&v); + if (tf->parameterList.varargs == 2 && parameter == tf->parameterList[tf->parameterList.parameters->length - 1]) + { + buf.writestring("..."); + } + return buf.extractChars(); +} |