aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-01-25 11:27:29 +0100
committerEric Botcazou <ebotcazou@adacore.com>2021-01-25 11:30:00 +0100
commit5d01fc7c11606fa0fa36210309df6b10b6e07775 (patch)
tree390e5b51d018b3a0f54487789c98ddc0ef682ef7 /gcc/ada/gcc-interface/utils.c
parentc6b0e33febbf73abfcc2bb0e28f0b62afe3b0f2a (diff)
downloadgcc-5d01fc7c11606fa0fa36210309df6b10b6e07775.zip
gcc-5d01fc7c11606fa0fa36210309df6b10b6e07775.tar.gz
gcc-5d01fc7c11606fa0fa36210309df6b10b6e07775.tar.bz2
Fix internal error on extension with interface at -O2
This is a regression present on the mainline, 10 and 9 branches, in the form of an internal error with the Ada compiler when a covariant-only thunk is inlined into its caller. gcc/ada/ * gcc-interface/trans.c (make_covariant_thunk): Set the DECL_CONTEXT of the parameters and do not set TREE_PUBLIC on the thunk. (maybe_make_gnu_thunk): Pass the alias to the covariant thunk. * gcc-interface/utils.c (finish_subprog_decl): Set the DECL_CONTEXT of the parameters here... (begin_subprog_body): ...instead of here. gcc/testsuite/ * gnat.dg/thunk2.adb, gnat.dg/thunk2.ads: New test. * gnat.dg/thunk2_pkg.ads: New helper.
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 494f60e..d52220a 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3521,6 +3521,12 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
void
finish_subprog_decl (tree decl, tree asm_name, tree type)
{
+ /* DECL_ARGUMENTS is set by the caller, but not its context. */
+ for (tree param_decl = DECL_ARGUMENTS (decl);
+ param_decl;
+ param_decl = DECL_CHAIN (param_decl))
+ DECL_CONTEXT (param_decl) = decl;
+
tree result_decl
= build_decl (DECL_SOURCE_LOCATION (decl), RESULT_DECL, NULL_TREE,
TREE_TYPE (type));
@@ -3566,8 +3572,6 @@ finish_subprog_decl (tree decl, tree asm_name, tree type)
void
begin_subprog_body (tree subprog_decl)
{
- tree param_decl;
-
announce_function (subprog_decl);
/* This function is being defined. */
@@ -3583,10 +3587,6 @@ begin_subprog_body (tree subprog_decl)
/* Enter a new binding level and show that all the parameters belong to
this function. */
gnat_pushlevel ();
-
- for (param_decl = DECL_ARGUMENTS (subprog_decl); param_decl;
- param_decl = DECL_CHAIN (param_decl))
- DECL_CONTEXT (param_decl) = subprog_decl;
}
/* Finish translating the current subprogram and set its BODY. */