aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-04-05 14:05:28 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-04-06 19:43:30 +0200
commitdddf3bb0c37e8ff7f2c0488a46edfa18716d8a00 (patch)
treeeced0751b8257b387c90eb2d1a0ac72a779a7d8b /gcc/d
parent406f58e1e38e92e4b881f3666b596843da308783 (diff)
downloadgcc-dddf3bb0c37e8ff7f2c0488a46edfa18716d8a00.zip
gcc-dddf3bb0c37e8ff7f2c0488a46edfa18716d8a00.tar.gz
gcc-dddf3bb0c37e8ff7f2c0488a46edfa18716d8a00.tar.bz2
d: Merge upstream dmd 5cc71ff83, druntime 1134b710
D front-end changes: - Fix ICEs that occurred when using opaque enums. - Update `pragma(printf)' checking code to work on 16-bit targets. Phobos change: - Don't compile in argTypes code on AArch64 Reviewed-on: https://github.com/dlang/dmd/pull/12378 https://github.com/dlang/druntime/pull/3431 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 5cc71ff83. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 1134b710.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/chkformat.c44
-rw-r--r--gcc/d/dmd/denum.c54
-rw-r--r--gcc/d/dmd/dsymbolsem.c17
-rw-r--r--gcc/d/dmd/mtype.c17
5 files changed, 77 insertions, 57 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 86475c8..a891844 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-3b808e838bb00f527eb4ed5281cd985756237b8f
+5cc71ff830fcfba218152360014298550be9180e
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/chkformat.c b/gcc/d/dmd/chkformat.c
index d00b658..a4a97c9 100644
--- a/gcc/d/dmd/chkformat.c
+++ b/gcc/d/dmd/chkformat.c
@@ -610,7 +610,7 @@ bool checkPrintfFormat(const Loc &loc, const char *format, Expressions &args, bo
Type *t = e->type->toBasetype();
Type *tnext = t->nextOf();
const unsigned c_longsize = target.c.longsize;
- const bool is64bit = global.params.is64bit;
+ const unsigned ptrsize = target.ptrsize;
// Types which are promoted to int are allowed.
// Spec: C99 6.5.2.2.7
@@ -619,46 +619,56 @@ bool checkPrintfFormat(const Loc &loc, const char *format, Expressions &args, bo
case Format_u: // unsigned int
case Format_d: // int
if (t->ty != Tint32 && t->ty != Tuns32)
- errorPrintfFormat(NULL, slice, e, "int", t);
+ errorPrintfFormat(NULL, slice, e, fmt == Format_u ? "uint" : "int", t);
break;
case Format_hhu: // unsigned char
case Format_hhd: // signed char
if (t->ty != Tint32 && t->ty != Tuns32 && t->ty != Tint8 && t->ty != Tuns8)
- errorPrintfFormat(NULL, slice, e, "byte", t);
+ errorPrintfFormat(NULL, slice, e, fmt == Format_hhu ? "ubyte" : "byte", t);
break;
case Format_hu: // unsigned short int
case Format_hd: // short int
if (t->ty != Tint32 && t->ty != Tuns32 && t->ty != Tint16 && t->ty != Tuns16)
- errorPrintfFormat(NULL, slice, e, "short", t);
+ errorPrintfFormat(NULL, slice, e, fmt == Format_hu ? "ushort" : "short", t);
break;
case Format_lu: // unsigned long int
case Format_ld: // long int
if (!(t->isintegral() && t->size() == c_longsize))
- errorPrintfFormat(NULL, slice, e, (c_longsize == 4 ? "int" : "long"), t);
+ {
+ if (fmt == Format_lu)
+ errorPrintfFormat(NULL, slice, e, (c_longsize == 4 ? "uint" : "ulong"), t);
+ else
+ errorPrintfFormat(NULL, slice, e, (c_longsize == 4 ? "int" : "long"), t);
+ }
break;
case Format_llu: // unsigned long long int
case Format_lld: // long long int
if (t->ty != Tint64 && t->ty != Tuns64)
- errorPrintfFormat(NULL, slice, e, "long", t);
+ errorPrintfFormat(NULL, slice, e, fmt == Format_llu ? "ulong" : "long", t);
break;
case Format_ju: // uintmax_t
case Format_jd: // intmax_t
if (t->ty != Tint64 && t->ty != Tuns64)
- errorPrintfFormat(NULL, slice, e, "core.stdc.stdint.intmax_t", t);
+ {
+ if (fmt == Format_ju)
+ errorPrintfFormat(NULL, slice, e, "core.stdc.stdint.uintmax_t", t);
+ else
+ errorPrintfFormat(NULL, slice, e, "core.stdc.stdint.intmax_t", t);
+ }
break;
case Format_zd: // size_t
- if (!(t->isintegral() && t->size() == (is64bit ? 8 : 4)))
+ if (!(t->isintegral() && t->size() == ptrsize))
errorPrintfFormat(NULL, slice, e, "size_t", t);
break;
case Format_td: // ptrdiff_t
- if (!(t->isintegral() && t->size() == (is64bit ? 8 : 4)))
+ if (!(t->isintegral() && t->size() == ptrsize))
errorPrintfFormat(NULL, slice, e, "ptrdiff_t", t);
break;
@@ -685,7 +695,7 @@ bool checkPrintfFormat(const Loc &loc, const char *format, Expressions &args, bo
break;
case Format_ln: // pointer to long int
- if (!(t->ty == Tpointer && tnext->isintegral() && tnext->size() == c_longsize))
+ if (!(t->ty == Tpointer && tnext->isintegral() && !tnext->isunsigned() && tnext->size() == c_longsize))
errorPrintfFormat(NULL, slice, e, (c_longsize == 4 ? "int*" : "long*"), t);
break;
@@ -710,12 +720,12 @@ bool checkPrintfFormat(const Loc &loc, const char *format, Expressions &args, bo
break;
case Format_zn: // pointer to size_t
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tuns64 : Tuns32)))
+ if (!(t->ty == Tpointer && tnext->isintegral() && tnext->isunsigned() && tnext->size() == ptrsize))
errorPrintfFormat(NULL, slice, e, "size_t*", t);
break;
case Format_tn: // pointer to ptrdiff_t
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tint64 : Tint32)))
+ if (!(t->ty == Tpointer && tnext->isintegral() && !tnext->isunsigned() && tnext->size() == ptrsize))
errorPrintfFormat(NULL, slice, e, "ptrdiff_t*", t);
break;
@@ -845,7 +855,7 @@ bool checkScanfFormat(const Loc &loc, const char *format, Expressions &args, boo
Type *t = e->type->toBasetype();
Type *tnext = t->nextOf();
const unsigned c_longsize = target.c.longsize;
- const bool is64bit = global.params.is64bit;
+ const unsigned ptrsize = target.ptrsize;
switch (fmt)
{
@@ -887,13 +897,13 @@ bool checkScanfFormat(const Loc &loc, const char *format, Expressions &args, boo
case Format_zn:
case Format_zd: // pointer to size_t
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tuns64 : Tuns32)))
+ if (!(t->ty == Tpointer && tnext->isintegral() && tnext->isunsigned() && tnext->size() == ptrsize))
errorScanfFormat(NULL, slice, e, "size_t*", t);
break;
case Format_tn:
case Format_td: // pointer to ptrdiff_t
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tint64 : Tint32)))
+ if (!(t->ty == Tpointer && tnext->isintegral() && !tnext->isunsigned() && tnext->size() == ptrsize))
errorScanfFormat(NULL, slice, e, "ptrdiff_t*", t);
break;
@@ -913,7 +923,7 @@ bool checkScanfFormat(const Loc &loc, const char *format, Expressions &args, boo
break;
case Format_lu: // pointer to unsigned long int
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tuns64 : Tuns32)))
+ if (!(t->ty == Tpointer && tnext->isintegral() && tnext->isunsigned() && tnext->size() == c_longsize))
errorScanfFormat(NULL, slice, e, (c_longsize == 4 ? "uint*" : "ulong*"), t);
break;
@@ -923,7 +933,7 @@ bool checkScanfFormat(const Loc &loc, const char *format, Expressions &args, boo
break;
case Format_ju: // pointer to uintmax_t
- if (!(t->ty == Tpointer && tnext->ty == (is64bit ? Tuns64 : Tuns32)))
+ if (!(t->ty == Tpointer && tnext->ty == Tuns64))
errorScanfFormat(NULL, slice, e, "ulong*", t);
break;
diff --git a/gcc/d/dmd/denum.c b/gcc/d/dmd/denum.c
index bfd3b72..b00eaa0 100644
--- a/gcc/d/dmd/denum.c
+++ b/gcc/d/dmd/denum.c
@@ -122,7 +122,7 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id)
dsymbolSemantic(this, _scope);
if (errors)
goto Lerrors;
- if (semanticRun == PASSinit || !members)
+ if (!members)
{
if (isSpecial())
{
@@ -131,7 +131,7 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id)
return memtype->getProperty(loc, id, 0);
}
- error("is forward referenced looking for .%s", id->toChars());
+ error(loc, "is opaque and has no `.%s`", id->toChars());
goto Lerrors;
}
if (!(memtype && memtype->isintegral()))
@@ -148,12 +148,21 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id)
if (!em)
continue;
if (em->errors)
- goto Lerrors;
+ {
+ errors = true;
+ continue;
+ }
+
+ if (em->semanticRun < PASSsemanticdone)
+ {
+ em->error("is forward referenced looking for `.%s`", id->toChars());
+ errors = true;
+ continue;
+ }
- Expression *e = em->value();
if (first)
{
- *pval = e;
+ *pval = em->value();
first = false;
}
else
@@ -168,15 +177,23 @@ Expression *EnumDeclaration::getMaxMinValue(Loc loc, Identifier *id)
* if (e > maxval)
* maxval = e;
*/
+ Expression *e = em->value();
Expression *ec = new CmpExp(id == Id::max ? TOKgt : TOKlt, em->loc, e, *pval);
inuse++;
ec = expressionSemantic(ec, em->_scope);
inuse--;
ec = ec->ctfeInterpret();
+ if (ec->op == TOKerror)
+ {
+ errors = true;
+ continue;
+ }
if (ec->toInteger())
*pval = e;
}
}
+ if (errors)
+ goto Lerrors;
Ldone:
{
Expression *e = *pval;
@@ -213,16 +230,17 @@ Expression *EnumDeclaration::getDefaultValue(Loc loc)
dsymbolSemantic(this, _scope);
if (errors)
goto Lerrors;
- if (semanticRun == PASSinit || !members)
+ if (!members)
{
if (isSpecial())
{
/* Allow these special enums to not need a member list
*/
- return memtype->defaultInit(loc);
+ defaultval = memtype->defaultInit(loc);
+ return defaultval;
}
- error(loc, "forward reference of %s.init", toChars());
+ error(loc, "is opaque and has no default initializer");
goto Lerrors;
}
@@ -231,6 +249,12 @@ Expression *EnumDeclaration::getDefaultValue(Loc loc)
EnumMember *em = (*members)[i]->isEnumMember();
if (em)
{
+ if (em->semanticRun < PASSsemanticdone)
+ {
+ error(loc, "forward reference of `%s.init`", toChars());
+ goto Lerrors;
+ }
+
defaultval = em->value();
return defaultval;
}
@@ -252,15 +276,10 @@ Type *EnumDeclaration::getMemtype(Loc loc)
*/
if (memtype)
memtype = typeSemantic(memtype, loc, _scope);
- else
- {
- if (!isAnonymous() && members)
- memtype = Type::tint32;
- }
}
if (!memtype)
{
- if (!isAnonymous() && members)
+ if (!isAnonymous() && (members || semanticRun >= PASSsemanticdone))
memtype = Type::tint32;
else
{
@@ -307,13 +326,6 @@ Dsymbol *EnumDeclaration::search(const Loc &loc, Identifier *ident, int flags)
dsymbolSemantic(this, _scope);
}
- if (!members || !symtab || _scope)
- {
- error("is forward referenced when looking for `%s`", ident->toChars());
- //*(char*)0=0;
- return NULL;
- }
-
Dsymbol *s = ScopeDsymbol::search(loc, ident, flags);
return s;
}
diff --git a/gcc/d/dmd/dsymbolsem.c b/gcc/d/dmd/dsymbolsem.c
index 26e23e9..7e1a858 100644
--- a/gcc/d/dmd/dsymbolsem.c
+++ b/gcc/d/dmd/dsymbolsem.c
@@ -415,7 +415,19 @@ public:
TypeStruct *ts = (TypeStruct *)tb;
if (!ts->sym->members)
{
- dsym->error("no definition of struct %s", ts->toChars());
+ dsym->error("no definition of struct `%s`", ts->toChars());
+
+ // Explain why the definition is required when it's part of another type
+ if (!dsym->type->isTypeStruct())
+ {
+ // Prefer Loc of the dependant type
+ Dsymbol *s = dsym->type->toDsymbol(sc);
+ Loc loc = s ? s->loc : dsym->loc;
+ errorSupplemental(loc, "required by type `%s`", dsym->type->toChars());
+ }
+
+ // Flag variable as error to avoid invalid error messages due to unknown size
+ dsym->type = Type::terror;
}
}
if ((dsym->storage_class & STCauto) && !inferred)
@@ -1737,6 +1749,9 @@ public:
ed->semanticRun = PASSinit;
return;
}
+ else
+ // Ensure that semantic is run to detect. e.g. invalid forward references
+ dsymbolSemantic(sym, sc);
}
if (ed->memtype->ty == Tvoid)
{
diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c
index 6b01999..57aa244 100644
--- a/gcc/d/dmd/mtype.c
+++ b/gcc/d/dmd/mtype.c
@@ -6806,23 +6806,6 @@ Expression *TypeEnum::dotExp(Scope *sc, Expression *e, Identifier *ident, int fl
if (sym->semanticRun < PASSsemanticdone)
dsymbolSemantic(sym, NULL);
- if (!sym->members)
- {
- if (sym->isSpecial())
- {
- /* Special enums forward to the base type
- */
- e = sym->memtype->dotExp(sc, e, ident, flag);
- }
- else if (!(flag & 1))
- {
- sym->error("is forward referenced when looking for `%s`", ident->toChars());
- e = new ErrorExp();
- }
- else
- e = NULL;
- return e;
- }
Dsymbol *s = sym->search(e->loc, ident);
if (!s)