aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-06-24 18:48:33 +0100
committerIain Sandoe <iain@sandoe.co.uk>2020-06-24 21:05:37 +0100
commit1e5da6a02fec8aa84bb00966282f420cb70fe4f0 (patch)
tree01477813c8a08e8118524130158da7d3619c2817 /gcc/cp
parent2dbc16552204ffa28b643949eb1f26b787017b39 (diff)
downloadgcc-1e5da6a02fec8aa84bb00966282f420cb70fe4f0.zip
gcc-1e5da6a02fec8aa84bb00966282f420cb70fe4f0.tar.gz
gcc-1e5da6a02fec8aa84bb00966282f420cb70fe4f0.tar.bz2
coroutines: Copy attributes to the outlined functions [PR95518,PR95813]
We had omitted the copying of function attributes, we now copy the used, alignment, section values from the original decal and the complete set of function attributes. It is likely that some function attributes don't really make sense for coroutines, but that can be disgnosed separately. Also mark the outlined functions as artificial, since they are; some diagnostic processing tests this. gcc/cp/ChangeLog: PR c++/95518 PR c++/95813 * coroutines.cc (act_des_fn): Copy function attributes onto the outlined coroutine helpers. gcc/testsuite/ChangeLog: PR c++/95518 PR c++/95813 * g++.dg/coroutines/pr95518.C: New test. * g++.dg/coroutines/pr95813.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/coroutines.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 9cdb0c5..64b9753 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3530,12 +3530,24 @@ act_des_fn (tree orig, tree fn_type, tree coro_frame_ptr, const char* name)
tree fn_name = get_fn_local_identifier (orig, name);
tree fn = build_lang_decl (FUNCTION_DECL, fn_name, fn_type);
DECL_CONTEXT (fn) = DECL_CONTEXT (orig);
+ DECL_ARTIFICIAL (fn) = true;
DECL_INITIAL (fn) = error_mark_node;
tree id = get_identifier ("frame_ptr");
tree fp = build_lang_decl (PARM_DECL, id, coro_frame_ptr);
DECL_CONTEXT (fp) = fn;
DECL_ARG_TYPE (fp) = type_passed_as (coro_frame_ptr);
DECL_ARGUMENTS (fn) = fp;
+ /* Copy selected attributes from the original function. */
+ TREE_USED (fn) = TREE_USED (orig);
+ if (DECL_SECTION_NAME (orig))
+ set_decl_section_name (fn, DECL_SECTION_NAME (orig));
+ /* Copy any alignment that the FE added. */
+ if (DECL_ALIGN (orig))
+ SET_DECL_ALIGN (fn, DECL_ALIGN (orig));
+ /* Copy any alignment the user added. */
+ DECL_USER_ALIGN (fn) = DECL_USER_ALIGN (orig);
+ /* Apply attributes from the original fn. */
+ DECL_ATTRIBUTES (fn) = copy_list (DECL_ATTRIBUTES (orig));
return fn;
}