aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/ChangeLog42
-rw-r--r--gcc/d/d-codegen.cc32
-rw-r--r--gcc/d/d-compiler.cc37
-rw-r--r--gcc/d/d-convert.cc4
-rw-r--r--gcc/d/d-lang.cc25
-rw-r--r--gcc/d/d-spec.cc50
-rw-r--r--gcc/d/d-tree.h1
-rw-r--r--gcc/d/decl.cc2
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/expressionsem.d30
-rw-r--r--gcc/d/dmd/globals.h1
-rw-r--r--gcc/d/dmd/lexer.d4
-rw-r--r--gcc/d/dmd/location.d23
-rw-r--r--gcc/d/dmd/typesem.d16
-rw-r--r--gcc/d/expr.cc22
-rw-r--r--gcc/d/gdc.texi6
-rw-r--r--gcc/d/lang.opt4
-rw-r--r--gcc/d/lang.opt.urls6
-rw-r--r--gcc/d/modules.cc13
-rw-r--r--gcc/d/typeinfo.cc8
-rw-r--r--gcc/d/types.cc15
21 files changed, 246 insertions, 97 deletions
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 1ea467e..ca31897 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,45 @@
+2025-04-11 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * dmd/MERGE: Merge upstream dmd 1b34fea478.
+
+2025-04-09 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ PR d/118309
+ * modules.cc: Include debug.h
+ (d_finish_compilation): Call debug_hooks->type_decl on all TYPE_DECLs.
+ * types.cc: Remove toplev.h include.
+ (finish_aggregate_type): Don't call rest_of_type_compilation or
+ rest_of_decl_compilation on type.
+ (TypeVisitor::visit (TypeEnum *)): Likewise.
+
+2025-04-09 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ PR d/117832
+ * d-tree.h (build_padded_constructor): New prototype.
+ * d-codegen.cc (build_padded_constructor): New function.
+ (d_array_value): Call it.
+ (build_memset_call): Likewise.
+ (build_struct_literal): Likewise.
+ (underlying_complex_expr): Likewise.
+ (build_array_from_val): Likewise.
+ (build_array_from_exprs): Likewise.
+ (d_build_call): Likewise.
+ (get_frame_for_symbol): Likewise.
+ * d-convert.cc (convert_for_rvalue): Likewise.
+ (convert_for_assignment): Likewise.
+ * decl.cc (class DeclVisitor): Likewise.
+ * expr.cc (class ExprVisitor): Likewise.
+ * modules.cc (layout_moduleinfo): Likewise.
+ * typeinfo.cc (class TypeInfoVisitor): Likewise.
+
+2025-04-08 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * dmd/MERGE: Merge upstream dmd 51816cd01d.
+
+2025-04-06 Sandra Loosemore <sloosemore@baylibre.com>
+
+ * lang.opt.urls: Regenerate.
+
2025-04-02 Iain Buclaw <ibuclaw@gdcproject.org>
* dmd/MERGE: Merge upstream dmd ed17b3e95d.
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index ad71486..1a7575a 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -317,7 +317,7 @@ d_array_value (tree type, tree len, tree data)
CONSTRUCTOR_APPEND_ELT (ce, len_field, len);
CONSTRUCTOR_APPEND_ELT (ce, ptr_field, data);
- return build_constructor (type, ce);
+ return build_padded_constructor (type, ce);
}
/* Returns value representing the array length of expression EXP.
@@ -898,7 +898,10 @@ build_memset_call (tree ptr, tree num)
{
tree cst = build_zero_cst (valtype);
if (TREE_CODE (cst) == CONSTRUCTOR)
- return build_memcpy_call (ptr, build_address (cst), num);
+ {
+ CONSTRUCTOR_ZERO_PADDING_BITS (cst) = 1;
+ return build_memcpy_call (ptr, build_address (cst), num);
+ }
return modify_expr (build_deref (ptr), cst);
}
@@ -1205,7 +1208,7 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
{
/* If the initializer was empty, use default zero initialization. */
if (vec_safe_is_empty (init))
- return build_constructor (type, NULL);
+ return build_padded_constructor (type, NULL);
/* Struct literals can be seen for special enums representing `_Complex',
make sure to reinterpret the literal as the correct type. */
@@ -1306,7 +1309,7 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
/* Ensure that we have consumed all values. */
gcc_assert (vec_safe_is_empty (init) || ANON_AGGR_TYPE_P (type));
- tree ctor = build_constructor (type, ve);
+ tree ctor = build_padded_constructor (type, ve);
if (constant_p)
TREE_CONSTANT (ctor) = 1;
@@ -1314,6 +1317,17 @@ build_struct_literal (tree type, vec <constructor_elt, va_gc> *init)
return ctor;
}
+/* Return a new zero padded CONSTRUCTOR node whose type is TYPE and values are
+ in the vec pointed to by VALS. */
+
+tree
+build_padded_constructor (tree type, vec<constructor_elt, va_gc> *vals)
+{
+ tree ctor = build_constructor (type, vals);
+ CONSTRUCTOR_ZERO_PADDING_BITS (ctor) = 1;
+ return ctor;
+}
+
/* Given the TYPE of an anonymous field inside T, return the
FIELD_DECL for the field. If not found return NULL_TREE.
Because anonymous types can nest, we must also search all
@@ -1647,7 +1661,7 @@ underlying_complex_expr (tree type, tree expr)
real_part (expr));
CONSTRUCTOR_APPEND_ELT (ve, TREE_CHAIN (TYPE_FIELDS (type)),
imaginary_part (expr));
- return build_constructor (type, ve);
+ return build_padded_constructor (type, ve);
}
/* Replace type in the reinterpret cast with a cast to the record type. */
@@ -1852,7 +1866,7 @@ build_array_from_val (Type *type, tree val)
for (size_t i = 0; i < dims; i++)
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), val);
- return build_constructor (build_ctype (type), elms);
+ return build_padded_constructor (build_ctype (type), elms);
}
/* Build a static array of type TYPE from an array of EXPS.
@@ -1886,7 +1900,7 @@ build_array_from_exprs (Type *type, Expressions *exps, bool const_p)
init = build_memset_call (var);
/* Initialize the temporary. */
- tree assign = modify_expr (var, build_constructor (satype, elms));
+ tree assign = modify_expr (var, build_padded_constructor (satype, elms));
return compound_expr (compound_expr (init, assign), var);
}
@@ -2301,7 +2315,7 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
if (empty_aggregate_p (TREE_TYPE (targ)) && !TREE_ADDRESSABLE (targ)
&& TREE_CODE (targ) != CONSTRUCTOR)
{
- tree t = build_constructor (TREE_TYPE (targ), NULL);
+ tree t = build_padded_constructor (TREE_TYPE (targ), NULL);
targ = build2 (COMPOUND_EXPR, TREE_TYPE (t), targ, t);
}
@@ -2613,7 +2627,7 @@ get_frame_for_symbol (Dsymbol *sym)
framefields = DECL_CHAIN (framefields);
}
- frame_ref = build_address (build_constructor (type, ve));
+ frame_ref = build_address (build_padded_constructor (type, ve));
}
}
diff --git a/gcc/d/d-compiler.cc b/gcc/d/d-compiler.cc
index 160539d..e18f5d3 100644
--- a/gcc/d/d-compiler.cc
+++ b/gcc/d/d-compiler.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "dmd/compiler.h"
+#include "dmd/errors.h"
#include "dmd/expression.h"
#include "dmd/identifier.h"
#include "dmd/module.h"
@@ -164,7 +165,39 @@ Compiler::onParseModule (Module *m)
driver intends on compiling the import. */
bool
-Compiler::onImport (Module *)
+Compiler::onImport (Module *m)
{
- return false;
+ if (!includeImports)
+ return false;
+
+ if (m->filetype != FileType::d && m->filetype != FileType::c)
+ return false;
+
+ /* All imports modules are included except those in the runtime library. */
+ ModuleDeclaration *md = m->md;
+ if (md && md->id)
+ {
+ if (md->packages.length >= 1)
+ {
+ if (!strcmp (md->packages.ptr[0]->toChars (), "core")
+ || !strcmp (md->packages.ptr[0]->toChars (), "std")
+ || !strcmp (md->packages.ptr[0]->toChars (), "gcc")
+ || !strcmp (md->packages.ptr[0]->toChars (), "etc"))
+ return false;
+ }
+ else if (!strcmp (md->id->toChars (), "object"))
+ return false;
+ }
+ else if (m->ident)
+ {
+ if (!strcmp (m->ident->toChars (), "object"))
+ return false;
+ }
+
+ /* This import will be compiled. */
+ if (global.params.v.verbose)
+ message ("compileimport (%s)", m->srcfile.toChars ());
+
+ compiledImports.push (m);
+ return true;
}
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 4b19584..c5b0d65 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -688,7 +688,7 @@ convert_for_rvalue (tree expr, Type *etype, Type *totype)
CONSTRUCTOR_APPEND_ELT (elms, index, value);
}
- return build_constructor (build_ctype (totype), elms);
+ return build_padded_constructor (build_ctype (totype), elms);
}
}
@@ -788,7 +788,7 @@ convert_for_assignment (Expression *expr, Type *totype, bool literalp)
TypeSArray *sa_type = tbtype->isTypeSArray ();
uinteger_t count = sa_type->dim->toUInteger ();
- tree ctor = build_constructor (build_ctype (totype), NULL);
+ tree ctor = build_padded_constructor (build_ctype (totype), NULL);
if (count)
{
vec <constructor_elt, va_gc> *ce = NULL;
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index b3786be..ec2ea59 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -523,6 +523,10 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
global.params.ignoreUnsupportedPragmas = value;
break;
+ case OPT_finclude_imports:
+ includeImports = true;
+ break;
+
case OPT_finvariants:
global.params.useInvariants = value ? CHECKENABLEon : CHECKENABLEoff;
break;
@@ -1085,9 +1089,9 @@ d_parse_file (void)
/* Buffer for contents of .ddoc files. */
OutBuffer ddocbuf;
- /* In this mode, the first file name is supposed to be a duplicate
- of one of the input files. */
- if (d_option.fonly && strcmp (d_option.fonly, main_input_filename) != 0)
+ /* In this mode, the main input file is supposed to be the same as the one
+ given by -fonly=. */
+ if (d_option.fonly && !endswith (main_input_filename, d_option.fonly))
error ("%<-fonly=%> argument is different from first input file name");
for (size_t i = 0; i < num_in_fnames; i++)
@@ -1309,6 +1313,21 @@ d_parse_file (void)
dmd::semantic3 (m, NULL);
}
+ if (includeImports)
+ {
+ for (size_t i = 0; i < compiledImports.length; i++)
+ {
+ Module *m = compiledImports[i];
+ gcc_assert (m->isRoot ());
+
+ if (global.params.v.verbose)
+ message ("semantic3 %s", m->toChars ());
+
+ dmd::semantic3 (m, NULL);
+ modules.push (m);
+ }
+ }
+
Module::runDeferredSemantic3 ();
/* Check again, incase semantic3 pass loaded any more modules. */
diff --git a/gcc/d/d-spec.cc b/gcc/d/d-spec.cc
index 7f4a779..c788048 100644
--- a/gcc/d/d-spec.cc
+++ b/gcc/d/d-spec.cc
@@ -104,8 +104,8 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
/* The total number of arguments with the new stuff. */
unsigned int num_args = 1;
- /* "-fonly" if it appears on the command line. */
- const char *only_source_option = 0;
+ /* "-fonly=" if it appears on the command line. */
+ const char *only_source_arg = 0;
/* Whether the -o option was used. */
bool saw_opt_o = false;
@@ -280,13 +280,13 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
case OPT_fonly_:
args[i] |= SKIPOPT;
- only_source_option = decoded_options[i].orig_option_with_args_text;
+ only_source_arg = arg;
if (arg != NULL)
{
- const char *suffix = strrchr (only_source_option, '.');
+ const char *suffix = strrchr (only_source_arg, '.');
if (suffix == NULL || strcmp (suffix, ".d") != 0)
- only_source_option = concat (only_source_option, ".d", NULL);
+ only_source_arg = concat (only_source_arg, ".d", NULL);
}
break;
@@ -335,48 +335,52 @@ lang_specific_driver (cl_decoded_option **in_decoded_options,
+ (phobos_library != PHOBOS_NOLINK) * 4 + 2;
new_decoded_options = XNEWVEC (cl_decoded_option, num_args);
- i = 0;
j = 0;
/* Copy the 0th argument, i.e., the name of the program itself. */
- new_decoded_options[j++] = decoded_options[i++];
+ new_decoded_options[j++] = decoded_options[0];
/* NOTE: We start at 1 now, not 0. */
- while (i < argc)
+ for (i = 1; i < argc; i++)
{
if (args[i] & SKIPOPT)
- {
- ++i;
- continue;
- }
-
- new_decoded_options[j] = decoded_options[i];
+ continue;
if (!saw_libcxx && (args[i] & WITHLIBCXX))
{
- --j;
saw_libcxx = &decoded_options[i];
+ continue;
}
- if (args[i] & DSOURCE)
+ if (only_source_arg && (args[i] & DSOURCE))
{
- if (only_source_option)
- --j;
+ if (!endswith (decoded_options[i].arg, only_source_arg))
+ continue;
}
- i++;
+ new_decoded_options[j] = decoded_options[i];
j++;
}
- if (only_source_option)
+ if (only_source_arg)
{
- const char *only_source_arg = only_source_option + 7;
+ /* Generate -fonly= option, then copy D input sources that were initially
+ skipped in first pass over all decoded_options. */
generate_option (OPT_fonly_, only_source_arg, 1, CL_DRIVER,
&new_decoded_options[j]);
j++;
- generate_option_input_file (only_source_arg,
- &new_decoded_options[j++]);
+ for (i = 1; i < argc; i++)
+ {
+ if (!(args[i] & DSOURCE))
+ continue;
+
+ if (endswith (decoded_options[i].arg, only_source_arg))
+ continue;
+
+ new_decoded_options[j] = decoded_options[i];
+ j++;
+ }
}
/* If no reason to link against libphobos library, then don't add it. */
diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index 42d01e4..ebbbe71 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -575,6 +575,7 @@ extern tree build_struct_comparison (tree_code, StructDeclaration *,
extern tree build_array_struct_comparison (tree_code, StructDeclaration *,
tree, tree, tree);
extern tree build_struct_literal (tree, vec <constructor_elt, va_gc> *);
+extern tree build_padded_constructor (tree, vec <constructor_elt, va_gc> *);
extern tree component_ref (tree, tree);
extern tree build_assign (tree_code, tree, tree);
extern tree modify_expr (tree, tree);
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 250d148..136f78b 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -651,7 +651,7 @@ public:
}
DECL_INITIAL (vtblsym->csym)
- = build_constructor (TREE_TYPE (vtblsym->csym), elms);
+ = build_padded_constructor (TREE_TYPE (vtblsym->csym), elms);
d_finish_decl (vtblsym->csym);
d->semanticRun (PASS::obj);
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index bd297b6..ee5eb85 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-ed17b3e95dc3fc3264a4c91843da824f5541f3e1
+1b34fea4788136b54ec77c6ed9678754d109fc79
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index b0278cb..19111e3 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -641,21 +641,25 @@ TupleDeclaration isAliasThisTuple(Expression e)
Type t = e.type.toBasetype();
while (true)
{
- Dsymbol s = t.toDsymbol(null);
- if (!s)
- return null;
- auto ad = s.isAggregateDeclaration();
- if (!ad)
- return null;
- s = ad.aliasthis ? ad.aliasthis.sym : null;
- if (s && s.isVarDeclaration())
+ if (Dsymbol s = t.toDsymbol(null))
{
- TupleDeclaration td = s.isVarDeclaration().toAlias().isTupleDeclaration();
- if (td && td.isexp)
- return td;
+ if (auto ad = s.isAggregateDeclaration())
+ {
+ s = ad.aliasthis ? ad.aliasthis.sym : null;
+ if (s && s.isVarDeclaration())
+ {
+ TupleDeclaration td = s.isVarDeclaration().toAlias().isTupleDeclaration();
+ if (td && td.isexp)
+ return td;
+ }
+ if (Type att = t.aliasthisOf())
+ {
+ t = att;
+ continue;
+ }
+ }
}
- if (Type att = t.aliasthisOf())
- t = att;
+ return null;
}
}
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 59952a2..62a575e 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -421,6 +421,7 @@ struct SourceLoc
uint32_t line;
uint32_t column;
uint32_t fileOffset;
+ DString fileContent;
};
struct Loc
diff --git a/gcc/d/dmd/lexer.d b/gcc/d/dmd/lexer.d
index 63313ac..ed9f7f1 100644
--- a/gcc/d/dmd/lexer.d
+++ b/gcc/d/dmd/lexer.d
@@ -132,7 +132,7 @@ class Lexer
// debug printf("Lexer::Lexer(%p)\n", base);
// debug printf("lexer.filename = %s\n", filename);
token = Token.init;
- this.baseLoc = newBaseLoc(filename, endoffset);
+ this.baseLoc = newBaseLoc(filename, base[0 .. endoffset]);
this.linnum = 1;
this.base = base;
this.end = base + endoffset;
@@ -224,7 +224,7 @@ class Lexer
inTokenStringConstant = 0;
lastDocLine = 0;
- baseLoc = newBaseLoc("#defines", slice.length);
+ baseLoc = newBaseLoc("#defines", slice);
scanloc = baseLoc.getLoc(0);
}
diff --git a/gcc/d/dmd/location.d b/gcc/d/dmd/location.d
index 54b3fb6..393ffb8 100644
--- a/gcc/d/dmd/location.d
+++ b/gcc/d/dmd/location.d
@@ -64,7 +64,7 @@ nothrow:
extern (C++) static Loc singleFilename(const char* filename)
{
Loc result;
- locFileTable ~= new BaseLoc(filename.toDString, locIndex, 0, [0]);
+ locFileTable ~= new BaseLoc(filename.toDString, null, locIndex, 0, [0]);
result.index = locIndex++;
return result;
}
@@ -235,16 +235,20 @@ struct SourceLoc
uint column; /// column number (starts at 1)
uint fileOffset; /// byte index into file
+ /// Index `fileOffset` into this to to obtain source code context of this location
+ const(char)[] fileContent;
+
// aliases for backwards compatibility
alias linnum = line;
alias charnum = column;
- this(const(char)[] filename, uint line, uint column, uint fileOffset = 0) nothrow @nogc pure @safe
+ this(const(char)[] filename, uint line, uint column, uint fileOffset = 0, const(char)[] fileContent = null) nothrow @nogc pure @safe
{
this.filename = filename;
this.line = line;
this.column = column;
this.fileOffset = fileOffset;
+ this.fileContent = fileContent;
}
this(Loc loc) nothrow @nogc @trusted
@@ -300,15 +304,15 @@ private size_t fileTableIndex(uint index) nothrow @nogc
* Create a new source location map for a file
* Params:
* filename = source file name
- * size = space to reserve for locations, equal to the file size in bytes
+ * fileContent = content of source file
* Returns: new BaseLoc
*/
-BaseLoc* newBaseLoc(const(char)* filename, size_t size) nothrow
+BaseLoc* newBaseLoc(const(char)* filename, const(char)[] fileContent) nothrow
{
- locFileTable ~= new BaseLoc(filename.toDString, locIndex, 1, [0]);
+ locFileTable ~= new BaseLoc(filename.toDString, fileContent, locIndex, 1, [0]);
// Careful: the endloc of a FuncDeclaration can
// point to 1 past the very last byte in the file, so account for that
- locIndex += size + 1;
+ locIndex += fileContent.length + 1;
return locFileTable[$ - 1];
}
@@ -354,6 +358,7 @@ struct BaseLoc
@safe nothrow:
const(char)[] filename; /// Source file name
+ const(char)[] fileContents; /// Source file contents
uint startIndex; /// Subtract this from Loc.index to get file offset
int startLine = 1; /// Line number at index 0
uint[] lines; /// For each line, the file offset at which it starts. At index 0 there's always a 0 entry.
@@ -384,11 +389,11 @@ struct BaseLoc
{
auto fname = filename.toDString;
if (substitutions.length == 0)
- substitutions ~= BaseLoc(this.filename, 0, 0);
+ substitutions ~= BaseLoc(this.filename, null, 0, 0);
if (fname.length == 0)
fname = substitutions[$ - 1].filename;
- substitutions ~= BaseLoc(fname, offset, cast(int) (line - lines.length + startLine - 2));
+ substitutions ~= BaseLoc(fname, null, offset, cast(int) (line - lines.length + startLine - 2));
}
/// Returns: `loc` modified by substitutions from #file / #line directives
@@ -408,7 +413,7 @@ struct BaseLoc
private SourceLoc getSourceLoc(uint offset) @nogc
{
const i = getLineIndex(offset);
- const sl = SourceLoc(filename, cast(int) (i + startLine), cast(int) (1 + offset - lines[i]), offset);
+ const sl = SourceLoc(filename, cast(int) (i + startLine), cast(int) (1 + offset - lines[i]), offset, fileContents);
return substitute(sl);
}
diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d
index 3bc0489..d4c7a58 100644
--- a/gcc/d/dmd/typesem.d
+++ b/gcc/d/dmd/typesem.d
@@ -3266,9 +3266,19 @@ Type merge(Type type)
case Tsarray:
// prevents generating the mangle if the array dim is not yet known
- if (!type.isTypeSArray().dim.isIntegerExp())
- return type;
- goto default;
+ if (auto ie = type.isTypeSArray().dim.isIntegerExp())
+ {
+ // After TypeSemantic, the length is always converted to size_t, but the parser
+ // usually generates regular integer types (e.g. in cast(const ubyte[2])) which
+ // it may try to merge, which then leads to failing implicit conversions as 2LU != 2
+ // according to Expression.equals. Only merge array types with size_t lengths for now.
+ // https://github.com/dlang/dmd/issues/21179
+ if (ie.type != Type.tsize_t)
+ return type;
+
+ goto default;
+ }
+ return type;
case Tenum:
break;
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 46e6514..1c1ecf2 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2457,7 +2457,7 @@ public:
CONSTRUCTOR_APPEND_ELT (ce, TYPE_FIELDS (aatype), mem);
result = build_nop (build_ctype (e->type),
- build_constructor (aatype, ce));
+ build_padded_constructor (aatype, ce));
}
else
gcc_unreachable ();
@@ -2530,7 +2530,7 @@ public:
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value);
}
- tree ctor = build_constructor (type, elms);
+ tree ctor = build_padded_constructor (type, elms);
TREE_CONSTANT (ctor) = 1;
this->result_ = ctor;
return;
@@ -2612,8 +2612,10 @@ public:
this->result_ = d_array_value (build_ctype (e->type),
size_int (0), null_pointer_node);
else
- this->result_ = build_constructor (make_array_type (tb->nextOf (), 0),
- NULL);
+ {
+ tree arrtype = make_array_type (tb->nextOf (), 0);
+ this->result_ = build_padded_constructor (arrtype, NULL);
+ }
return;
}
@@ -2654,7 +2656,7 @@ public:
/* Now return the constructor as the correct type. For static arrays there
is nothing else to do. For dynamic arrays, return a two field struct.
For pointers, return the address. */
- tree ctor = build_constructor (satype, elms);
+ tree ctor = build_padded_constructor (satype, elms);
tree type = build_ctype (e->type);
/* Nothing else to do for static arrays. */
@@ -2755,7 +2757,7 @@ public:
TypeAArray *ta = tb->isTypeAArray ();
if (e->keys->length == 0)
{
- this->result_ = build_constructor (build_ctype (ta), NULL);
+ this->result_ = build_padded_constructor (build_ctype (ta), NULL);
return;
}
@@ -2787,7 +2789,7 @@ public:
CONSTRUCTOR_APPEND_ELT (ce, TYPE_FIELDS (aatype), mem);
tree result = build_nop (build_ctype (e->type),
- build_constructor (aatype, ce));
+ build_padded_constructor (aatype, ce));
this->result_ = compound_expr (init, result);
}
@@ -2798,7 +2800,7 @@ public:
/* Handle empty struct literals. */
if (e->elements == NULL || e->sd->fields.length == 0)
{
- this->result_ = build_constructor (build_ctype (e->type), NULL);
+ this->result_ = build_padded_constructor (build_ctype (e->type), NULL);
return;
}
@@ -2849,7 +2851,7 @@ public:
elem = d_save_expr (elem);
if (initializer_zerop (elem))
- value = build_constructor (build_ctype (ftype), NULL);
+ value = build_padded_constructor (build_ctype (ftype), NULL);
else
value = build_array_from_val (ftype, elem);
}
@@ -2948,7 +2950,7 @@ public:
if (constant_p)
this->result_ = build_vector_from_ctor (type, elms);
else
- this->result_ = build_constructor (type, elms);
+ this->result_ = build_padded_constructor (type, elms);
}
else if (e->e1->type->toBasetype ()->ty == TY::Tsarray)
{
diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi
index 2cb0c4a62..3a8bea0 100644
--- a/gcc/d/gdc.texi
+++ b/gcc/d/gdc.texi
@@ -277,6 +277,12 @@ Sets @code{__traits(getTargetInfo, "cppStd")} to @code{202002}.
Sets @code{__traits(getTargetInfo, "cppStd")} to @code{202302}.
@end table
+@opindex finclude-imports
+@item -finclude-imports
+Include imported modules in the compilation, as if they were given on the
+command line. When this option is enabled, all imported modules are compiled
+except those that are part of libphobos.
+
@opindex finvariants
@opindex fno-invariants
@item -fno-invariants
diff --git a/gcc/d/lang.opt b/gcc/d/lang.opt
index 50c6f2f..298ff58 100644
--- a/gcc/d/lang.opt
+++ b/gcc/d/lang.opt
@@ -327,6 +327,10 @@ fignore-unknown-pragmas
D
Ignore unsupported pragmas.
+finclude-imports
+D RejectNegative
+Include imported modules in the compilation.
+
finvariants
D Var(flag_invariants)
Generate code for class invariant contracts.
diff --git a/gcc/d/lang.opt.urls b/gcc/d/lang.opt.urls
index 40bbca7..b4886bf 100644
--- a/gcc/d/lang.opt.urls
+++ b/gcc/d/lang.opt.urls
@@ -75,6 +75,9 @@ UrlSuffix(gcc/Warning-Options.html#index-Wextra) LangUrlSuffix_D(gdc/Warnings.ht
Wmismatched-special-enum
LangUrlSuffix_D(gdc/Warnings.html#index-Wmismatched-special-enum)
+Wpsabi
+UrlSuffix(gcc/Warning-Options.html#index-Wno-psabi)
+
Wspeculative
LangUrlSuffix_D(gdc/Warnings.html#index-Wno-speculative)
@@ -152,6 +155,9 @@ LangUrlSuffix_D(gdc/Runtime-Options.html#index-fextern-std)
fignore-unknown-pragmas
LangUrlSuffix_D(gdc/Warnings.html#index-fignore-unknown-pragmas)
+finclude-imports
+LangUrlSuffix_D(gdc/Runtime-Options.html#index-finclude-imports)
+
finvariants
LangUrlSuffix_D(gdc/Runtime-Options.html#index-finvariants)
diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc
index 471ac43..14e4a48 100644
--- a/gcc/d/modules.cc
+++ b/gcc/d/modules.cc
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "function.h"
#include "cgraph.h"
#include "stor-layout.h"
+#include "debug.h"
#include "toplev.h"
#include "target.h"
#include "common/common-target.h"
@@ -667,7 +668,7 @@ layout_moduleinfo (Module *decl)
CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE, size_int (aimports_dim));
CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE,
- build_constructor (satype, elms));
+ build_padded_constructor (satype, elms));
}
if (flags & MIlocalClasses)
@@ -684,7 +685,7 @@ layout_moduleinfo (Module *decl)
CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE, size_int (aclasses.length));
CONSTRUCTOR_APPEND_ELT (minit, NULL_TREE,
- build_constructor (satype, elms));
+ build_padded_constructor (satype, elms));
}
if (flags & MIname)
@@ -927,6 +928,14 @@ d_finish_compilation (tree *vec, int len)
/* Complete all generated thunks. */
symtab->process_same_body_aliases ();
+ /* Output debug information for all type declarations in this unit. */
+ for (int i = 0; i < len; i++)
+ {
+ tree decl = vec[i];
+ if (TREE_CODE (decl) == TYPE_DECL)
+ debug_hooks->type_decl (decl, false);
+ }
+
/* Process all file scopes in this compilation, and the external_scope,
through wrapup_global_declarations. */
for (int i = 0; i < len; i++)
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index e81b2f0..4c3e9e4 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -489,14 +489,14 @@ class TypeInfoVisitor : public Visitor
CONSTRUCTOR_APPEND_ELT (v, size_int (3), size_int (b->offset));
/* Add to the array of interfaces. */
- value = build_constructor (vtbl_interface_type_node, v);
+ value = build_padded_constructor (vtbl_interface_type_node, v);
CONSTRUCTOR_APPEND_ELT (elms, size_int (i), value);
}
tree domain = size_int (cd->vtblInterfaces->length - 1);
tree arrtype = build_array_type (vtbl_interface_type_node,
build_index_type (domain));
- return build_constructor (arrtype, elms);
+ return build_padded_constructor (arrtype, elms);
}
/* Write out the interfacing vtable[] of base class BCD that will be accessed
@@ -542,7 +542,7 @@ class TypeInfoVisitor : public Visitor
tree vtbldomain = build_index_type (size_int (id->vtbl.length - 1));
tree vtbltype = build_array_type (vtable_entry_type, vtbldomain);
- tree value = build_constructor (vtbltype, elms);
+ tree value = build_padded_constructor (vtbltype, elms);
this->layout_field (value);
}
@@ -1160,7 +1160,7 @@ public:
CONSTRUCTOR_APPEND_ELT (elms, size_int (i),
build_typeinfo (d->loc, arg->type));
}
- tree ctor = build_constructor (build_ctype (satype), elms);
+ tree ctor = build_padded_constructor (build_ctype (satype), elms);
tree decl = this->internal_reference (ctor);
tree length = size_int (ti->arguments->length);
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index ea62bc9..e43fa88 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -33,7 +33,6 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
#include "tm.h"
#include "function.h"
-#include "toplev.h"
#include "target.h"
#include "stringpool.h"
#include "stor-layout.h"
@@ -709,13 +708,8 @@ finish_aggregate_type (unsigned structsize, unsigned alignsize, tree type)
TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type);
}
- /* Finish debugging output for this type. */
- rest_of_type_compilation (type, TYPE_FILE_SCOPE_P (type));
+ /* Complete any other forward-referenced fields of this aggregate type. */
finish_incomplete_fields (type);
-
- /* Finish processing of TYPE_DECL. */
- rest_of_decl_compilation (TYPE_NAME (type),
- DECL_FILE_SCOPE_P (TYPE_NAME (type)), 0);
}
/* Returns true if the class or struct type TYPE has already been layed out by
@@ -1185,13 +1179,8 @@ public:
layout_type (t->ctype);
- /* Finish debugging output for this type. */
- rest_of_type_compilation (t->ctype, TYPE_FILE_SCOPE_P (t->ctype));
+ /* Complete forward-referenced fields of this enum type. */
finish_incomplete_fields (t->ctype);
-
- /* Finish processing of TYPE_DECL. */
- rest_of_decl_compilation (TYPE_NAME (t->ctype),
- DECL_FILE_SCOPE_P (TYPE_NAME (t->ctype)), 0);
}
}