aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/expr.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2024-01-28 12:23:14 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2024-02-03 12:03:37 +0100
commit51c4eb28c192ecff4463c973a0ff089e04a80b89 (patch)
tree160ac2ef2c9d732681e96577ef0009027092aea6 /gcc/d/expr.cc
parent854b8555bd49ad97c336b8df7098e725dc196e4f (diff)
downloadgcc-51c4eb28c192ecff4463c973a0ff089e04a80b89.zip
gcc-51c4eb28c192ecff4463c973a0ff089e04a80b89.tar.gz
gcc-51c4eb28c192ecff4463c973a0ff089e04a80b89.tar.bz2
d: Merge dmd. druntime e770945277, phobos 6d6e0b9b9
D front-end changes: - Import latest fixes from dmd v2.107.0-beta.1. - Hex strings can now be cast to integer arrays. - Add support for Interpolated Expression Sequences. D runtime changes: - Import latest fixes from druntime v2.107.0-beta.1. - New core.interpolation module to provide run-time support for D interpolated expression sequence literals. Phobos changes: - Import latest fixes from phobos v2.107.0-beta.1. - `std.range.primitives.isBidirectionalRange', and `std.range.primitives.isRandomAccessRange' now take an optional element type. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd e770945277. * Make-lang.in (D_FRONTEND_OBJS): Add d/basicmangle.o, d/enumsem.o, d/funcsem.o, d/templatesem.o. * d-builtins.cc (build_frontend_type): Update for new front-end interface. * d-codegen.cc (declaration_type): Likewise. (parameter_type): Likewise. * d-incpath.cc (add_globalpaths): Likewise. (add_filepaths): Likewise. (add_import_paths): Likewise. * d-lang.cc (d_init_options): Likewise. (d_handle_option): Likewise. (d_parse_file): Likewise. * decl.cc (DeclVisitor::finish_vtable): Likewise. (DeclVisitor::visit (FuncDeclaration *)): Likewise. (get_symbol_decl): Likewise. * expr.cc (ExprVisitor::visit (StringExp *)): Likewise. Implement support for 8-byte hexadecimal strings. * typeinfo.cc (create_tinfo_types): Update internal TypeInfo representation. (TypeInfoVisitor::visit (TypeInfoConstDeclaration *)): Update for new front-end interface. (TypeInfoVisitor::visit (TypeInfoInvariantDeclaration *)): Likewise. (TypeInfoVisitor::visit (TypeInfoSharedDeclaration *)): Likewise. (TypeInfoVisitor::visit (TypeInfoWildDeclaration *)): Likewise. (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Move data for TypeInfo_Class.nameSig to the end of the object. (create_typeinfo): Update for new front-end interface. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime e770945277. * libdruntime/Makefile.am (DRUNTIME_SOURCES): Add core/interpolation.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 6d6e0b9b9.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r--gcc/d/expr.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 6f596c5..0a85a55 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2495,17 +2495,18 @@ public:
for (size_t i = 0; i < e->len; i++)
{
- tree value = build_integer_cst (e->getCodeUnit (i), etype);
+ tree value = build_integer_cst (e->getIndex (i), etype);
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value);
}
tree ctor = build_constructor (type, elms);
TREE_CONSTANT (ctor) = 1;
this->result_ = ctor;
+ return;
}
else
{
- /* Copy the string contents to a null terminated string. */
+ /* Copy the string contents to a null terminated STRING_CST. */
dinteger_t length = (e->len * e->sz);
char *string = XALLOCAVEC (char, length + e->sz);
memset (string, 0, length + e->sz);
@@ -2514,7 +2515,18 @@ public:
/* String value and type includes the null terminator. */
tree value = build_string (length + e->sz, string);
- TREE_TYPE (value) = make_array_type (tb->nextOf (), length + 1);
+ if (e->sz <= 4)
+ TREE_TYPE (value) = make_array_type (tb->nextOf (), length + 1);
+ else
+ {
+ /* Hexadecimal literal strings with an 8-byte character type are
+ just an alternative way to store an array of `ulong'.
+ Treat it as if it were a `uint[]' array instead. */
+ dinteger_t resize = e->sz / 4;
+ TREE_TYPE (value) = make_array_type (Type::tuns32,
+ (length * resize) + resize);
+ }
+
value = build_address (value);
if (tb->ty == TY::Tarray)