]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR d/90761
authoribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:49:18 +0000 (07:49 +0000)
committeribuclaw <ibuclaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Jun 2019 07:49:18 +0000 (07:49 +0000)
d/dmd: Merge upstream dmd d912f4e49

Fixes segmentation fault in implicitConvTo::ImplicitConvTo::visit.

Reviewed-on: https://github.com/dlang/dmd/pull/10005

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272346 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/d/dmd/MERGE
gcc/d/dmd/expressionsem.c
gcc/testsuite/gdc.test/compilable/test19941.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/fail19941.d [new file with mode: 0644]

index 7b46e8f3da03402dc950c663a3fd0070ac7b88d5..865462d64fbcf66a9e62f6847479f7a8d73cb52c 100644 (file)
@@ -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.
index 5177f9f6449431ef01d20517c7fd6f7c05a0391c..2957c09ca62bfde639b165c69e99464aea3532c1 100644 (file)
@@ -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 (file)
index 0000000..add1d41
--- /dev/null
@@ -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 (file)
index 0000000..61e174b
--- /dev/null
@@ -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; }