aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-07-21 19:32:54 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-08-03 04:40:18 +0200
commit442b5a661e312b27fc87f769834a2b58412a847a (patch)
tree493216f398cb16044a59d39fdebb97a6d683baef /gcc/d/dmd
parent7031087cd7d6cd07d18797b0cac90dc048103ed1 (diff)
downloadgcc-442b5a661e312b27fc87f769834a2b58412a847a.zip
gcc-442b5a661e312b27fc87f769834a2b58412a847a.tar.gz
gcc-442b5a661e312b27fc87f769834a2b58412a847a.tar.bz2
d: Merge upstream dmd c2274e56a (PR96250).
1. Fixes an ICE in the front-end if a struct symbol were to appear twice in the compilation unit. 2. Fixes a rejects-valid bug in the front-end where `(symbol)' was being resolved as a `var' expression, instead of `this.var'. Reviewed-on: https://github.com/dlang/dmd/pull/11436 https://github.com/dlang/dmd/pull/11439 gcc/d/ChangeLog: PR d/96250 * dmd/MERGE: Merge upstream dmd c2274e56a.
Diffstat (limited to 'gcc/d/dmd')
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/dstruct.c9
-rw-r--r--gcc/d/dmd/expressionsem.c10
-rw-r--r--gcc/d/dmd/parse.c1
4 files changed, 19 insertions, 3 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index b99e9f3..daa3e56 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-8508c4e683f065eb3deab76b610f7fecb3258a8e
+c2274e56a3220ea636c6199fd06cd54fcdf6bad9
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/dstruct.c b/gcc/d/dmd/dstruct.c
index 86bb6c8..2b87154 100644
--- a/gcc/d/dmd/dstruct.c
+++ b/gcc/d/dmd/dstruct.c
@@ -1206,6 +1206,13 @@ void StructDeclaration::semantic(Scope *sc)
}
}
+ if (type->ty == Tstruct && ((TypeStruct *)type)->sym != this)
+ {
+ // https://issues.dlang.org/show_bug.cgi?id=19024
+ StructDeclaration *sd = ((TypeStruct *)type)->sym;
+ error("already exists at %s. Perhaps in another function with the same name?", sd->loc.toChars());
+ }
+
if (global.errors != errors)
{
// The type is no good.
@@ -1220,8 +1227,6 @@ void StructDeclaration::semantic(Scope *sc)
deferred->semantic2(sc);
deferred->semantic3(sc);
}
-
- assert(type->ty != Tstruct || ((TypeStruct *)type)->sym == this);
}
Dsymbol *StructDeclaration::search(const Loc &loc, Identifier *ident, int flags)
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index ac6b5bc..9f21dab 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -812,6 +812,16 @@ public:
exp->type->resolve(exp->loc, sc, &e, &t, &s, true);
if (e)
{
+ // `(Type)` is actually `(var)` so if `(var)` is a member requiring `this`
+ // then rewrite as `(this.var)` in case it would be followed by a DotVar
+ // to fix https://issues.dlang.org/show_bug.cgi?id=9490
+ VarExp *ve = e->isVarExp();
+ if (ve && ve->var && exp->parens && !ve->var->isStatic() && !(sc->stc & STCstatic) &&
+ sc->func && sc->func->needThis() && ve->var->toParent2()->isAggregateDeclaration())
+ {
+ // printf("apply fix for issue 9490: add `this.` to `%s`...\n", e->toChars());
+ e = new DotVarExp(exp->loc, new ThisExp(exp->loc), ve->var, false);
+ }
//printf("e = %s %s\n", Token::toChars(e->op), e->toChars());
e = semantic(e, sc);
}
diff --git a/gcc/d/dmd/parse.c b/gcc/d/dmd/parse.c
index f4cd28e..d1017ac 100644
--- a/gcc/d/dmd/parse.c
+++ b/gcc/d/dmd/parse.c
@@ -7531,6 +7531,7 @@ Expression *Parser::parseUnaryExp()
return NULL;
}
e = new TypeExp(loc, t);
+ e->parens = 1;
e = parsePostExp(e);
}
else