diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-07-21 19:32:54 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-08-03 04:40:18 +0200 |
commit | 442b5a661e312b27fc87f769834a2b58412a847a (patch) | |
tree | 493216f398cb16044a59d39fdebb97a6d683baef /gcc/testsuite/gdc.test | |
parent | 7031087cd7d6cd07d18797b0cac90dc048103ed1 (diff) | |
download | gcc-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/testsuite/gdc.test')
9 files changed, 110 insertions, 1 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/b9490.d b/gcc/testsuite/gdc.test/compilable/b9490.d new file mode 100644 index 0000000..d0148b1 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/b9490.d @@ -0,0 +1,39 @@ +// https://issues.dlang.org/show_bug.cgi?id=9490 +class A +{ + int[1] arr; + + this() + { + assert(arr.length); + assert((arr).length); + } +} + +class C +{ + struct Foo { int a; void funcToo(){} } + Foo foo; + + auto get(){return foo;} + + void test() + { + // Error: need 'this' to access member a + (foo).a = 1; + (foo).funcToo(); + (get()).a = 2; + } +} + +struct S { int i; } +struct S1 { S s; } +void f(int) { } + +void main() +{ + S1 s1; + f(s1.s.tupleof); // OK + f((s1.s).tupleof); // Error: need 'this' to access member s +} + diff --git a/gcc/testsuite/gdc.test/compilable/ice14739.d b/gcc/testsuite/gdc.test/compilable/ice14739.d new file mode 100644 index 0000000..cc90da6 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/ice14739.d @@ -0,0 +1,19 @@ +// REQUIRED_ARGS: -o- + +void main(string[] args) +{ + immutable int a; + immutable int b; + S!a sa; + S!b sb; + C!a ca; + C!b cb; +} + +struct S(alias a) +{ +} + +class C(alias a) +{ +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17492.d b/gcc/testsuite/gdc.test/fail_compilation/fail17492.d index e45c2e5..80e9e2a 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail17492.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail17492.d @@ -1,6 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail17492.d(19): Error: class fail17492.C.testE.I already exists at fail_compilation/fail17492.d(12). Perhaps in another function with the same name? +fail_compilation/fail17492.d(20): Error: class `fail17492.C.testE.I` already exists at fail17492.d(13). Perhaps in another function with the same name? +fail_compilation/fail17492.d(37): Error: struct `fail17492.S.testE.I` already exists at fail17492.d(30). Perhaps in another function with the same name? --- https://issues.dlang.org/show_bug.cgi?id=17492 */ @@ -21,3 +22,20 @@ class C } } } + +class S +{ + void testE() + { + struct I + { + } + } + + void testE() + { + struct I + { + } + } +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice21060.d b/gcc/testsuite/gdc.test/fail_compilation/ice21060.d new file mode 100644 index 0000000..d33889c --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/ice21060.d @@ -0,0 +1,15 @@ +/* +EXTRA_FILES: imports/ice21060a/package.d imports/ice21060b/package.d imports/ice21060c/package.d imports/ice21060d/package.d +TEST_OUTPUT: +--- +fail_compilation/imports/ice21060b/package.d(3): Error: struct `imports.ice21060d.P21060` already exists at fail_compilation/imports/ice21060d/package.d(3). Perhaps in another function with the same name? +--- +*/ +struct S21060 +{ + void print() + { + import imports.ice21060a; + import imports.ice21060b; + } +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060a/package.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060a/package.d new file mode 100644 index 0000000..b046aeb --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060a/package.d @@ -0,0 +1 @@ +import imports.ice21060c; diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060b/package.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060b/package.d new file mode 100644 index 0000000..a806fd0 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060b/package.d @@ -0,0 +1,5 @@ +module imports.ice21060d; + +struct P21060 +{ +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060c/package.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060c/package.d new file mode 100644 index 0000000..cc6f74e --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060c/package.d @@ -0,0 +1 @@ +import imports.ice21060d; diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060d/package.d b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060d/package.d new file mode 100644 index 0000000..a806fd0 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/imports/ice21060d/package.d @@ -0,0 +1,5 @@ +module imports.ice21060d; + +struct P21060 +{ +} diff --git a/gcc/testsuite/gdc.test/runnable/b16278.d b/gcc/testsuite/gdc.test/runnable/b16278.d new file mode 100644 index 0000000..a0a422d --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/b16278.d @@ -0,0 +1,6 @@ +// REQUIRED_ARGS: -main +class A() +{ + static struct S { A a; } +} +enum e = is(A!()); |