aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/d/decl.cc6
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/README.md2
-rw-r--r--gcc/d/dmd/VERSION2
-rw-r--r--gcc/d/dmd/cxxfrontend.d6
-rw-r--r--gcc/d/dmd/declaration.h2
-rw-r--r--gcc/d/dmd/dmodule.d2
-rw-r--r--gcc/d/dmd/dstruct.d5
-rw-r--r--gcc/d/dmd/dsymbolsem.d22
-rw-r--r--gcc/d/dmd/dtemplate.d11
-rw-r--r--gcc/d/dmd/enumsem.d5
-rw-r--r--gcc/d/dmd/expression.h1
-rw-r--r--gcc/d/dmd/expressionsem.d23
-rw-r--r--gcc/d/dmd/func.d317
-rw-r--r--gcc/d/dmd/funcsem.d377
-rw-r--r--gcc/d/dmd/gluelayer.d6
-rw-r--r--gcc/d/dmd/hdrgen.d3
-rw-r--r--gcc/d/dmd/id.d3
-rw-r--r--gcc/d/dmd/mtype.d13
-rw-r--r--gcc/d/dmd/semantic3.d2
-rw-r--r--gcc/d/dmd/statementsem.d5
-rw-r--r--gcc/d/dmd/target.d5
-rw-r--r--gcc/d/dmd/target.h5
-rw-r--r--gcc/d/dmd/templatesem.d10
-rw-r--r--gcc/d/dmd/traits.d11
-rw-r--r--gcc/d/dmd/typesem.d40
-rw-r--r--gcc/testsuite/gdc.test/compilable/b20243.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/cppmangle.d1
-rw-r--r--gcc/testsuite/gdc.test/compilable/cppmangle3.d1
-rw-r--r--gcc/testsuite/gdc.test/compilable/d_ident_c99.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/deprecationlimit.d22
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_21217.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_enum.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_expressions.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_functions.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_mangling.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_names.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_protection.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_verbose.d27
-rw-r--r--gcc/testsuite/gdc.test/compilable/dtoh_windows.d36
-rw-r--r--gcc/testsuite/gdc.test/compilable/future.d47
-rw-r--r--gcc/testsuite/gdc.test/compilable/ident_UAX31.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/ident_all.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/ident_c11.d5
-rw-r--r--gcc/testsuite/gdc.test/compilable/ob1.d16
-rw-r--r--gcc/testsuite/gdc.test/compilable/returnscope_without_safe.d16
-rw-r--r--gcc/testsuite/gdc.test/compilable/sw_transition_complex.d2
-rw-r--r--gcc/testsuite/gdc.test/compilable/test11559upgradeoptlink.d2
-rw-r--r--gcc/testsuite/gdc.test/compilable/test24479.d35
-rw-r--r--gcc/testsuite/gdc.test/compilable/test24560.d12
-rw-r--r--gcc/testsuite/gdc.test/compilable/test__ctfeWrite.d58
-rw-r--r--gcc/testsuite/gdc.test/compilable/zerosize.d5
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/alias_instance_member.d28
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/alias_instance_member2.d21
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/bitintro.d38
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/cast_qual.d19
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/deprecate1553.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/editions.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/empty_statement.d14
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail125.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail17612.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail24485.d32
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/foreach_index_overflow.d28
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice12539.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/issue24534.d25
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/lexer23465.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ob1.d28
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/obsolete_body.d11
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/onemember_overloads.d38
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/systemvariables_bool_union.d22
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/systemvariables_void_init.d51
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test22977.d56
-rw-r--r--gcc/testsuite/gdc.test/runnable/funclit.d12
-rw-r--r--gcc/testsuite/gdc.test/runnable/future.d3
-rw-r--r--gcc/testsuite/gdc.test/runnable/imports/issue18919b.d6
-rw-r--r--gcc/testsuite/gdc.test/runnable/issue18919.d4
-rw-r--r--gcc/testsuite/gdc.test/runnable/test15.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/test17338.d3
-rw-r--r--gcc/testsuite/gdc.test/runnable/test24029.c23
-rw-r--r--gcc/testsuite/gdc.test/runnable/test24498.d21
-rw-r--r--gcc/testsuite/gdc.test/runnable/testthread.d11
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d1
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/cppa.d7
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/externmangle.d44
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp7925.cpp4
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp8
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp4
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp2
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/extra-files/test20652.cpp5
-rw-r--r--gcc/testsuite/gdc.test/runnable_cxx/test20652.d6
103 files changed, 1215 insertions, 1134 deletions
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 34953d8..fa9c429 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -561,10 +561,8 @@ public:
if (fd2->isFuture ())
continue;
- if (FuncDeclaration::leastAsSpecialized (fd, fd2, NULL)
- == MATCH::nomatch
- && FuncDeclaration::leastAsSpecialized (fd2, fd, NULL)
- == MATCH::nomatch)
+ if (dmd::leastAsSpecialized (fd, fd2, NULL) == MATCH::nomatch
+ && dmd::leastAsSpecialized (fd2, fd, NULL) == MATCH::nomatch)
continue;
/* Hiding detected; same name, overlapping specializations. */
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 46d435e..77e8562 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-c11e1d1708646c9ac81ac2aafb57fa1ef5d289ad
+07bc5b9b3c81cc0d4314e0040de981124b363ea5
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/README.md b/gcc/d/dmd/README.md
index d784d07..baac0d7 100644
--- a/gcc/d/dmd/README.md
+++ b/gcc/d/dmd/README.md
@@ -201,11 +201,9 @@ Note that these groups have no strict meaning, the category assignments are a bi
| [libelf.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/libelf.d) | Library in ELF format (Unix) |
| [libmach.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/libmach.d) | Library in Mach-O format (macOS) |
| [libmscoff.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/libmscoff.d) | Library in COFF format (32/64-bit Windows) |
-| [libomf.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/libomf.d) | Library in OMF format (legacy 32-bit Windows) |
| [scanelf.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/scanelf.d) | Extract symbol names from a library in ELF format |
| [scanmach.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/scanmach.d) | Extract symbol names from a library in Mach-O format |
| [scanmscoff.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/scanmscoff.d) | Extract symbol names from a library in COFF format |
-| [scanomf.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/scanomf.d) | Extract symbol names from a library in OMF format |
### Code generation / back-end interfacing
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 99582f5..3d80c3d 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.108.1
+v2.109.0
diff --git a/gcc/d/dmd/cxxfrontend.d b/gcc/d/dmd/cxxfrontend.d
index c0805b8..403588b 100644
--- a/gcc/d/dmd/cxxfrontend.d
+++ b/gcc/d/dmd/cxxfrontend.d
@@ -265,6 +265,12 @@ bool functionSemantic3(FuncDeclaration fd)
return dmd.funcsem.functionSemantic3(fd);
}
+MATCH leastAsSpecialized(FuncDeclaration f, FuncDeclaration g, Identifiers* names)
+{
+ import dmd.funcsem;
+ return dmd.funcsem.leastAsSpecialized(f, g, names);
+}
+
/***********************************************************
* hdrgen.d
*/
diff --git a/gcc/d/dmd/declaration.h b/gcc/d/dmd/declaration.h
index 998beba9..fdfe8a8 100644
--- a/gcc/d/dmd/declaration.h
+++ b/gcc/d/dmd/declaration.h
@@ -34,6 +34,7 @@ namespace dmd
{
bool functionSemantic(FuncDeclaration* fd);
bool functionSemantic3(FuncDeclaration* fd);
+ MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, Identifiers *names);
}
//enum STC : ulong from astenums.d:
@@ -706,7 +707,6 @@ public:
bool overloadInsert(Dsymbol *s) override;
bool inUnittest();
- static MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, Identifiers *names);
LabelDsymbol *searchLabel(Identifier *ident, const Loc &loc);
const char *toPrettyChars(bool QualifyTypes = false) override;
const char *toFullSignature(); // for diagnostics, e.g. 'int foo(int x, int y) pure'
diff --git a/gcc/d/dmd/dmodule.d b/gcc/d/dmd/dmodule.d
index a1a337b..005f1c9 100644
--- a/gcc/d/dmd/dmodule.d
+++ b/gcc/d/dmd/dmodule.d
@@ -766,7 +766,7 @@ extern (C++) final class Module : Package
{
filetype = FileType.c;
- global.compileEnv.masm = target.os == Target.OS.Windows && !target.omfobj; // Microsoft inline assembler format
+ global.compileEnv.masm = target.os == Target.OS.Windows; // Microsoft inline assembler format
scope p = new CParser!AST(this, buf, cast(bool) docfile, global.errorSink, target.c, &defines, &global.compileEnv);
global.compileEnv.masm = false;
p.nextToken();
diff --git a/gcc/d/dmd/dstruct.d b/gcc/d/dmd/dstruct.d
index 339b223..416bd57 100644
--- a/gcc/d/dmd/dstruct.d
+++ b/gcc/d/dmd/dstruct.d
@@ -320,11 +320,6 @@ extern (C++) class StructDeclaration : AggregateDeclaration
*/
structsize = 4;
}
- else if (target.c.bitFieldStyle == TargetC.BitFieldStyle.DM)
- {
- structsize = 0;
- alignsize = 0;
- }
else
structsize = 0;
break;
diff --git a/gcc/d/dmd/dsymbolsem.d b/gcc/d/dmd/dsymbolsem.d
index 65a1b04..4a21b14 100644
--- a/gcc/d/dmd/dsymbolsem.d
+++ b/gcc/d/dmd/dsymbolsem.d
@@ -7259,25 +7259,6 @@ private extern(C++) class SetFieldOffsetVisitor : Visitor
return;
}
}
- else if (style == TargetC.BitFieldStyle.DM)
- {
- if (anon && bfd.fieldWidth && (!fieldState.inFlight || fieldState.bitOffset == 0))
- return; // this probably should be a bug in DMC
- if (ad.alignsize == 0)
- ad.alignsize = 1;
- if (bfd.fieldWidth == 0)
- {
- if (fieldState.inFlight && !isunion)
- {
- const alsz = memsize;
- fieldState.offset = (fieldState.offset + alsz - 1) & ~(alsz - 1);
- ad.structsize = fieldState.offset;
- }
-
- fieldState.inFlight = false;
- return;
- }
- }
if (!fieldState.inFlight)
{
@@ -7307,8 +7288,7 @@ private extern(C++) class SetFieldOffsetVisitor : Visitor
}
}
}
- else if (style == TargetC.BitFieldStyle.DM ||
- style == TargetC.BitFieldStyle.MS)
+ else if (style == TargetC.BitFieldStyle.MS)
{
if (memsize != fieldState.fieldSize ||
fieldState.bitOffset + bfd.fieldWidth > fieldState.fieldSize * 8)
diff --git a/gcc/d/dmd/dtemplate.d b/gcc/d/dmd/dtemplate.d
index fb11821..33ec6b1 100644
--- a/gcc/d/dmd/dtemplate.d
+++ b/gcc/d/dmd/dtemplate.d
@@ -751,6 +751,17 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
return buf.extractChars();
}
+ /****************************
+ * Similar to `toChars`, but does not print the template constraints
+ */
+ const(char)* toCharsNoConstraints() const
+ {
+ HdrGenState hgs = { skipConstraints: true };
+ OutBuffer buf;
+ toCharsMaybeConstraints(this, buf, hgs);
+ return buf.extractChars();
+ }
+
override Visibility visible() pure nothrow @nogc @safe
{
return visibility;
diff --git a/gcc/d/dmd/enumsem.d b/gcc/d/dmd/enumsem.d
index 3886ca2..c67ac61 100644
--- a/gcc/d/dmd/enumsem.d
+++ b/gcc/d/dmd/enumsem.d
@@ -325,7 +325,10 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
if (EnumMember em = s.isEnumMember())
{
em.type = commonType;
- em.value = em.value.castTo(sc, commonType);
+ // optimize out the cast so that other parts of the compiler can
+ // assume that an integral enum's members are `IntegerExp`s.
+ // https://issues.dlang.org/show_bug.cgi?id=24504
+ em.value = em.value.castTo(sc, commonType).optimize(WANTvalue);
}
});
}
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
index 1ff6c4c..ad79281 100644
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -889,6 +889,7 @@ public:
// Possible to cast to one type while painting to another type
Type *to; // type to cast to
unsigned char mod; // MODxxxxx
+ d_bool trusted; // assume cast is safe
CastExp *syntaxCopy() override;
bool isLvalue() override;
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index 3502a1c..481806d 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -14306,14 +14306,16 @@ private Expression dotIdSemanticPropX(DotIdExp exp, Scope* sc)
if (auto te = exp.e1.isTupleExp())
{
- if (exp.ident == Id.offsetof)
+ if (exp.ident == Id.offsetof ||
+ exp.ident == Id.bitoffsetof ||
+ exp.ident == Id.bitwidth)
{
/* 'distribute' the .offsetof to each of the tuple elements.
*/
auto exps = new Expressions(te.exps.length);
foreach (i, e; (*te.exps)[])
{
- (*exps)[i] = new DotIdExp(e.loc, e, Id.offsetof);
+ (*exps)[i] = new DotIdExp(e.loc, e, exp.ident);
}
// Don't evaluate te.e0 in runtime
Expression e = new TupleExp(exp.loc, null, exps);
@@ -14636,6 +14638,8 @@ Expression dotIdSemanticProp(DotIdExp exp, Scope* sc, bool gag)
!cfile &&
(exp.ident == Id._mangleof ||
exp.ident == Id.offsetof ||
+ exp.ident == Id.bitoffsetof ||
+ exp.ident == Id.bitwidth ||
exp.ident == Id._init ||
exp.ident == Id.stringof)
))
@@ -15282,6 +15286,9 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
Expression visitStructLiteral(StructLiteralExp exp)
{
+ if (!exp.elements)
+ return exp;
+
foreach (ref element; *exp.elements)
{
if (element)
@@ -15300,6 +15307,9 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
if (exp.lowering)
exp.lowering = exp.lowering.resolveLoc(loc, sc);
+ if (!exp.arguments)
+ return exp;
+
foreach (ref element; *exp.arguments)
{
if (element)
@@ -15311,6 +15321,9 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
Expression visitCall(CallExp exp)
{
+ if (!exp.arguments)
+ return exp;
+
foreach (ref element; *exp.arguments)
{
if (element)
@@ -15324,6 +15337,9 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
{
exp.e1 = exp.e1.resolveLoc(loc, sc);
+ if (!exp.arguments)
+ return exp;
+
foreach (ref element; *exp.arguments)
{
if (element)
@@ -15357,6 +15373,9 @@ Expression resolveLoc(Expression exp, const ref Loc loc, Scope* sc)
if (exp.basis)
exp.basis = exp.basis.resolveLoc(loc, sc);
+ if (!exp.elements)
+ return exp;
+
foreach (ref element; *exp.elements)
{
if (element)
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d
index f3d7aba..cb19b14 100644
--- a/gcc/d/dmd/func.d
+++ b/gcc/d/dmd/func.d
@@ -424,27 +424,6 @@ extern (C++) class FuncDeclaration : Declaration
}
/****************************************************
- * Determine if 'this' overrides fd.
- * Return !=0 if it does.
- */
- extern (D) final int overrides(FuncDeclaration fd)
- {
- int result = 0;
- if (fd.ident == ident)
- {
- const cov = type.covariant(fd.type);
- if (cov != Covariant.distinct)
- {
- ClassDeclaration cd1 = toParent().isClassDeclaration();
- ClassDeclaration cd2 = fd.toParent().isClassDeclaration();
- if (cd1 && cd2 && cd2.isBaseOf(cd1, null))
- result = 1;
- }
- }
- return result;
- }
-
- /****************************************************
* Overload this FuncDeclaration with the new one f.
* Return true if successful; i.e. no conflict.
*/
@@ -547,91 +526,6 @@ extern (C++) class FuncDeclaration : Declaration
return false;
}
- /*************************************
- * Determine partial specialization order of functions `f` vs `g`.
- * This is very similar to TemplateDeclaration::leastAsSpecialized().
- * Params:
- * f = first function
- * g = second function
- * names = names of parameters
- * Returns:
- * match 'this' is at least as specialized as g
- * 0 g is more specialized than 'this'
- */
- static MATCH leastAsSpecialized(FuncDeclaration f, FuncDeclaration g, Identifiers* names)
- {
- enum LOG_LEASTAS = 0;
- static if (LOG_LEASTAS)
- {
- import core.stdc.stdio : printf;
- printf("leastAsSpecialized(%s, %s, %s)\n", f.toChars(), g.toChars(), names ? names.toChars() : "null");
- printf("%s, %s\n", f.type.toChars(), g.type.toChars());
- }
-
- /* This works by calling g() with f()'s parameters, and
- * if that is possible, then f() is at least as specialized
- * as g() is.
- */
-
- TypeFunction tf = f.type.toTypeFunction();
- TypeFunction tg = g.type.toTypeFunction();
-
- /* If both functions have a 'this' pointer, and the mods are not
- * the same and g's is not const, then this is less specialized.
- */
- if (f.needThis() && g.needThis() && tf.mod != tg.mod)
- {
- if (f.isCtorDeclaration())
- {
- if (!MODimplicitConv(tg.mod, tf.mod))
- return MATCH.nomatch;
- }
- else
- {
- if (!MODimplicitConv(tf.mod, tg.mod))
- return MATCH.nomatch;
- }
- }
-
- /* Create a dummy array of arguments out of the parameters to f()
- */
- Expressions args;
- foreach (u, p; tf.parameterList)
- {
- Expression e;
- if (p.isReference())
- {
- e = new IdentifierExp(Loc.initial, p.ident);
- e.type = p.type;
- }
- else
- e = p.type.defaultInitLiteral(Loc.initial);
- args.push(e);
- }
-
- MATCH m = tg.callMatch(null, ArgumentList(&args, names), 1);
- if (m > MATCH.nomatch)
- {
- /* A variadic parameter list is less specialized than a
- * non-variadic one.
- */
- if (tf.parameterList.varargs && !tg.parameterList.varargs)
- goto L1; // less specialized
-
- static if (LOG_LEASTAS)
- {
- printf(" matches %d, so is least as specialized\n", m);
- }
- return m;
- }
- L1:
- static if (LOG_LEASTAS)
- {
- printf(" doesn't match, so is not as specialized\n");
- }
- return MATCH.nomatch;
- }
-
/********************************
* Searches for a label with the given identifier. This function will insert a new
* `LabelDsymbol` into `labtab` if it does not contain a mapping for `ident`.
@@ -1607,27 +1501,6 @@ extern (C++) class FuncDeclaration : Declaration
return false;
}
- /****************************************************
- * Determine whether an 'out' contract is declared inside
- * the given function or any of its overrides.
- * Params:
- * fd = the function to search
- * Returns:
- * true found an 'out' contract
- */
- static bool needsFensure(FuncDeclaration fd) @safe
- {
- if (fd.fensures)
- return true;
-
- foreach (fdv; fd.foverrides)
- {
- if (needsFensure(fdv))
- return true;
- }
- return false;
- }
-
/*********************************************
* Returns: the function's parameter list, and whether
* it is variadic or not.
@@ -1684,179 +1557,6 @@ extern (C++) class FuncDeclaration : Declaration
return fd;
}
- /+
- + Checks the parameter and return types iff this is a `main` function.
- +
- + The following signatures are allowed for a `D main`:
- + - Either no or a single parameter of type `string[]`
- + - Return type is either `void`, `int` or `noreturn`
- +
- + The following signatures are standard C:
- + - `int main()`
- + - `int main(int, char**)`
- +
- + This function accepts the following non-standard extensions:
- + - `char** envp` as a third parameter
- + - `void` / `noreturn` as return type
- +
- + This function will issue errors for unexpected arguments / return types.
- +/
- extern (D) final void checkMain()
- {
- if (ident != Id.main || isMember() || isNested())
- return; // Not a main function
-
- TypeFunction tf = type.toTypeFunction();
-
- Type retType = tf.nextOf();
- if (!retType)
- {
- // auto main(), check after semantic
- assert(this.inferRetType);
- return;
- }
-
- /// Checks whether `t` is equivalent to `char**`
- /// Ignores qualifiers and treats enums according to their base type
- static bool isCharPtrPtr(Type t)
- {
- auto tp = t.toBasetype().isTypePointer();
- if (!tp)
- return false;
-
- tp = tp.next.toBasetype().isTypePointer();
- if (!tp)
- return false;
-
- return tp.next.toBasetype().ty == Tchar;
- }
-
- // Neither of these qualifiers is allowed because they affect the ABI
- enum invalidSTC = STC.out_ | STC.ref_ | STC.lazy_;
-
- const nparams = tf.parameterList.length;
- bool argerr;
-
- const linkage = resolvedLinkage();
- if (linkage == LINK.d)
- {
- if (nparams == 1)
- {
- auto fparam0 = tf.parameterList[0];
- auto t = fparam0.type.toBasetype();
- if (t.ty != Tarray ||
- t.nextOf().ty != Tarray ||
- t.nextOf().nextOf().ty != Tchar ||
- fparam0.storageClass & invalidSTC)
- {
- argerr = true;
- }
- }
-
- if (tf.parameterList.varargs || nparams >= 2 || argerr)
- .error(loc, "%s `%s` parameter list must be empty or accept one parameter of type `string[]`", kind, toPrettyChars);
- }
-
- else if (linkage == LINK.c)
- {
- if (nparams == 2 || nparams == 3)
- {
- // Argument count must be int
- auto argCount = tf.parameterList[0];
- argerr |= !!(argCount.storageClass & invalidSTC);
- argerr |= argCount.type.toBasetype().ty != Tint32;
-
- // Argument pointer must be char**
- auto argPtr = tf.parameterList[1];
- argerr |= !!(argPtr.storageClass & invalidSTC);
- argerr |= !isCharPtrPtr(argPtr.type);
-
- // `char** environ` is a common extension, see J.5.1 of the C standard
- if (nparams == 3)
- {
- auto envPtr = tf.parameterList[2];
- argerr |= !!(envPtr.storageClass & invalidSTC);
- argerr |= !isCharPtrPtr(envPtr.type);
- }
- }
- else
- argerr = nparams != 0;
-
- // Disallow variadic main() - except for K&R declarations in C files.
- // E.g. int main(), int main(argc, argv) int argc, char** argc { ... }
- if (tf.parameterList.varargs && (!this.isCsymbol() || (!tf.parameterList.hasIdentifierList && nparams)))
- argerr |= true;
-
- if (argerr)
- {
- .error(loc, "%s `%s` parameters must match one of the following signatures", kind, toPrettyChars);
- loc.errorSupplemental("`main()`");
- loc.errorSupplemental("`main(int argc, char** argv)`");
- loc.errorSupplemental("`main(int argc, char** argv, char** environ)` [POSIX extension]");
- }
- }
- else
- return; // Neither C nor D main, ignore (should probably be an error)
-
- // Allow enums with appropriate base types (same ABI)
- retType = retType.toBasetype();
-
- if (retType.ty != Tint32 && retType.ty != Tvoid && retType.ty != Tnoreturn)
- .error(loc, "%s `%s` must return `int`, `void` or `noreturn`, not `%s`", kind, toPrettyChars, tf.nextOf().toChars());
- }
-
- /***********************************************
- * Check all return statements for a function to verify that returning
- * using NRVO is possible.
- *
- * Returns:
- * `false` if the result cannot be returned by hidden reference.
- */
- extern (D) final bool checkNRVO()
- {
- if (!isNRVO() || returns is null)
- return false;
-
- auto tf = type.toTypeFunction();
- if (tf.isref)
- return false;
-
- foreach (rs; *returns)
- {
- if (auto ve = rs.exp.isVarExp())
- {
- auto v = ve.var.isVarDeclaration();
- if (!v || v.isReference())
- return false;
- else if (nrvo_var is null)
- {
- // Variables in the data segment (e.g. globals, TLS or not),
- // parameters and closure variables cannot be NRVOed.
- if (v.isDataseg() || v.isParameter() || v.toParent2() != this)
- return false;
- if (v.nestedrefs.length && needsClosure())
- return false;
- // don't know if the return storage is aligned
- version (MARS)
- {
- if (alignSectionVars && (*alignSectionVars).contains(v))
- return false;
- }
- // The variable type needs to be equivalent to the return type.
- if (!v.type.equivalent(tf.next))
- return false;
- //printf("Setting nrvo to %s\n", v.toChars());
- nrvo_var = v;
- }
- else if (nrvo_var != v)
- return false;
- }
- else //if (!exp.isLvalue()) // keep NRVO-ability
- return false;
- }
- return true;
- }
-
override final inout(FuncDeclaration) isFuncDeclaration() inout
{
return this;
@@ -2067,23 +1767,6 @@ unittest
}
/**************************************
- * Returns an indirect type one step from t.
- */
-Type getIndirection(Type t)
-{
- t = t.baseElemOf();
- if (t.ty == Tarray || t.ty == Tpointer)
- return t.nextOf().toBasetype();
- if (t.ty == Taarray || t.ty == Tclass)
- return t;
- if (t.ty == Tstruct)
- return t.hasPointers() ? t : null; // TODO
-
- // should consider TypeDelegate?
- return null;
-}
-
-/**************************************
* Performs type-based alias analysis between a newly created value and a pre-
* existing memory reference:
*
diff --git a/gcc/d/dmd/funcsem.d b/gcc/d/dmd/funcsem.d
index e058deb..ee36a16 100644
--- a/gcc/d/dmd/funcsem.d
+++ b/gcc/d/dmd/funcsem.d
@@ -65,6 +65,10 @@ import dmd.tokens;
import dmd.typesem;
import dmd.visitor;
+version (IN_GCC) {}
+else version (IN_LLVM) {}
+else version = MARS;
+
/* Tweak all return statements and dtor call for nrvo_var, for correct NRVO.
*/
extern (C++) final class NrvoWalker : StatementRewriteWalker
@@ -742,7 +746,10 @@ void funcDeclarationSemantic(Scope* sc, FuncDeclaration funcdecl)
{
if (fdv.isFuture())
{
- deprecation(funcdecl.loc, "`@__future` base class method `%s` is being overridden by `%s`; rename the latter", fdv.toPrettyChars(), funcdecl.toPrettyChars());
+ deprecation(funcdecl.loc, "method `%s` implicitly overrides `@__future` base class method; rename the former",
+ funcdecl.toPrettyChars());
+ deprecationSupplemental(fdv.loc, "base method `%s` defined here",
+ fdv.toPrettyChars());
// Treat 'this' as an introducing function, giving it a separate hierarchy in the vtbl[]
goto Lintro;
}
@@ -1743,10 +1750,24 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
// max num of overloads to print (-v or -verror-supplements overrides this).
const uint DisplayLimit = global.params.v.errorSupplementCount();
const(char)* constraintsTip;
- // determine if the first candidate was printed
- int printed;
- bool matchSymbol(Dsymbol s, bool print, bool single_candidate = false)
+ int printed = 0; // number of candidates printed
+ int count = 0; // total candidates
+ bool child; // true if inside an eponymous template
+ const(char)* errorPrefix() @safe
+ {
+ if (child)
+ return " - Containing: ";
+
+ // align with blank spaces after first message
+ enum plural = "Candidates are: ";
+ enum spaces = " ";
+ if (printed)
+ return spaces;
+
+ return (count == 1) ? "Candidate is: " : plural;
+ }
+ bool matchSymbol(Dsymbol s, bool print)
{
if (auto fd = s.isFuncDeclaration())
{
@@ -1762,16 +1783,14 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
return true;
auto tf = cast(TypeFunction) fd.type;
OutBuffer buf;
- buf.writestring(fd.toPrettyChars());
+ buf.writestring(child ? fd.toChars() : fd.toPrettyChars());
buf.writestring(parametersTypeToChars(tf.parameterList));
if (tf.mod)
{
buf.writeByte(' ');
buf.MODtoBuffer(tf.mod);
}
- .errorSupplemental(fd.loc,
- printed ? " `%s`" :
- single_candidate ? "Candidate is: `%s`" : "Candidates are: `%s`", buf.peekChars());
+ .errorSupplemental(fd.loc, "%s`%s`", errorPrefix(), buf.peekChars());
}
else if (auto td = s.isTemplateDeclaration())
{
@@ -1779,35 +1798,43 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
if (!print)
return true;
+
+ // td.onemember may not have overloads set
+ // (see fail_compilation/onemember_overloads.d)
+ // assume if more than one member it is overloaded internally
+ bool recurse = td.onemember && td.members.length > 1;
OutBuffer buf;
HdrGenState hgs;
hgs.skipConstraints = true;
+ hgs.showOneMember = !recurse;
toCharsMaybeConstraints(td, buf, hgs);
const tmsg = buf.peekChars();
- const cmsg = td.getConstraintEvalError(constraintsTip);
-
- // add blank space if there are multiple candidates
- // the length of the blank space is `strlen("Candidates are: ")`
+ const cmsg = child ? null : td.getConstraintEvalError(constraintsTip);
if (cmsg)
- {
- .errorSupplemental(td.loc,
- printed ? " `%s`\n%s" :
- single_candidate ? "Candidate is: `%s`\n%s" : "Candidates are: `%s`\n%s",
- tmsg, cmsg);
- }
+ .errorSupplemental(td.loc, "%s`%s`\n%s", errorPrefix(), tmsg, cmsg);
else
+ .errorSupplemental(td.loc, "%s`%s`", errorPrefix(), tmsg);
+
+ if (recurse)
{
- .errorSupplemental(td.loc,
- printed ? " `%s`" :
- single_candidate ? "Candidate is: `%s`" : "Candidates are: `%s`",
- tmsg);
+ child = true;
+ foreach (d; *td.members)
+ {
+ if (d.ident != td.ident)
+ continue;
+
+ if (auto fd2 = d.isFuncDeclaration())
+ matchSymbol(fd2, print);
+ else if (auto td2 = d.isTemplateDeclaration())
+ matchSymbol(td2, print);
+ }
+ child = false;
}
}
return true;
}
// determine if there's > 1 candidate
- int count = 0;
overloadApply(declaration, (s) {
if (matchSymbol(s, false))
count++;
@@ -1817,7 +1844,7 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
overloadApply(declaration, (s) {
if (global.params.v.verbose || printed < DisplayLimit)
{
- if (matchSymbol(s, true, count == 1))
+ if (matchSymbol(s, true))
printed++;
}
else
@@ -1928,6 +1955,112 @@ FuncDeclaration overloadExactMatch(FuncDeclaration thisfd, Type t)
return fd;
}
+/****************************************************
+ * Determine if fd1 overrides fd2.
+ * Return !=0 if it does.
+ */
+int overrides(FuncDeclaration fd1, FuncDeclaration fd2)
+{
+ int result = 0;
+ if (fd1.ident == fd2.ident)
+ {
+ const cov = fd1.type.covariant(fd2.type);
+ if (cov != Covariant.distinct)
+ {
+ ClassDeclaration cd1 = fd1.toParent().isClassDeclaration();
+ ClassDeclaration cd2 = fd2.toParent().isClassDeclaration();
+ if (cd1 && cd2 && cd2.isBaseOf(cd1, null))
+ result = 1;
+ }
+ }
+ return result;
+}
+
+/*************************************
+ * Determine partial specialization order of functions `f` vs `g`.
+ * This is very similar to TemplateDeclaration::leastAsSpecialized().
+ * Params:
+ * f = first function
+ * g = second function
+ * names = names of parameters
+ * Returns:
+ * match 'this' is at least as specialized as g
+ * 0 g is more specialized than 'this'
+ */
+MATCH leastAsSpecialized(FuncDeclaration f, FuncDeclaration g, Identifiers* names)
+{
+ enum LOG_LEASTAS = 0;
+ static if (LOG_LEASTAS)
+ {
+ import core.stdc.stdio : printf;
+ printf("leastAsSpecialized(%s, %s, %s)\n", f.toChars(), g.toChars(), names ? names.toChars() : "null");
+ printf("%s, %s\n", f.type.toChars(), g.type.toChars());
+ }
+
+ /* This works by calling g() with f()'s parameters, and
+ * if that is possible, then f() is at least as specialized
+ * as g() is.
+ */
+
+ TypeFunction tf = f.type.toTypeFunction();
+ TypeFunction tg = g.type.toTypeFunction();
+
+ /* If both functions have a 'this' pointer, and the mods are not
+ * the same and g's is not const, then this is less specialized.
+ */
+ if (f.needThis() && g.needThis() && tf.mod != tg.mod)
+ {
+ if (f.isCtorDeclaration())
+ {
+ if (!MODimplicitConv(tg.mod, tf.mod))
+ return MATCH.nomatch;
+ }
+ else
+ {
+ if (!MODimplicitConv(tf.mod, tg.mod))
+ return MATCH.nomatch;
+ }
+ }
+
+ /* Create a dummy array of arguments out of the parameters to f()
+ */
+ Expressions args;
+ foreach (u, p; tf.parameterList)
+ {
+ Expression e;
+ if (p.isReference())
+ {
+ e = new IdentifierExp(Loc.initial, p.ident);
+ e.type = p.type;
+ }
+ else
+ e = p.type.defaultInitLiteral(Loc.initial);
+ args.push(e);
+ }
+
+ MATCH m = tg.callMatch(null, ArgumentList(&args, names), 1);
+ if (m > MATCH.nomatch)
+ {
+ /* A variadic parameter list is less specialized than a
+ * non-variadic one.
+ */
+ if (tf.parameterList.varargs && !tg.parameterList.varargs)
+ goto L1; // less specialized
+
+ static if (LOG_LEASTAS)
+ {
+ printf(" matches %d, so is least as specialized\n", m);
+ }
+ return m;
+ }
+L1:
+ static if (LOG_LEASTAS)
+ {
+ printf(" doesn't match, so is not as specialized\n");
+ }
+ return MATCH.nomatch;
+}
+
/********************************************
* Find function in overload list that matches to the 'this' modifier.
* There's four result types.
@@ -2494,6 +2627,27 @@ void buildEnsureRequire(FuncDeclaration thisfd)
}
/****************************************************
+ * Determine whether an 'out' contract is declared inside
+ * the given function or any of its overrides.
+ * Params:
+ * fd = the function to search
+ * Returns:
+ * true found an 'out' contract
+ */
+bool needsFensure(FuncDeclaration fd) @safe
+{
+ if (fd.fensures)
+ return true;
+
+ foreach (fdv; fd.foverrides)
+ {
+ if (needsFensure(fdv))
+ return true;
+ }
+ return false;
+}
+
+/****************************************************
* Merge into this function the 'out' contracts of all it overrides.
* 'out's are AND'd together, i.e. all of them need to pass.
*/
@@ -2515,7 +2669,7 @@ Statement mergeFensure(FuncDeclaration fd, Statement sf, Identifier oid, Express
* https://issues.dlang.org/show_bug.cgi?id=3602 and
* https://issues.dlang.org/show_bug.cgi?id=5230
*/
- if (fd.needsFensure(fdv) && fdv.semanticRun != PASS.semantic3done)
+ if (needsFensure(fdv) && fdv.semanticRun != PASS.semantic3done)
{
assert(fdv._scope);
Scope* sc = fdv._scope.push();
@@ -2735,3 +2889,176 @@ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)
return false;
}
}
+
+/+
+ + Checks the parameter and return types iff this is a `main` function.
+ +
+ + The following signatures are allowed for a `D main`:
+ + - Either no or a single parameter of type `string[]`
+ + - Return type is either `void`, `int` or `noreturn`
+ +
+ + The following signatures are standard C:
+ + - `int main()`
+ + - `int main(int, char**)`
+ +
+ + This function accepts the following non-standard extensions:
+ + - `char** envp` as a third parameter
+ + - `void` / `noreturn` as return type
+ +
+ + This function will issue errors for unexpected arguments / return types.
+ +/
+extern (D) void checkMain(FuncDeclaration fd)
+{
+ if (fd.ident != Id.main || fd.isMember() || fd.isNested())
+ return; // Not a main function
+
+ TypeFunction tf = fd.type.toTypeFunction();
+
+ Type retType = tf.nextOf();
+ if (!retType)
+ {
+ // auto main(), check after semantic
+ assert(fd.inferRetType);
+ return;
+ }
+
+ /// Checks whether `t` is equivalent to `char**`
+ /// Ignores qualifiers and treats enums according to their base type
+ static bool isCharPtrPtr(Type t)
+ {
+ auto tp = t.toBasetype().isTypePointer();
+ if (!tp)
+ return false;
+
+ tp = tp.next.toBasetype().isTypePointer();
+ if (!tp)
+ return false;
+
+ return tp.next.toBasetype().ty == Tchar;
+ }
+
+ // Neither of these qualifiers is allowed because they affect the ABI
+ enum invalidSTC = STC.out_ | STC.ref_ | STC.lazy_;
+
+ const nparams = tf.parameterList.length;
+ bool argerr;
+
+ const linkage = fd.resolvedLinkage();
+ if (linkage == LINK.d)
+ {
+ if (nparams == 1)
+ {
+ auto fparam0 = tf.parameterList[0];
+ auto t = fparam0.type.toBasetype();
+ if (t.ty != Tarray ||
+ t.nextOf().ty != Tarray ||
+ t.nextOf().nextOf().ty != Tchar ||
+ fparam0.storageClass & invalidSTC)
+ {
+ argerr = true;
+ }
+ }
+
+ if (tf.parameterList.varargs || nparams >= 2 || argerr)
+ .error(fd.loc, "%s `%s` parameter list must be empty or accept one parameter of type `string[]`", fd.kind, fd.toPrettyChars);
+ }
+
+ else if (linkage == LINK.c)
+ {
+ if (nparams == 2 || nparams == 3)
+ {
+ // Argument count must be int
+ auto argCount = tf.parameterList[0];
+ argerr |= !!(argCount.storageClass & invalidSTC);
+ argerr |= argCount.type.toBasetype().ty != Tint32;
+
+ // Argument pointer must be char**
+ auto argPtr = tf.parameterList[1];
+ argerr |= !!(argPtr.storageClass & invalidSTC);
+ argerr |= !isCharPtrPtr(argPtr.type);
+
+ // `char** environ` is a common extension, see J.5.1 of the C standard
+ if (nparams == 3)
+ {
+ auto envPtr = tf.parameterList[2];
+ argerr |= !!(envPtr.storageClass & invalidSTC);
+ argerr |= !isCharPtrPtr(envPtr.type);
+ }
+ }
+ else
+ argerr = nparams != 0;
+
+ // Disallow variadic main() - except for K&R declarations in C files.
+ // E.g. int main(), int main(argc, argv) int argc, char** argc { ... }
+ if (tf.parameterList.varargs && (!fd.isCsymbol() || (!tf.parameterList.hasIdentifierList && nparams)))
+ argerr |= true;
+
+ if (argerr)
+ {
+ .error(fd.loc, "%s `%s` parameters must match one of the following signatures", fd.kind, fd.toPrettyChars);
+ fd.loc.errorSupplemental("`main()`");
+ fd.loc.errorSupplemental("`main(int argc, char** argv)`");
+ fd.loc.errorSupplemental("`main(int argc, char** argv, char** environ)` [POSIX extension]");
+ }
+ }
+ else
+ return; // Neither C nor D main, ignore (should probably be an error)
+
+ // Allow enums with appropriate base types (same ABI)
+ retType = retType.toBasetype();
+
+ if (retType.ty != Tint32 && retType.ty != Tvoid && retType.ty != Tnoreturn)
+ .error(fd.loc, "%s `%s` must return `int`, `void` or `noreturn`, not `%s`", fd.kind, fd.toPrettyChars, tf.nextOf().toChars());
+}
+
+/***********************************************
+ * Check all return statements for a function to verify that returning
+ * using NRVO is possible.
+ *
+ * Returns:
+ * `false` if the result cannot be returned by hidden reference.
+ */
+extern (D) bool checkNRVO(FuncDeclaration fd)
+{
+ if (!fd.isNRVO() || fd.returns is null)
+ return false;
+
+ auto tf = fd.type.toTypeFunction();
+ if (tf.isref)
+ return false;
+
+ foreach (rs; *fd.returns)
+ {
+ if (auto ve = rs.exp.isVarExp())
+ {
+ auto v = ve.var.isVarDeclaration();
+ if (!v || v.isReference())
+ return false;
+ else if (fd.nrvo_var is null)
+ {
+ // Variables in the data segment (e.g. globals, TLS or not),
+ // parameters and closure variables cannot be NRVOed.
+ if (v.isDataseg() || v.isParameter() || v.toParent2() != fd)
+ return false;
+ if (v.nestedrefs.length && fd.needsClosure())
+ return false;
+ // don't know if the return storage is aligned
+ version (MARS)
+ {
+ if (fd.alignSectionVars && (*fd.alignSectionVars).contains(v))
+ return false;
+ }
+ // The variable type needs to be equivalent to the return type.
+ if (!v.type.equivalent(tf.next))
+ return false;
+ //printf("Setting nrvo to %s\n", v.toChars());
+ fd.nrvo_var = v;
+ }
+ else if (fd.nrvo_var != v)
+ return false;
+ }
+ else //if (!exp.isLvalue()) // keep NRVO-ability
+ return false;
+ }
+ return true;
+}
diff --git a/gcc/d/dmd/gluelayer.d b/gcc/d/dmd/gluelayer.d
index a3a3bd0..72e6c52 100644
--- a/gcc/d/dmd/gluelayer.d
+++ b/gcc/d/dmd/gluelayer.d
@@ -25,7 +25,7 @@ version (NoBackend)
struct Symbol;
struct code;
struct block;
- struct Blockx;
+ struct BlockState;
struct elem;
struct TYPE;
alias type = TYPE;
@@ -51,9 +51,9 @@ else version (IN_GCC)
}
else
{
- public import dmd.backend.cc : block, Blockx, Symbol;
+ public import dmd.backend.cc : block, BlockState, Symbol;
public import dmd.backend.type : type;
public import dmd.backend.el : elem;
- public import dmd.backend.code_x86 : code;
+ public import dmd.backend.x86.code_x86 : code;
public import dmd.objc_glue : ObjcGlue;
}
diff --git a/gcc/d/dmd/hdrgen.d b/gcc/d/dmd/hdrgen.d
index 41da11d..1e72cf7 100644
--- a/gcc/d/dmd/hdrgen.d
+++ b/gcc/d/dmd/hdrgen.d
@@ -62,6 +62,7 @@ struct HdrGenState
bool doFuncBodies; /// include function bodies in output
bool vcg_ast; /// write out codegen-ast
bool skipConstraints; // skip constraints when doing templates
+ bool showOneMember = true;
bool fullQual; /// fully qualify types when printing
int tpltMember;
@@ -1974,7 +1975,7 @@ void toCharsMaybeConstraints(const TemplateDeclaration td, ref OutBuffer buf, re
}
buf.writeByte(')');
- if (td.onemember)
+ if (hgs.showOneMember && td.onemember)
{
if (const fd = td.onemember.isFuncDeclaration())
{
diff --git a/gcc/d/dmd/id.d b/gcc/d/dmd/id.d
index 6dbc60b..dfaf8f5 100644
--- a/gcc/d/dmd/id.d
+++ b/gcc/d/dmd/id.d
@@ -102,6 +102,8 @@ immutable Msgtable[] msgtable =
{ "ctfe", "__ctfe" },
{ "offset" },
{ "offsetof" },
+ { "bitoffsetof" },
+ { "bitwidth" },
{ "ModuleInfo" },
{ "ClassInfo" },
{ "classinfo" },
@@ -455,6 +457,7 @@ immutable Msgtable[] msgtable =
{ "isAbstractClass" },
{ "isArithmetic" },
{ "isAssociativeArray" },
+ { "isBitfield" },
{ "isFinalClass" },
{ "isTemplate" },
{ "isPOD" },
diff --git a/gcc/d/dmd/mtype.d b/gcc/d/dmd/mtype.d
index dcfe183..a91a0a4 100644
--- a/gcc/d/dmd/mtype.d
+++ b/gcc/d/dmd/mtype.d
@@ -597,6 +597,14 @@ extern (C++) abstract class Type : ASTNode
tsize_t = basic[isLP64 ? Tuns64 : Tuns32];
tptrdiff_t = basic[isLP64 ? Tint64 : Tint32];
thash_t = tsize_t;
+
+ static if (__VERSION__ == 2081)
+ {
+ // Related issue: https://issues.dlang.org/show_bug.cgi?id=19134
+ // D 2.081.x regressed initializing class objects at compile time.
+ // As a workaround initialize this global at run-time instead.
+ TypeTuple.empty = new TypeTuple();
+ }
}
/**
@@ -4405,7 +4413,10 @@ extern (C++) final class TypeClass : Type
extern (C++) final class TypeTuple : Type
{
// 'logically immutable' cached global - don't modify!
- __gshared TypeTuple empty = new TypeTuple();
+ static if (__VERSION__ == 2081)
+ __gshared TypeTuple empty; // See comment in Type._init
+ else
+ __gshared TypeTuple empty = new TypeTuple();
Parameters* arguments; // types making up the tuple
diff --git a/gcc/d/dmd/semantic3.d b/gcc/d/dmd/semantic3.d
index d88face..963fa92 100644
--- a/gcc/d/dmd/semantic3.d
+++ b/gcc/d/dmd/semantic3.d
@@ -314,7 +314,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
fds.checkInContractOverrides();
// Remember whether we need to generate an 'out' contract.
- immutable bool needEnsure = FuncDeclaration.needsFensure(funcdecl);
+ immutable bool needEnsure = funcdecl.needsFensure();
if (funcdecl.fbody || funcdecl.frequires || needEnsure)
{
diff --git a/gcc/d/dmd/statementsem.d b/gcc/d/dmd/statementsem.d
index ae68d6a..d0e1b9a 100644
--- a/gcc/d/dmd/statementsem.d
+++ b/gcc/d/dmd/statementsem.d
@@ -3542,6 +3542,7 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
ls2.statement = ls;
sc = sc.push();
+ sc.lastVar = sc.enclosing.lastVar;
sc.scopesym = sc.enclosing.scopesym;
sc.ctorflow.orCSX(CSX.label);
@@ -3549,6 +3550,10 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
sc.slabel = ls;
if (ls.statement)
ls.statement = ls.statement.statementSemantic(sc);
+
+ //issue 24534: lastVar may have been updated in the nested scope
+ sc.enclosing.lastVar = sc.lastVar;
+
sc.pop();
result = ls;
diff --git a/gcc/d/dmd/target.d b/gcc/d/dmd/target.d
index 87826b5..dadf519 100644
--- a/gcc/d/dmd/target.d
+++ b/gcc/d/dmd/target.d
@@ -113,6 +113,7 @@ extern (C++) struct Target
const(char)[] architectureName;
CPU cpu; // CPU instruction set to target
bool isX86_64; // generate 64 bit code for x86_64; true by default for 64 bit dmd
+ bool isX86; // generate 32 bit Intel x86 code
bool isLP64; // pointers are 64 bits
// Environmental
@@ -120,7 +121,6 @@ extern (C++) struct Target
const(char)[] lib_ext; /// extension for static library files
const(char)[] dll_ext; /// extension for dynamic library files
bool run_noext; /// allow -run sources without extensions
- bool omfobj; // for Win32: write OMF object files instead of MsCoff
/**
* Values representing all properties for floating point types
*/
@@ -302,7 +302,6 @@ struct TargetC
{
Unspecified,
Bionic,
- DigitalMars,
Glibc,
Microsoft,
Musl,
@@ -314,7 +313,6 @@ struct TargetC
enum BitFieldStyle : ubyte
{
Unspecified,
- DM, /// Digital Mars 32 bit C compiler
MS, /// Microsoft 32 and 64 bit C compilers
/// https://docs.microsoft.com/en-us/cpp/c-language/c-bit-fields?view=msvc-160
/// https://docs.microsoft.com/en-us/cpp/cpp/cpp-bit-fields?view=msvc-160
@@ -347,7 +345,6 @@ struct TargetCPP
{
Unspecified,
Clang,
- DigitalMars,
Gcc,
Microsoft,
Sun
diff --git a/gcc/d/dmd/target.h b/gcc/d/dmd/target.h
index 6237cf14..a5caa74 100644
--- a/gcc/d/dmd/target.h
+++ b/gcc/d/dmd/target.h
@@ -50,7 +50,6 @@ struct TargetC
{
Unspecified,
Bionic,
- DigitalMars,
Glibc,
Microsoft,
Musl,
@@ -62,7 +61,6 @@ struct TargetC
enum class BitFieldStyle : unsigned char
{
Unspecified,
- DM, // Digital Mars 32 bit C compiler
MS, // Microsoft 32 and 64 bit C compilers
// https://docs.microsoft.com/en-us/cpp/c-language/c-bit-fields?view=msvc-160
// https://docs.microsoft.com/en-us/cpp/cpp/cpp-bit-fields?view=msvc-160
@@ -87,7 +85,6 @@ struct TargetCPP
{
Unspecified,
Clang,
- DigitalMars,
Gcc,
Microsoft,
Sun
@@ -157,6 +154,7 @@ struct Target
DString architectureName; // name of the platform architecture (e.g. X86_64)
CPU cpu; // CPU instruction set to target
d_bool isX86_64; // generate 64 bit code for x86_64; true by default for 64 bit dmd
+ d_bool isX86; // generate 32 bit Intel x86 code
d_bool isLP64; // pointers are 64 bits
// Environmental
@@ -164,7 +162,6 @@ struct Target
DString lib_ext; /// extension for static library files
DString dll_ext; /// extension for dynamic library files
d_bool run_noext; /// allow -run sources without extensions
- d_bool omfobj; /// for Win32: write OMF object files instead of COFF
template <typename T>
struct FPTypeProperties
diff --git a/gcc/d/dmd/templatesem.d b/gcc/d/dmd/templatesem.d
index bd3cd89..d26e35d 100644
--- a/gcc/d/dmd/templatesem.d
+++ b/gcc/d/dmd/templatesem.d
@@ -56,6 +56,8 @@ import dmd.tokens;
import dmd.typesem;
import dmd.visitor;
+alias funcLeastAsSpecialized = dmd.funcsem.leastAsSpecialized;
+
/************************************
* Perform semantic analysis on template.
* Params:
@@ -2021,8 +2023,8 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc,
* This is because f() is "more specialized."
*/
{
- MATCH c1 = FuncDeclaration.leastAsSpecialized(fd, m.lastf, argumentList.names);
- MATCH c2 = FuncDeclaration.leastAsSpecialized(m.lastf, fd, argumentList.names);
+ MATCH c1 = funcLeastAsSpecialized(fd, m.lastf, argumentList.names);
+ MATCH c2 = funcLeastAsSpecialized(m.lastf, fd, argumentList.names);
//printf("c1 = %d, c2 = %d\n", c1, c2);
if (c1 > c2) return firstIsBetter();
if (c1 < c2) return 0;
@@ -2301,8 +2303,8 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc,
}
{
// Disambiguate by picking the most specialized FunctionDeclaration
- MATCH c1 = FuncDeclaration.leastAsSpecialized(fd, m.lastf, argumentList.names);
- MATCH c2 = FuncDeclaration.leastAsSpecialized(m.lastf, fd, argumentList.names);
+ MATCH c1 = funcLeastAsSpecialized(fd, m.lastf, argumentList.names);
+ MATCH c2 = funcLeastAsSpecialized(m.lastf, fd, argumentList.names);
//printf("3: c1 = %d, c2 = %d\n", c1, c2);
if (c1 > c2) goto Ltd;
if (c1 < c2) goto Ltd_best;
diff --git a/gcc/d/dmd/traits.d b/gcc/d/dmd/traits.d
index 81d42e6..5ec3844 100644
--- a/gcc/d/dmd/traits.d
+++ b/gcc/d/dmd/traits.d
@@ -503,6 +503,17 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
sm => sm.isTemplateDeclaration() !is null) != 0;
});
}
+ if (e.ident == Id.isBitfield)
+ {
+ if (dim != 1)
+ return dimError(1);
+
+ return isDsymX((s)
+ {
+ s = s.toAlias();
+ return s.isBitFieldDeclaration() !is null;
+ });
+ }
if (e.ident == Id.isPOD)
{
if (dim != 1)
diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d
index 195fdc7..31ebc4c 100644
--- a/gcc/d/dmd/typesem.d
+++ b/gcc/d/dmd/typesem.d
@@ -1282,6 +1282,23 @@ bool hasPointers(Type t)
}
}
+/**************************************
+ * Returns an indirect type one step from t.
+ */
+Type getIndirection(Type t)
+{
+ t = t.baseElemOf();
+ if (t.ty == Tarray || t.ty == Tpointer)
+ return t.nextOf().toBasetype();
+ if (t.ty == Taarray || t.ty == Tclass)
+ return t;
+ if (t.ty == Tstruct)
+ return t.hasPointers() ? t : null; // TODO
+
+ // should consider TypeDelegate?
+ return null;
+}
+
/******************************************
* Perform semantic analysis on a type.
* Params:
@@ -4083,7 +4100,9 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag
}
if (v)
{
- if (ident == Id.offsetof)
+ if (ident == Id.offsetof ||
+ ident == Id.bitoffsetof ||
+ ident == Id.bitwidth)
{
v.dsymbolSemantic(null);
if (v.isField())
@@ -4093,7 +4112,20 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag
ad.size(e.loc);
if (ad.sizeok != Sizeok.done)
return ErrorExp.get();
- return new IntegerExp(e.loc, v.offset, Type.tsize_t);
+ uint value;
+ if (ident == Id.offsetof)
+ value = v.offset;
+ else // Id.bitoffsetof || Id.bitwidth
+ {
+ auto bf = v.isBitFieldDeclaration();
+ if (bf)
+ {
+ value = ident == Id.bitoffsetof ? bf.bitOffset : bf.fieldWidth;
+ }
+ else
+ error(v.loc, "`%s` is not a bitfield, cannot apply `%s`", v.toChars(), ident.toChars());
+ }
+ return new IntegerExp(e.loc, value, Type.tsize_t);
}
}
else if (ident == Id._init)
@@ -4512,6 +4544,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, DotExpFlag
ident != Id._mangleof &&
ident != Id.stringof &&
ident != Id.offsetof &&
+ ident != Id.bitoffsetof &&
+ ident != Id.bitwidth &&
// https://issues.dlang.org/show_bug.cgi?id=15045
// Don't forward special built-in member functions.
ident != Id.ctor &&
@@ -6687,7 +6721,7 @@ Type substWildTo(Type type, uint mod)
t = new TypeSArray(t, (cast(TypeSArray)type).dim.syntaxCopy());
else if (type.ty == Taarray)
{
- t = new TypeAArray(t, (cast(TypeAArray)type).index.syntaxCopy());
+ t = new TypeAArray(t, (cast(TypeAArray)type).index.substWildTo(mod));
}
else if (type.ty == Tdelegate)
{
diff --git a/gcc/testsuite/gdc.test/compilable/b20243.d b/gcc/testsuite/gdc.test/compilable/b20243.d
new file mode 100644
index 0000000..792dcf3
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/b20243.d
@@ -0,0 +1,9 @@
+module b20243;
+
+inout(int) f(inout(int)[inout(string)] x);
+const(int)[const(string)] x;
+static assert(is(typeof(f(x)) == const(int)));
+
+inout(int)[inout(string)] g(inout(int) y);
+const(int) y;
+static assert(is(typeof(g(y)) == const(int)[const(string)]));
diff --git a/gcc/testsuite/gdc.test/compilable/cppmangle.d b/gcc/testsuite/gdc.test/compilable/cppmangle.d
index 264b374..948fee2 100644
--- a/gcc/testsuite/gdc.test/compilable/cppmangle.d
+++ b/gcc/testsuite/gdc.test/compilable/cppmangle.d
@@ -8,7 +8,6 @@
import core.stdc.stdio;
version (CppRuntime_Clang) version = CppMangle_Itanium;
-version (CppRuntime_DigitalMars) version = CppMangle_MSVC;
version (CppRuntime_Gcc) version = CppMangle_Itanium;
version (CppRuntime_Microsoft) version = CppMangle_MSVC;
version (CppRuntime_Sun) version = CppMangle_Itanium;
diff --git a/gcc/testsuite/gdc.test/compilable/cppmangle3.d b/gcc/testsuite/gdc.test/compilable/cppmangle3.d
index 82c68f7..92c8588 100644
--- a/gcc/testsuite/gdc.test/compilable/cppmangle3.d
+++ b/gcc/testsuite/gdc.test/compilable/cppmangle3.d
@@ -4,7 +4,6 @@
module cppmangle3;
version (CppRuntime_Clang) version = CppMangle_Itanium;
-version (CppRuntime_DigitalMars) version = CppMangle_MSVC;
version (CppRuntime_Gcc) version = CppMangle_Itanium;
version (CppRuntime_Microsoft) version = CppMangle_MSVC;
version (CppRuntime_Sun) version = CppMangle_Itanium;
diff --git a/gcc/testsuite/gdc.test/compilable/d_ident_c99.d b/gcc/testsuite/gdc.test/compilable/d_ident_c99.d
new file mode 100644
index 0000000..2cff082
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/d_ident_c99.d
@@ -0,0 +1,5 @@
+// REQUIRED_ARGS: -identifiers=c99
+
+// verify that the C99 identifier set is applied.
+
+int ªideµnt;
diff --git a/gcc/testsuite/gdc.test/compilable/deprecationlimit.d b/gcc/testsuite/gdc.test/compilable/deprecationlimit.d
new file mode 100644
index 0000000..dcdc9e1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/deprecationlimit.d
@@ -0,0 +1,22 @@
+/*
+REQUIRED_ARGS: -verrors=3
+TEST_OUTPUT:
+---
+compilable/deprecationlimit.d(18): Deprecation: function `deprecationlimit.f` is deprecated
+compilable/deprecationlimit.d(19): Deprecation: function `deprecationlimit.f` is deprecated
+compilable/deprecationlimit.d(20): Deprecation: function `deprecationlimit.f` is deprecated
+1 deprecation warning omitted, use `-verrors=0` to show all
+---
+*/
+
+deprecated void f()
+{
+}
+
+void main()
+{
+ f();
+ f();
+ f();
+ f();
+}
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_21217.d b/gcc/testsuite/gdc.test/compilable/dtoh_21217.d
index 3e535d2..439ff36 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_21217.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_21217.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct Foo final
{
int32_t a;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d
index 64198f9..43bbe97 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration.d
@@ -14,33 +14,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
class C;
extern void importFunc();
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d b/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d
index 12edbd2..b285e6f 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_AliasDeclaration_98.d
@@ -11,33 +11,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
template <typename T, typename U>
struct TS final
{
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d
index a4c6ce4..3c5bde3 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_AnonDeclaration.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct S final
{
union
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d
index 0436371..2310bfa 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_CPPNamespaceDeclaration.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
namespace nameSpace
{
extern void fn();
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d
index 169b7b1..cca4646 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_ClassDeclaration.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
class ForwardClass;
class BaseClass
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d
index 6fefcce..45b5530 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_TemplateDeclaration.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct Outer final
{
int32_t a;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d b/gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d
index 48fcf72..e0648d7 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_UnionDeclaration.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
union U1
{
int32_t a;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_enum.d b/gcc/testsuite/gdc.test/compilable/dtoh_enum.d
index 8b3e5aa..e8b4a55 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_enum.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_enum.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
enum : int32_t { Anon = 10 };
enum : bool { Anon2 = true };
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d b/gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d
index 6a266d9..1314f64 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_enum_cpp98.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
static int32_t const Anon = 10;
static bool const Anon2 = true;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_expressions.d b/gcc/testsuite/gdc.test/compilable/dtoh_expressions.d
index b93c47e..7af1025 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_expressions.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_expressions.d
@@ -11,33 +11,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
extern int32_t foo();
extern int32_t* somePtr;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d b/gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d
index c9d5bbc..beb779d 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_forwarding.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct Child;
class Struct;
enum class Enum;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_functions.d b/gcc/testsuite/gdc.test/compilable/dtoh_functions.d
index 90223cc..f5777bc 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_functions.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_functions.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct S final
{
int32_t i;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d b/gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d
index a8f5b99..28c7908 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_invalid_identifiers.d
@@ -21,33 +21,6 @@ compilable/dtoh_invalid_identifiers.d(145): Warning: function `__attribute__` is
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
extern void register(int32_t* ptr);
namespace const_cast
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_mangling.d b/gcc/testsuite/gdc.test/compilable/dtoh_mangling.d
index fda9efa..203f424 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_mangling.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_mangling.d
@@ -11,33 +11,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
extern "C" int32_t freeC();
// Ignored function dtoh_mangling.bar because C++ doesn't support explicit mangling
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_names.d b/gcc/testsuite/gdc.test/compilable/dtoh_names.d
index a4b055e..c6def03 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_names.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_names.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct Outer final
{
static Outer* outerPtr;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_protection.d b/gcc/testsuite/gdc.test/compilable/dtoh_protection.d
index dc07c7b..458b2d7 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_protection.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_protection.d
@@ -13,33 +13,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
struct S1 final
{
int32_t a;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d b/gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d
index ab53764..77aee6e 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_required_symbols.d
@@ -11,33 +11,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
class ExternDClass;
struct ExternDStruct2;
struct ExternDStruct3;
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d b/gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d
index ee86a5e..a2982ac 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_special_enum.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
enum class __c_not_special;
extern "C" void fn_long(long __param_0_);
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d b/gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d
index 7b2943c..c7aa6b7 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_unittest_block.d
@@ -12,33 +12,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
---
*/
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_verbose.d b/gcc/testsuite/gdc.test/compilable/dtoh_verbose.d
index 891ff0e..e4b268b 100644
--- a/gcc/testsuite/gdc.test/compilable/dtoh_verbose.d
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_verbose.d
@@ -14,33 +14,6 @@ TEST_OUTPUT:
#include <stddef.h>
#include <stdint.h>
-#ifdef CUSTOM_D_ARRAY_TYPE
-#define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
-#else
-/// Represents a D [] array
-template<typename T>
-struct _d_dynamicArray final
-{
- size_t length;
- T *ptr;
-
- _d_dynamicArray() : length(0), ptr(NULL) { }
-
- _d_dynamicArray(size_t length_in, T *ptr_in)
- : length(length_in), ptr(ptr_in) { }
-
- T& operator[](const size_t idx) {
- assert(idx < length);
- return ptr[idx];
- }
-
- const T& operator[](const size_t idx) const {
- assert(idx < length);
- return ptr[idx];
- }
-};
-#endif
-
extern void importFunc();
// Ignored function dtoh_verbose.foo because of linkage
diff --git a/gcc/testsuite/gdc.test/compilable/dtoh_windows.d b/gcc/testsuite/gdc.test/compilable/dtoh_windows.d
new file mode 100644
index 0000000..1cbe324
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/dtoh_windows.d
@@ -0,0 +1,36 @@
+/++
+REQUIRED_ARGS: -HC -o-
+TEST_OUTPUT:
+---
+// Automatically generated by Digital Mars D Compiler
+
+#pragma once
+
+#include <assert.h>
+#include <math.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifndef _WIN32
+#define EXTERN_SYSTEM_AFTER __stdcall
+#define EXTERN_SYSTEM_BEFORE
+#else
+#define EXTERN_SYSTEM_AFTER
+#define EXTERN_SYSTEM_BEFORE extern "C"
+#endif
+
+EXTERN_SYSTEM_BEFORE int32_t EXTERN_SYSTEM_AFTER exSystem(int32_t x);
+
+int32_t __stdcall exWindows(int32_t y);
+---
+++/
+
+extern(System) int exSystem(int x)
+{
+ return x;
+}
+
+extern(Windows) int exWindows(int y)
+{
+ return y;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/future.d b/gcc/testsuite/gdc.test/compilable/future.d
deleted file mode 100644
index 3043984..0000000
--- a/gcc/testsuite/gdc.test/compilable/future.d
+++ /dev/null
@@ -1,47 +0,0 @@
-/* PERMUTE_ARGS:
- * TEST_OUTPUT:
----
-compilable/future.d(15): Deprecation: `@__future` base class method `future.A.msg` is being overridden by `future.B.msg`; rename the latter
----
- */
-
-class A
-{
- @__future char msg() { return 'a'; }
-}
-
-class B : A
-{
- char msg() { return 'b'; }
-}
-
-class C : B
-{
- override char msg() { return 'c'; }
-}
-
-class D : A
-{
- override char msg() { return 'd'; }
-}
-
-int main()
-{
- auto a = new A();
- assert(a.msg() == 'a');
- auto b = new B();
- assert(b.msg() == 'b');
- auto c = new C();
- assert(c.msg() == 'c');
- auto d = new D();
- assert(d.msg() == 'd');
-
- assert(b.A.msg() == 'a');
-
- auto ba = cast(A)b;
- assert(ba.msg() == 'a');
-
- auto da = cast(A)d;
- assert(da.msg() == 'd');
- return 0;
-}
diff --git a/gcc/testsuite/gdc.test/compilable/ident_UAX31.d b/gcc/testsuite/gdc.test/compilable/ident_UAX31.d
new file mode 100644
index 0000000..c8d579a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/ident_UAX31.d
@@ -0,0 +1,5 @@
+// REQUIRED_ARGS: -identifiers=UAX31
+
+// verify that the UAX31 identifier set is applied.
+
+int øideùnt;
diff --git a/gcc/testsuite/gdc.test/compilable/ident_all.d b/gcc/testsuite/gdc.test/compilable/ident_all.d
new file mode 100644
index 0000000..2dd9316
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/ident_all.d
@@ -0,0 +1,10 @@
+// REQUIRED_ARGS: -identifiers=all
+
+// verify that the UAX31 identifier set is applied.
+
+int øideùnt;
+int ªideµnt;
+int ¨ide¯nt;
+
+// just to play it safe, do we support one unicode then another at start?
+int øùident;
diff --git a/gcc/testsuite/gdc.test/compilable/ident_c11.d b/gcc/testsuite/gdc.test/compilable/ident_c11.d
new file mode 100644
index 0000000..8504a36
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/ident_c11.d
@@ -0,0 +1,5 @@
+// REQUIRED_ARGS: -identifiers=c11
+
+// verify that the C11 identifier set is applied.
+
+int ¨ide¯nt;
diff --git a/gcc/testsuite/gdc.test/compilable/ob1.d b/gcc/testsuite/gdc.test/compilable/ob1.d
index 720c765..bbc862e 100644
--- a/gcc/testsuite/gdc.test/compilable/ob1.d
+++ b/gcc/testsuite/gdc.test/compilable/ob1.d
@@ -147,3 +147,19 @@ struct S { int i; int* p; }
S* s = cast(S*)malloc();
free(s.p); // consumes s
}
+
+/*******************************
+ * https://issues.dlang.org/show_bug.cgi?id=21854
+ */
+
+@live void test21854()
+{
+ foreach(int tmp; 0..10) { }
+
+ int key = 0;
+ int limit = 10;
+ for (; key < limit; key += 1)
+ {
+ int tmp = key;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/returnscope_without_safe.d b/gcc/testsuite/gdc.test/compilable/returnscope_without_safe.d
new file mode 100644
index 0000000..7a84e65
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/returnscope_without_safe.d
@@ -0,0 +1,16 @@
+// Stack pointers are being escaped here, but without
+// @safe and dip1000, it should still be allowed
+// because return scope could have been inferred incorrectly,
+// and it breaks existing code:
+// https://issues.dlang.org/show_bug.cgi?id=23657
+
+int* identity(return scope int* x);
+
+auto identityAuto(int* x) => x;
+
+int* f()
+{
+ int x;
+ return identity(&x);
+ return identityAuto(&x);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/sw_transition_complex.d b/gcc/testsuite/gdc.test/compilable/sw_transition_complex.d
index b6dbc8a..3b27356 100644
--- a/gcc/testsuite/gdc.test/compilable/sw_transition_complex.d
+++ b/gcc/testsuite/gdc.test/compilable/sw_transition_complex.d
@@ -1,5 +1,5 @@
// PERMUTE_ARGS:
-// REQUIRED_ARGS: -unittest
+// REQUIRED_ARGS: -unittest -verrors=0
/*
TEST_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/compilable/test11559upgradeoptlink.d b/gcc/testsuite/gdc.test/compilable/test11559upgradeoptlink.d
index b61ffc8..774176e 100644
--- a/gcc/testsuite/gdc.test/compilable/test11559upgradeoptlink.d
+++ b/gcc/testsuite/gdc.test/compilable/test11559upgradeoptlink.d
@@ -1,7 +1,5 @@
// REQUIRED_ARGS: -g
-// If this is failing, you need optlink 8.00.14 or higher
-
string gen()
{
string m;
diff --git a/gcc/testsuite/gdc.test/compilable/test24479.d b/gcc/testsuite/gdc.test/compilable/test24479.d
new file mode 100644
index 0000000..7865c1b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test24479.d
@@ -0,0 +1,35 @@
+// https://issues.dlang.org/show_bug.cgi?id=24479
+
+/*
+TEST_OUTPUT:
+---
+1
+2
+---
+*/
+
+struct S
+{
+ @1
+ S opBinary(string op: "-")(S rhs) const pure nothrow @nogc
+ {
+ return rhs;
+ }
+ @2
+ S opBinary(string op: "*")(S dur) const pure nothrow @nogc
+ {
+ return dur;
+ }
+}
+
+private enum hasExternalUDA(alias A) = is(A == External) || is(typeof(A) == External);
+
+void foo()
+{
+ static foreach (t; __traits(getOverloads, S, "opBinary", true))
+ static foreach(attr; __traits(getAttributes, t))
+ pragma(msg, attr);
+
+ static assert(__traits(getOverloads, S, "opBinary", true).length == 2);
+ alias A = __traits(getAttributes, __traits(getOverloads, S, "opBinary", true)[1]);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test24560.d b/gcc/testsuite/gdc.test/compilable/test24560.d
new file mode 100644
index 0000000..a4a4926
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test24560.d
@@ -0,0 +1,12 @@
+// https://issues.dlang.org/show_bug.cgi?id=24560
+
+class C { }
+struct S
+{
+ static void fun(C heur = new C) { }
+}
+
+void main()
+{
+ S.fun();
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test__ctfeWrite.d b/gcc/testsuite/gdc.test/compilable/test__ctfeWrite.d
new file mode 100644
index 0000000..0f1e55f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test__ctfeWrite.d
@@ -0,0 +1,58 @@
+/*
+TEST_OUTPUT:
+---
+Hello
+World
+from
+CTFE
+Hello[1 .. 3] = el
+S.str
+abcdefghij[2 .. 6] = cdef
+---
+*/
+
+struct S
+{
+ string str = "S.str";
+ alias str this;
+}
+
+int greeting(scope const char[][] values) pure nothrow @safe @nogc
+{
+ const string newline = "\n";
+
+ foreach (const val; values)
+ {
+ __ctfeWrite(val);
+ __ctfeWrite(newline);
+ }
+
+ // Test slices
+ const val = values[0];
+ __ctfeWrite(val[]);
+ __ctfeWrite(['[','1',' ','.','.',' ','3',']',' ','=',' ']);
+ __ctfeWrite(val[1 .. 3]);
+ __ctfeWrite(newline);
+
+ S s;
+ __ctfeWrite(s);
+ __ctfeWrite(newline);
+
+ // Test mutable slices
+ char[10] buffer;
+ fill(buffer); // Avoid potential shortcuts for literals
+ __ctfeWrite(buffer[0 .. $]);
+ __ctfeWrite("[2 .. 6] = ");
+ __ctfeWrite(buffer[2 .. 6]);
+ __ctfeWrite(newline);
+
+ return 0;
+}
+
+void fill(ref char[10] buffer) pure nothrow @safe @nogc
+{
+ foreach (const idx, ref ch; buffer)
+ ch = cast(char)('a' + idx);
+}
+
+enum forceCTFE = greeting(["Hello", "World", "from", "CTFE"]);
diff --git a/gcc/testsuite/gdc.test/compilable/zerosize.d b/gcc/testsuite/gdc.test/compilable/zerosize.d
index 6e26deb..7986c92 100644
--- a/gcc/testsuite/gdc.test/compilable/zerosize.d
+++ b/gcc/testsuite/gdc.test/compilable/zerosize.d
@@ -6,10 +6,7 @@ version (CRuntime_Microsoft)
else
static assert(S.sizeof == 0);
-version (CRuntime_DigitalMars)
- static assert(S.alignof == 0);
-else
- static assert(S.alignof == 1);
+static assert(S.alignof == 1);
extern (C++) struct T { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member.d b/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member.d
new file mode 100644
index 0000000..9f3729e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member.d
@@ -0,0 +1,28 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/alias_instance_member.d(18): Error: cannot alias member of variable `that`
+fail_compilation/alias_instance_member.d(18): Use `typeof(that)` instead to preserve behaviour
+---
+*/
+
+@__edition_latest_do_not_use
+module aim;
+
+struct Foo
+{
+ int v;
+ void test(Foo that) const
+ {
+ alias a = this.v; // OK
+ alias b = that.v;
+ assert(&a is &b);
+ }
+}
+
+void main()
+{
+ Foo a = Foo(1);
+ Foo b = Foo(2);
+ a.test(b);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member2.d b/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member2.d
new file mode 100644
index 0000000..752ef14
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/alias_instance_member2.d
@@ -0,0 +1,21 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/alias_instance_member2.d(20): Error: cannot alias member of variable `f`
+fail_compilation/alias_instance_member2.d(20): Use `typeof(f)` instead to preserve behaviour
+---
+*/
+
+@__edition_latest_do_not_use
+module aim;
+
+struct Foo
+{
+ int v;
+}
+
+struct Bar
+{
+ Foo f;
+ alias v = f.v;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/bitintro.d b/gcc/testsuite/gdc.test/fail_compilation/bitintro.d
new file mode 100644
index 0000000..d58c3ea
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/bitintro.d
@@ -0,0 +1,38 @@
+/* REQUIRED_ARGS: -preview=bitfields
+ */
+
+struct S
+{
+ int a;
+ int b:5, c:6;
+}
+
+static if (0)
+{
+ pragma(msg, __traits(isBitfield, S.a));
+ pragma(msg, __traits(isBitfield, S.b));
+ pragma(msg, S.b.bitoffsetof);
+ pragma(msg, S.b.bitwidth);
+ pragma(msg, S.c.bitoffsetof);
+ pragma(msg, S.c.bitwidth);
+ pragma(msg, S.a.bitoffsetof);
+ pragma(msg, S.a.bitwidth);
+}
+
+static assert(__traits(isBitfield, S.a) == false);
+static assert(__traits(isBitfield, S.b) == true);
+static assert(S.b.bitoffsetof == 0);
+static assert(S.b.bitwidth == 5);
+static assert(S.c.bitoffsetof == 5);
+static assert(S.c.bitwidth == 6);
+
+/* TEST_OUTPUT:
+---
+fail_compilation/bitintro.d(6): Error: `a` is not a bitfield, cannot apply `bitoffsetof`
+fail_compilation/bitintro.d(37): while evaluating: `static assert(a.bitoffsetof)`
+fail_compilation/bitintro.d(6): Error: `a` is not a bitfield, cannot apply `bitwidth`
+fail_compilation/bitintro.d(38): while evaluating: `static assert(a.bitwidth)`
+---
+*/
+static assert(S.a.bitoffsetof);
+static assert(S.a.bitwidth);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/cast_qual.d b/gcc/testsuite/gdc.test/fail_compilation/cast_qual.d
new file mode 100644
index 0000000..19932f8
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/cast_qual.d
@@ -0,0 +1,19 @@
+/*
+REQUIRED_ARGS: -preview=dip1000 -de
+TEST_OUTPUT:
+---
+fail_compilation/cast_qual.d(15): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code
+fail_compilation/cast_qual.d(17): Deprecation: cast from `const(int)` to `int` cannot be used as an lvalue in @safe code
+---
+*/
+
+@safe:
+
+void main() {
+ const int i = 3;
+ int j = cast() i; // OK
+ int* p = &cast() i; // this should not compile in @safe code
+ *p = 4; // oops
+ cast() i = 5; // NG
+ auto q = &cast(const) j; // OK, int* to const int*
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecate1553.d b/gcc/testsuite/gdc.test/fail_compilation/deprecate1553.d
index 18a7152..867616c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/deprecate1553.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/deprecate1553.d
@@ -1,9 +1,7 @@
-// REQUIRED_ARGS: -de
-
/*
TEST_OUTPUT:
---
-fail_compilation/deprecate1553.d(18): Deprecation: cannot use `foreach_reverse` with a delegate
+fail_compilation/deprecate1553.d(16): Error: cannot use `foreach_reverse` with a delegate
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/editions.d b/gcc/testsuite/gdc.test/fail_compilation/editions.d
new file mode 100644
index 0000000..869ee22
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/editions.d
@@ -0,0 +1,16 @@
+/**
+Test language editions (currently experimental)
+
+TEST_OUTPUT:
+---
+fail_compilation/editions.d(15): Error: scope parameter `x` may not be returned
+---
+*/
+@__edition_latest_do_not_use
+module editions;
+
+@safe:
+int* f(scope int* x)
+{
+ return x;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/empty_statement.d b/gcc/testsuite/gdc.test/fail_compilation/empty_statement.d
new file mode 100644
index 0000000..34070d5
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/empty_statement.d
@@ -0,0 +1,14 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/empty_statement.d(11): Error: use `{ }` for an empty statement, not `;`
+fail_compilation/empty_statement.d(12): Error: use `{ }` for an empty statement, not `;`
+fail_compilation/empty_statement.d(13): Error: use `{ }` for an empty statement, not `;`
+---
+*/
+void main()
+{
+ for (;;);
+ if (0);
+ while (0);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail125.d b/gcc/testsuite/gdc.test/fail_compilation/fail125.d
index 93d176d..8a4be29 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail125.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail125.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail125.d(15): Error: array index `[2]` is outside array bounds `[0 .. 2]`
+fail_compilation/fail125.d(15): Error: sequence index `[2]` is outside bounds `[0 .. 2]`
fail_compilation/fail125.d(18): Error: template instance `fail125.main.recMove!(1, a, b)` error instantiating
fail_compilation/fail125.d(25): instantiated from here: `recMove!(0, a, b)`
---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17612.d b/gcc/testsuite/gdc.test/fail_compilation/fail17612.d
index d39dd51..a14e859 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail17612.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail17612.d
@@ -1,7 +1,9 @@
/* TEST_OUTPUT:
---
-fail_compilation/fail17612.d(14): Error: undefined identifier `string`
-fail_compilation/fail17612.d(17): Error: class `object.TypeInfo` missing or corrupt object.d
+fail_compilation/fail17612.d(16): Error: undefined identifier `string`
+fail_compilation/fail17612.d(19): Error: `TypeInfo` not found. object.d may be incorrectly installed or corrupt.
+fail_compilation/fail17612.d(19): dmd might not be correctly installed. Run 'dmd -man' for installation instructions.
+fail_compilation/fail17612.d(19): config file: not found
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail24485.d b/gcc/testsuite/gdc.test/fail_compilation/fail24485.d
new file mode 100644
index 0000000..15547cd
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail24485.d
@@ -0,0 +1,32 @@
+// https://issues.dlang.org/show_bug.cgi?id=24485
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail24485.d(25): Error: cannot implicitly convert expression `*a` of type `A` to `B`
+fail_compilation/fail24485.d(31): Error: cannot implicitly convert expression `this.a` of type `A` to `B`
+
+---
+*/
+
+struct A
+{
+ int i = 43;
+ this(ref A rhs) {}
+}
+
+struct B
+{
+ int i = 42;
+}
+
+ref B foo()
+{
+ auto a = new A;
+ return *a;
+}
+
+struct C
+{
+ A a;
+ @property ref B b() { return a; }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/foreach_index_overflow.d b/gcc/testsuite/gdc.test/fail_compilation/foreach_index_overflow.d
new file mode 100644
index 0000000..aa6baa1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/foreach_index_overflow.d
@@ -0,0 +1,28 @@
+/*
+REQUIRED_ARGS: -de -m64
+TEST_OUTPUT:
+---
+fail_compilation/foreach_index_overflow.d(19): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
+fail_compilation/foreach_index_overflow.d(21): Deprecation: foreach: loop index implicitly converted from `size_t` to `ushort`
+fail_compilation/foreach_index_overflow.d(24): Deprecation: foreach: loop index implicitly converted from `size_t` to `ubyte`
+fail_compilation/foreach_index_overflow.d(26): Deprecation: foreach: loop index implicitly converted from `size_t` to `byte`
+---
+*/
+
+void main()
+{
+ enum { red, green, blue }
+ foreach (int i, color; [red, green, blue]) {} // OK
+
+ int[] arr;
+ foreach (int index, element; arr[0 .. 0x8000_0000]) {} // OK
+ foreach (int index, element; arr[0 .. 0x8000_0001]) {} // error
+ foreach (ushort index, element; arr[0 .. 0x1_0000]) {} // OK
+ foreach (ushort index, element; arr[0 .. 0x1_0001]) {} // error
+
+ int[257] data;
+ foreach (ubyte i, x; data[]) {} // error
+ foreach (ubyte i, x; data[0..256]) {} // OK
+ foreach (byte i, x; data[0..0x81]) {} // error
+ foreach (byte i, x; data[0..0x80]) {} // OK
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice12539.d b/gcc/testsuite/gdc.test/fail_compilation/ice12539.d
index 8fab042..ad68f23 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice12539.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice12539.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ice12539.d(15): Error: array index `[0]` is outside array bounds `[0 .. 0]`
+fail_compilation/ice12539.d(15): Error: sequence index `[0]` is outside bounds `[0 .. 0]`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue24534.d b/gcc/testsuite/gdc.test/fail_compilation/issue24534.d
new file mode 100644
index 0000000..1689b6c5
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/issue24534.d
@@ -0,0 +1,25 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/issue24534.d(12): Error: `goto` skips declaration of variable `issue24534.f1.y1`
+fail_compilation/issue24534.d(13): declared here
+fail_compilation/issue24534.d(20): Error: `goto` skips declaration of variable `issue24534.f2.y2`
+fail_compilation/issue24534.d(22): declared here
+---
+*/
+void f1(){ //always failed with error about skipping a declaration
+ int x1;
+ goto Label1;
+ int y1;
+ Label1:
+ int z1;
+}
+
+void f2(){ //compiled fine before this bug was fixed
+ int x2;
+ goto Label2;
+ Dummy2:
+ int y2;
+ Label2:
+ int z2;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/lexer23465.d b/gcc/testsuite/gdc.test/fail_compilation/lexer23465.d
index 526b770..4ea41a5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/lexer23465.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/lexer23465.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/lexer23465.d(19): Error: char 0x1f37a not allowed in identifier
+fail_compilation/lexer23465.d(19): Error: character 0x1f37a is not allowed as a continue character in an identifier
fail_compilation/lexer23465.d(19): Error: character 0x1f37a is not a valid token
fail_compilation/lexer23465.d(20): Error: character '\' is not a valid token
fail_compilation/lexer23465.d(21): Error: unterminated /+ +/ comment
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ob1.d b/gcc/testsuite/gdc.test/fail_compilation/ob1.d
new file mode 100644
index 0000000..a3428f1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/ob1.d
@@ -0,0 +1,28 @@
+/* REQUIRED_ARGS: -preview=dip1021
+TEST_OUTPUT:
+---
+fail_compilation/ob1.d(23): Error: variable `ob1.mars.t` has undefined state and cannot be read
+---
+ https://issues.dlang.org/show_bug.cgi?id=21923
+*/
+
+@live:
+
+struct Handle
+{
+ private void* _handle;
+
+ this(int n);
+ ~this();
+ scope void bar();
+ static void fido(ref Handle);
+}
+
+void mars()
+{
+ auto t = Handle(10);
+ t.bar();
+ Handle.fido(t); // moves t to fido(), then destructor runs, causing error
+
+ scope u = Handle(10);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/obsolete_body.d b/gcc/testsuite/gdc.test/fail_compilation/obsolete_body.d
new file mode 100644
index 0000000..86d8bbc
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/obsolete_body.d
@@ -0,0 +1,11 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/obsolete_body.d(11): Error: usage of identifer `body` as a keyword is obsolete. Use `do` instead.
+---
+*/
+@__edition_latest_do_not_use
+module m;
+
+void test()
+in { } body { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/onemember_overloads.d b/gcc/testsuite/gdc.test/fail_compilation/onemember_overloads.d
new file mode 100644
index 0000000..40d23b3
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/onemember_overloads.d
@@ -0,0 +1,38 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/onemember_overloads.d(29): Error: none of the overloads of `skipOver` are callable using argument types `()`
+fail_compilation/onemember_overloads.d(25): Candidates are: `onemember_overloads.skipOver(string)`
+fail_compilation/onemember_overloads.d(18): `skipOver(alias pred = (a, b) => a == b)`
+fail_compilation/onemember_overloads.d(20): - Containing: `skipOver(Haystack, Needles...)(ref Haystack haystack, Needles needles)`
+fail_compilation/onemember_overloads.d(21): - Containing: `skipOver(R)(ref R r1)`
+fail_compilation/onemember_overloads.d(22): - Containing: `skipOver(R, Es...)(ref R r, Es es)`
+fail_compilation/onemember_overloads.d(30): Error: template `t2` is not callable using argument types `!()()`
+fail_compilation/onemember_overloads.d(33): Candidate is: `t2(T)`
+fail_compilation/onemember_overloads.d(35): - Containing: `t2(string)`
+fail_compilation/onemember_overloads.d(36): - Containing: `t2(int[])`
+fail_compilation/onemember_overloads.d(37): - Containing: `t2(R)(R)`
+---
+*/
+
+template skipOver(alias pred = (a, b) => a == b)
+{
+ bool skipOver(Haystack, Needles...)(ref Haystack haystack, Needles needles) => true;
+ bool skipOver(R)(ref R r1) => true;
+ bool skipOver(R, Es...)(ref R r, Es es) => true;
+}
+
+void skipOver(string);
+
+void main()
+{
+ skipOver();
+ t2();
+}
+
+template t2(T)
+{
+ bool t2(string);
+ bool t2(int[]);
+ bool t2(R)(R);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/systemvariables_bool_union.d b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_bool_union.d
new file mode 100644
index 0000000..ca6e620
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_bool_union.d
@@ -0,0 +1,22 @@
+/*
+REQUIRED_ARGS: -de
+TEST_OUTPUT:
+---
+fail_compilation/systemvariables_bool_union.d(21): Deprecation: cannot access overlapped field `Box.b` with unsafe bit patterns in `@safe` code
+---
+*/
+
+// https://issues.dlang.org/show_bug.cgi?id=24477
+
+bool schrodingersCat() @safe
+{
+ union Box
+ {
+ bool b;
+ ubyte y;
+ }
+
+ Box u;
+ u.y = 2;
+ return u.b;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/systemvariables_void_init.d b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_void_init.d
index 6f44093..ea0e55d 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/systemvariables_void_init.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/systemvariables_void_init.d
@@ -2,9 +2,13 @@
REQUIRED_ARGS: -preview=systemVariables
TEST_OUTPUT:
---
-fail_compilation/systemvariables_void_init.d(29): Error: `void` initializers for `@system` variables not allowed in safe functions
-fail_compilation/systemvariables_void_init.d(30): Error: `void` initializers for `@system` variables not allowed in safe functions
-fail_compilation/systemvariables_void_init.d(31): Error: `void` initializers for `@system` variables not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(48): Error: `void` initializers for types with unsafe bit patterns are not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(49): Error: `void` initializers for types with unsafe bit patterns are not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(50): Error: `void` initializers for types with unsafe bit patterns are not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(51): Error: a `bool` must be 0 or 1, so void intializing it is not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(52): Error: a `bool` must be 0 or 1, so void intializing it is not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(53): Error: `void` initializers for types with unsafe bit patterns are not allowed in safe functions
+fail_compilation/systemvariables_void_init.d(54): Error: `void` initializers for types with unsafe bit patterns are not allowed in safe functions
---
*/
@@ -24,9 +28,50 @@ enum E : C
x = C.init,
}
+enum B : bool
+{
+ x,
+}
+
+struct SB
+{
+ bool x;
+}
+
+struct SSB
+{
+ SB sb;
+}
+
void main() @safe
{
S s = void;
C c = void;
E e = void;
+ const bool b = void;
+ B bb = void;
+ SB sb = void;
+ SSB ssb = void;
+}
+
+// The following test is reduced from Phobos. The compiler generates this `opAssign`:
+// (CopyPreventer __swap2 = void;) , __swap2 = this , (this = p , __swap2.~this());
+// The compiler would give an error about void initialization a struct with a bool,
+// but it can be trusted in this case because it's a compiler generated temporary.
+auto staticArray(T)(T a) @safe
+{
+ T c;
+ c = a;
+}
+
+void assignmentTest() @safe
+{
+ static struct CopyPreventer
+ {
+ bool on;
+ this(this) @safe {}
+ ~this() { }
+ }
+
+ staticArray(CopyPreventer());
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test22977.d b/gcc/testsuite/gdc.test/fail_compilation/test22977.d
new file mode 100644
index 0000000..87bb19c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test22977.d
@@ -0,0 +1,56 @@
+/*
+REQUIRED_ARGS: -preview=dip1000
+TEST_OUTPUT:
+---
+fail_compilation/test22977.d(16): Error: escaping local variable through nested function `scfunc`
+fail_compilation/test22977.d(22): Error: escaping reference to stack allocated value returned by `scfunc2()`
+---
+*/
+
+// Issue 22977 - [dip1000] can escape scope pointer returned by nested function
+// https://issues.dlang.org/show_bug.cgi?id=22977
+
+auto p0(scope string s) @safe
+{
+ string scfunc() { return s; }
+ return scfunc();
+}
+
+auto p1(scope string s) @safe
+{
+ ref string scfunc2() { return s; }
+ return scfunc2();
+}
+
+// Reduced from Mir
+struct Tuple(T...)
+{
+ T expand;
+}
+
+auto autoExpandAndForward(alias value)()
+{
+ return value.expand[0];
+}
+
+struct MapIterator
+{
+ int* p;
+ int* foo() scope
+ {
+ auto t = Tuple!(int*)(p);
+ return autoExpandAndForward!t;
+ }
+}
+
+// Reduced from Phobos
+float partial(alias fun)()
+{
+ return fun();
+}
+
+auto partialFunction() @safe
+{
+ int function() f = () => 0;
+ return &partial!(f);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/funclit.d b/gcc/testsuite/gdc.test/runnable/funclit.d
index c4b70dc..253df8f 100644
--- a/gcc/testsuite/gdc.test/runnable/funclit.d
+++ b/gcc/testsuite/gdc.test/runnable/funclit.d
@@ -1302,6 +1302,17 @@ void test16271()
T!().auf() = 2; assert(T!().x == 2);
}
+// https://issues.dlang.org/show_bug.cgi?id=24525
+void test24525()
+{
+ int a;
+ auto ref () {return a;}() = 1;
+ assert(a == 1);
+
+ ref () {return a;}() = 2;
+ assert(a == 2);
+}
+
/***************************************************/
int main()
@@ -1361,6 +1372,7 @@ int main()
test14745();
test15794();
test16271();
+ test24525();
printf("Success\n");
return 0;
diff --git a/gcc/testsuite/gdc.test/runnable/future.d b/gcc/testsuite/gdc.test/runnable/future.d
index 1a91d30..e0ef466 100644
--- a/gcc/testsuite/gdc.test/runnable/future.d
+++ b/gcc/testsuite/gdc.test/runnable/future.d
@@ -1,7 +1,8 @@
/* PERMUTE_ARGS:
TEST_OUTPUT:
---
-runnable/future.d(15): Deprecation: `@__future` base class method `future.A.msg` is being overridden by `future.B.msg`; rename the latter
+runnable/future.d(16): Deprecation: method `future.B.msg` implicitly overrides `@__future` base class method; rename the former
+runnable/future.d(11): base method `future.A.msg` defined here
---
*/
diff --git a/gcc/testsuite/gdc.test/runnable/imports/issue18919b.d b/gcc/testsuite/gdc.test/runnable/imports/issue18919b.d
index 4278f7f..b009298 100644
--- a/gcc/testsuite/gdc.test/runnable/imports/issue18919b.d
+++ b/gcc/testsuite/gdc.test/runnable/imports/issue18919b.d
@@ -248,3 +248,9 @@ void func12(const(char)*[] args = [baseName(__FILE__.ptr),
printf(" %s", arg);
printf("\n");
}
+
+// https://issues.dlang.org/show_bug.cgi?id=24519
+void func13(string file = __FILE__[])
+{
+ printf("%s: %s\n", __FUNCTION__.ptr, file.ptr);
+}
diff --git a/gcc/testsuite/gdc.test/runnable/issue18919.d b/gcc/testsuite/gdc.test/runnable/issue18919.d
index 815e018..9f3df62 100644
--- a/gcc/testsuite/gdc.test/runnable/issue18919.d
+++ b/gcc/testsuite/gdc.test/runnable/issue18919.d
@@ -20,10 +20,13 @@ imports.issue18919b.func9.fp: issue18919b.d:216 imports.issue18919b
imports.issue18919b.func10: expr1=imports.issue18919b, expr2=imports.issue18919b
imports.issue18919b.func11: issue18919b.d:233 imports.issue18919b
imports.issue18919b.func12: issue18919.d issue18919.main void issue18919.main() issue18919
+imports.issue18919b.func13: runnable/issue18919.d
---
*/
import imports.issue18919b;
+#line 26
+
void main()
{
func1();
@@ -44,4 +47,5 @@ void main()
func10();
func11();
func12();
+ func13();
}
diff --git a/gcc/testsuite/gdc.test/runnable/test15.d b/gcc/testsuite/gdc.test/runnable/test15.d
index b4acc23..bb9fc87 100644
--- a/gcc/testsuite/gdc.test/runnable/test15.d
+++ b/gcc/testsuite/gdc.test/runnable/test15.d
@@ -1420,7 +1420,7 @@ void test19758()
/************************************/
// https://issues.dlang.org/show_bug.cgi?id=19968
-@safe void test19968()
+void test19968()
{
int[2] array = [16, 678];
union U { int i; bool b; }
diff --git a/gcc/testsuite/gdc.test/runnable/test17338.d b/gcc/testsuite/gdc.test/runnable/test17338.d
index 1c937be..746a1df 100644
--- a/gcc/testsuite/gdc.test/runnable/test17338.d
+++ b/gcc/testsuite/gdc.test/runnable/test17338.d
@@ -3,9 +3,6 @@
// COMDAT folding increases runtime by > 80x
// REQUIRED_ARGS(windows): -L/OPT:NOICF
-// Apparently omf or optlink does not support more than 32767 symbols.
-// DISABLED: win32
-
// Generate \sum_{i=0}^{14} 2^i = 32767 template instantiations
// (each with 3 sections) to use more than 64Ki sections in total.
diff --git a/gcc/testsuite/gdc.test/runnable/test24029.c b/gcc/testsuite/gdc.test/runnable/test24029.c
deleted file mode 100644
index 145f2c2..0000000
--- a/gcc/testsuite/gdc.test/runnable/test24029.c
+++ /dev/null
@@ -1,23 +0,0 @@
-// https://issues.dlang.org/show_bug.cgi?id=24029
-
-int x = 0;
-int y = 0;
-
-void a()
-{
- (__extension__ ({ x += 2; })); // test.a.__dgliteral1
-}
-
-void b()
-{
- (__extension__ ({ y += 1; })); // test.b.__dgliteral1
-}
-
-int main(void)
-{
- a();
- b();
- __check(x == 2);
- __check(y == 1);
- return 0;
-}
diff --git a/gcc/testsuite/gdc.test/runnable/test24498.d b/gcc/testsuite/gdc.test/runnable/test24498.d
new file mode 100644
index 0000000..6c48e26
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test24498.d
@@ -0,0 +1,21 @@
+import core.memory;
+
+void main()
+{
+ {
+ int[][] a = new int[][](2, 2);
+ assert(!(GC.getAttr(a.ptr) & GC.BlkAttr.NO_SCAN));
+ assert(GC.getAttr(a[0].ptr) & GC.BlkAttr.NO_SCAN);
+ }
+ {
+ void*[][] a = new void*[][](2, 2);
+ assert(!(GC.getAttr(a.ptr) & GC.BlkAttr.NO_SCAN));
+ assert(!(GC.getAttr(a[0].ptr) & GC.BlkAttr.NO_SCAN));
+ }
+ {
+ int[][][] a = new int[][][](2, 2);
+ assert(!(GC.getAttr(a.ptr) & GC.BlkAttr.NO_SCAN));
+ assert(!(GC.getAttr(a[0].ptr) & GC.BlkAttr.NO_SCAN));
+ assert(a[0][0].ptr is null);
+ }
+}
diff --git a/gcc/testsuite/gdc.test/runnable/testthread.d b/gcc/testsuite/gdc.test/runnable/testthread.d
index 139a891..811b6c2 100644
--- a/gcc/testsuite/gdc.test/runnable/testthread.d
+++ b/gcc/testsuite/gdc.test/runnable/testthread.d
@@ -3,15 +3,6 @@
import core.stdc.stdio;
import core.thread;
-version (CRuntime_DigitalMars)
-{
- extern (C)
- {
- extern int _tlsstart;
- extern int _tlsend;
- }
-}
-
int tlsx;
class Foo
@@ -25,8 +16,6 @@ class Foo
tlsx = 5;
Thread t = Thread.getThis();
- version (CRuntime_DigitalMars)
- printf("thread ptr=%p, %p &tlsx = %p %p\n", t, &_tlsstart, &tlsx, &_tlsend);
x = 3;
printf("-bar()\n");
}
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d b/gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
index c0f4e6d..5d4bc99 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
+++ b/gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
@@ -272,7 +272,6 @@ void main()
foreach(byte val; values!byte()) check(val);
foreach(ubyte val; values!ubyte()) check(val);
foreach(char val; values!char()) check(val);
-version(CppRuntime_DigitalMars){} else
version(CppRuntime_Microsoft)
{
// TODO: figure out how to detect VS2013 which doesn't support char16_t/char32_t
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
index cb268af..34c2955 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
+++ b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
@@ -8,9 +8,6 @@
// N.B MSVC doesn't have a C++11 switch, but it defaults to the latest fully-supported standard
-// Broken for unknown reasons since the OMF => MsCOFF switch
-// DISABLED: win32omf
-
import core.stdc.stdio;
import core.stdc.stdarg;
import core.stdc.config;
@@ -908,9 +905,7 @@ void fuzz2()
}
////////
-version(CppRuntime_DigitalMars)
- enum UNICODE = false;
-else version(CppRuntime_Microsoft)
+version(CppRuntime_Microsoft)
enum UNICODE = false; //VS2013 doesn't support them
else
enum UNICODE = true;
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/externmangle.d b/gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
index ef132dc..266cad9 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
+++ b/gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
@@ -239,39 +239,31 @@ void test39()
extern(C++, "foo", "bar", "baz") int doStuff(int);
-version(CppRuntime_DigitalMars) // DMC doesn't support c++11
-{
- void test40() {}
- void test41() {}
-}
-else
-{
- void test40();
+void test40();
- void foovargs(T...)(T args)
+void foovargs(T...)(T args)
+{
+ static if (is(T[0] == char*))
{
- static if (is(T[0] == char*))
- {
- assert(*args[0] == 'a');
- }
- else
- {
- float ret = args[0] + args[1];
- assert(ret == 3.0f);
- }
+ assert(*args[0] == 'a');
}
-
- alias FooVargs = foovargs!(int, float);
- alias FooVargs2 = foovargs!(char*);
-
- void test41();
- void make_shared_poc(T, Args...)(ref Args args)
+ else
{
- assert(args[0] + args[1] == 3);
+ float ret = args[0] + args[1];
+ assert(ret == 3.0f);
}
- alias Make_Shared_Poc = make_shared_poc!(int, int, int);
}
+alias FooVargs = foovargs!(int, float);
+alias FooVargs2 = foovargs!(char*);
+
+void test41();
+void make_shared_poc(T, Args...)(ref Args args)
+{
+ assert(args[0] + args[1] == 3);
+}
+alias Make_Shared_Poc = make_shared_poc!(int, int, int);
+
void main()
{
test1(Foo!int());
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp7925.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp7925.cpp
index f3a9a85..282faec 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp7925.cpp
+++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp7925.cpp
@@ -90,14 +90,10 @@ void runCPPTests()
int (C2::*fp1)(int) = &C2::f1;
int (C2::*fp2)(int, int) = &C2::f2;
int (C2::*fp3)(int, int) = &C2::f3;
-#ifndef __DMC__
int (C2::*fp4)(int, ...) = &C2::f4;
-#endif
assert((c2->*(fp0))() == 100);
assert((c2->*(fp1))(1) == 101);
assert((c2->*(fp2))(20, 3) == 123);
assert((c2->*(fp3))(20, 3) == 123);
-#ifndef __DMC__
assert((c2->*(fp4))(20, 3, 0) == 123);
-#endif
}
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
index e1dcc28..cbde233 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
+++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
@@ -10,9 +10,7 @@ namespace std
struct test19248 {int a;};
};
-#ifdef __DMC__
-// DMC doesn't support c++11
-#elif defined (_MSC_VER) && _MSC_VER <= 1800
+#if defined (_MSC_VER) && _MSC_VER <= 1800
// MSVC2013 doesn't support char16_t/char32_t
#else
#define TEST_UNICODE
@@ -26,11 +24,7 @@ struct S18784
S18784::S18784(int n) : i(n) {}
-#ifdef __DMC__ // DMC doesn't support c++11
-template <class>
-#else
template <class...>
-#endif
struct SPack
{
int i;
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
index 83667cb..f91dfe8 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
+++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
@@ -374,9 +374,7 @@ wchar_t f13289_cpp_wchar_t(wchar_t ch)
return ch;
}
}
-#ifdef __DMC__
-// DMC doesn't support c++11
-#elif defined (_MSC_VER) //&& _MSC_VER <= 1800
+#if defined (_MSC_VER) //&& _MSC_VER <= 1800
// MSVC2013 doesn't support char16_t/char32_t
#else
#define TEST_UNICODE
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
index 37c98ea..df10a9c 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
+++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
@@ -426,7 +426,6 @@ namespace foo
}
}
-#ifndef __DMC__ // DMC doesn't support c++11
template<typename ...T> void foovargs(T... args);
void test40()
@@ -446,4 +445,3 @@ void test41()
make_shared_poc<int, int, int>(a, b);
}
-#endif
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test20652.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test20652.cpp
index 91ab66a..b35b3f5 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test20652.cpp
+++ b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/test20652.cpp
@@ -1,6 +1,3 @@
-#if defined(__DMC__) // DMC doesn't support immintrin.h
-#else
-
#include <assert.h>
// Inline the typedef of __m128 instead of including immintrin.h.
@@ -30,5 +27,3 @@ void test20652(const __m128& a)
assert(b.array[2] == 1);
assert(b.array[3] == 1);
}
-
-#endif
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/test20652.d b/gcc/testsuite/gdc.test/runnable_cxx/test20652.d
index 68bb0a7..a4962f6 100644
--- a/gcc/testsuite/gdc.test/runnable_cxx/test20652.d
+++ b/gcc/testsuite/gdc.test/runnable_cxx/test20652.d
@@ -3,11 +3,7 @@
import core.simd;
-version (CRuntime_DigitalMars) // DMC doesn't support immintrin.h
-{
- void main() {}
-}
-else static if (!__traits(compiles, float4)) // No __vector support
+static if (!__traits(compiles, float4)) // No __vector support
{
void main() {}
}