aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gcc.gnu.org>2019-06-16 07:49:18 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2019-06-16 07:49:18 +0000
commite5338b0449f4382594c86ec0f3ea6d9958aeeef5 (patch)
tree62bbe6883a0c080b16d928e0125af0935eba8d7d
parent88ad43b1f91f7cd2ba9c342c6c1a6da82e6088bf (diff)
downloadgcc-e5338b0449f4382594c86ec0f3ea6d9958aeeef5.zip
gcc-e5338b0449f4382594c86ec0f3ea6d9958aeeef5.tar.gz
gcc-e5338b0449f4382594c86ec0f3ea6d9958aeeef5.tar.bz2
re PR d/90761 (ICE in visit, at d/dmd/dcast.c:883)
PR d/90761 d/dmd: Merge upstream dmd d912f4e49 Fixes segmentation fault in implicitConvTo::ImplicitConvTo::visit. Reviewed-on: https://github.com/dlang/dmd/pull/10005 From-SVN: r272346
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/expressionsem.c18
-rw-r--r--gcc/testsuite/gdc.test/compilable/test19941.d57
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail19941.d62
4 files changed, 138 insertions, 1 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 7b46e8f..865462d 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-3be8a80bb0c4e01c436be970ac3555ceabb3caf8
+d912f4e495412b67f0a2e3b07f645909cfee0212
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index 5177f9f..2957c09 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -75,6 +75,7 @@ Expression *semantic(Expression *e, Scope *sc);
Expression *semanticY(DotIdExp *exp, Scope *sc, int flag);
Expression *semanticY(DotTemplateInstanceExp *exp, Scope *sc, int flag);
StringExp *semanticString(Scope *sc, Expression *exp, const char *s);
+Initializer *semantic(Initializer *init, Scope *sc, Type *t, NeedInterpret needInterpret);
/****************************************
* Preprocess arguments to function.
@@ -1226,6 +1227,23 @@ public:
exp->error("no constructor for %s", cd->toChars());
return setError();
}
+
+ // https://issues.dlang.org/show_bug.cgi?id=19941
+ // Run semantic on all field initializers to resolve any forward
+ // references. This is the same as done for structs in sd->fill().
+ for (ClassDeclaration *c = cd; c; c = c->baseClass)
+ {
+ for (size_t i = 0; i < c->fields.dim; i++)
+ {
+ VarDeclaration *v = c->fields[i];
+ if (v->inuse || v->_scope == NULL || v->_init == NULL ||
+ v->_init->isVoidInitializer())
+ continue;
+ v->inuse++;
+ v->_init = semantic(v->_init, v->_scope, v->type, INITinterpret);
+ v->inuse--;
+ }
+ }
}
}
else if (tb->ty == Tstruct)
diff --git a/gcc/testsuite/gdc.test/compilable/test19941.d b/gcc/testsuite/gdc.test/compilable/test19941.d
new file mode 100644
index 0000000..add1d41
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test19941.d
@@ -0,0 +1,57 @@
+// https://issues.dlang.org/show_bug.cgi?id=19941
+
+/******************************************/
+
+immutable i4 = 42;
+const v4 = new C4;
+class C4 { int f4 = i4; }
+
+const v5 = new C5;
+immutable i5 = 42;
+class C5 { int f5 = i5; }
+
+const v6 = new C6;
+class C6 { int f6 = i6; }
+immutable i6 = 42;
+
+/******************************************/
+
+immutable i10 = 42;
+__gshared v10 = new C10;
+class C10 { int f10 = i10; }
+
+__gshared v11 = new C11;
+immutable i11 = 42;
+class C11 { int f11 = i11; }
+
+__gshared v12 = new C12;
+class C12 { int f12 = i12; }
+immutable i12 = 42;
+
+/******************************************/
+
+immutable i13 = 42;
+immutable v13 = new C13;
+class C13 { int f13 = i13; }
+
+immutable v14 = new C14;
+immutable i14 = 42;
+class C14 { int f14 = i14; }
+
+immutable v15 = new C15;
+class C15 { int f15 = i15; }
+immutable i15 = 42;
+
+/******************************************/
+
+immutable i16 = 42;
+shared v16 = new C16;
+class C16 { int f16 = i16; }
+
+shared v17 = new C17;
+immutable i17 = 42;
+class C17 { int f17 = i17; }
+
+shared v18 = new C18;
+class C18 { int f18 = i18; }
+immutable i18 = 42;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail19941.d b/gcc/testsuite/gdc.test/fail_compilation/fail19941.d
new file mode 100644
index 0000000..61e174b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail19941.d
@@ -0,0 +1,62 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(8): Error: undefined identifier `dne`
+---
+*/
+auto a = new Auto;
+class Auto { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(17): Error: undefined identifier `dne`
+---
+*/
+const c = new Const;
+class Const { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(26): Error: undefined identifier `dne`
+---
+*/
+enum e = new Enum;
+class Enum { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(35): Error: undefined identifier `dne`
+---
+*/
+__gshared g = new Gshared;
+class Gshared { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(44): Error: undefined identifier `dne`
+---
+*/
+immutable i = new Immutable;
+class Immutable { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(53): Error: undefined identifier `dne`
+---
+*/
+shared s = new Shared;
+class Shared { int field = &dne; }
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail19941.d(62): Error: undefined identifier `dne`
+---
+*/
+static t = new Static;
+class Static { int field = &dne; }