d: Merge UDAs between function prototype and definitions (PR90136)
authorIain Buclaw <ibuclaw@gdcproject.org>
Thu, 18 Apr 2019 07:50:56 +0000 (09:50 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 31 Mar 2020 22:12:47 +0000 (00:12 +0200)
commit013fca64fc17ba646c3564eab52fac50f0751188
treec75868fd2d0b82c3e4ba548430629646ea5fb681
parent1c16f7fc903c1c1c912faf7889b69d83429b7b2e
d: Merge UDAs between function prototype and definitions (PR90136)

This change fixes the symbol merging in get_symbol_decl to also consider
prototypes.  This allows the ability to set user defined attributes on
the prototype of a function, which then get applied to the definition,
if found later in the compilation.

The lowering of UDAs to GCC attributes has been commonized into a single
function called apply_user_attributes.

gcc/d/ChangeLog:

PR d/90136
* d-attribs.cc: Include dmd/attrib.h.
(build_attributes): Redeclare as static.
(apply_user_attributes): New function.
* d-tree.h (class UserAttributeDeclaration): Remove.
(build_attributes): Remove.
(apply_user_attributes): Declare.
(finish_aggregate_type): Remove attrs argument.
* decl.cc (get_symbol_decl): Merge declaration prototypes with
definitions.  Use apply_user_attributes.
* modules.cc (layout_moduleinfo_fields): Remove last argument to
finish_aggregate_type.
* typeinfo.cc (layout_classinfo_interfaces): Likewise.
* types.cc (layout_aggregate_members): Likewise.
(finish_aggregate_type): Remove attrs argument.
(TypeVisitor::visit (TypeEnum *)): Use apply_user_attributes.
(TypeVisitor::visit (TypeStruct *)): Remove last argument to
finish_aggregate_type.  Use apply_user_attributes.
(TypeVisitor::visit (TypeClass *)): Likewise.

gcc/testsuite/ChangeLog:

PR d/90136
* gdc.dg/pr90136a.d: New test.
* gdc.dg/pr90136b.d: New test.
* gdc.dg/pr90136c.d: New test.
gcc/d/ChangeLog
gcc/d/d-attribs.cc
gcc/d/d-tree.h
gcc/d/decl.cc
gcc/d/modules.cc
gcc/d/typeinfo.cc
gcc/d/types.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gdc.dg/pr90136a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr90136b.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr90136c.d [new file with mode: 0644]