diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-07-21 19:59:00 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-08-03 11:18:46 +0200 |
commit | 2b1c2a4bd9fb555dccde5d67d6da64547064e0e6 (patch) | |
tree | 5da49e400890cbbb33d45ca68f9c47e323bf2baf /gcc/testsuite | |
parent | 58cfec3a6e756b534b33787e51c52f5fc63b53ab (diff) | |
download | gcc-2b1c2a4bd9fb555dccde5d67d6da64547064e0e6.zip gcc-2b1c2a4bd9fb555dccde5d67d6da64547064e0e6.tar.gz gcc-2b1c2a4bd9fb555dccde5d67d6da64547064e0e6.tar.bz2 |
d: Fix ICE using non-local variable: internal compiler error: Segmentation fault
Moves no frame access error to own function, adding use of it for both
when get_framedecl() cannot find a path to the outer function frame, and
guarding get_decl_tree() from recursively calling itself.
gcc/d/ChangeLog:
PR d/96254
* d-codegen.cc (error_no_frame_access): New.
(get_frame_for_symbol): Use fdparent name in error message.
(get_framedecl): Replace call to assert with error.
* d-tree.h (error_no_frame_access): Declare.
* decl.cc (get_decl_tree): Detect recursion and error.
gcc/testsuite/ChangeLog:
PR d/96254
* gdc.dg/pr96254a.d: New test.
* gdc.dg/pr96254b.d: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/gdc.dg/pr96254a.d | 28 | ||||
-rw-r--r-- | gcc/testsuite/gdc.dg/pr96254b.d | 24 |
2 files changed, 52 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.dg/pr96254a.d b/gcc/testsuite/gdc.dg/pr96254a.d new file mode 100644 index 0000000..e5dd124 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr96254a.d @@ -0,0 +1,28 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96254 +// { dg-do compile } +struct map(alias fun) +{ + @property run() + { + } +} + +struct Task(Args) +{ + Args _args; +} + +template reduce(functions...) +{ + auto reduce(Args)(Args args) + { + alias RTask = Task!(typeof(args)); + auto task = RTask(); + } +} + +void main() // { dg-error "'D main' is a nested function and cannot be accessed" } +{ + immutable delta = 1; + reduce!"a + b"(map!({ immutable x = delta; })()); +} diff --git a/gcc/testsuite/gdc.dg/pr96254b.d b/gcc/testsuite/gdc.dg/pr96254b.d new file mode 100644 index 0000000..02e3c48 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr96254b.d @@ -0,0 +1,24 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96254 +// { dg-do compile } +mixin template test() +{ + int next; +} + +void foo(alias l)() +{ + l.next = 0; // { dg-error "cannot get frame pointer to 'D main'" } +} + +void bar(alias l, alias t)() +{ + l.next = 0; // { dg-error "cannot get frame pointer to 'D main'" } +} + +void main() +{ + mixin test l1; + mixin test l2; + foo!(l1); + bar!(l1,l2); +} |