]> git.ipfire.org Git - thirdparty/gcc.git/commit
d: Add `@visibility' and `@hidden' attributes.
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 15 Jun 2022 17:44:36 +0000 (19:44 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 15 Jun 2022 18:11:04 +0000 (20:11 +0200)
commit636b01ab4910da0b96d844301fea1a2b56c5344d
tree480d97c9a670995fe519be3a7f8b86c5e97e50cb
parent49d14a841fd9a798fe6d68ae49c6fbb753d21032
d: Add `@visibility' and `@hidden' attributes.

The `@visibility' attribute is functionality the same as
`__attribute__((visibility))', and `@hidden' is a convenience alias to
`@visibility("hidden")' defined in the `gcc.attributes' module.

As the visibility of a symbol is also indirectly controlled by the
`export' keyword, the handling of this in the code generation pass has
been improved so that conflicts will be appropriately diagnosed.

gcc/d/ChangeLog:

* d-attribs.cc (d_langhook_attribute_table): Add visibility.
(insert_type_attribute): Use decl_attributes instead of
merge_attributes.
(insert_decl_attribute): Likewise.
(apply_user_attributes): Do nothing when no UDAs applied.
(d_handle_visibility_attribute): New function.
* d-gimplify.cc (d_gimplify_binary_expr): Adjust.
* d-tree.h (set_visibility_for_decl): Declare.
* decl.cc (get_symbol_decl): Move setting of visibility flags to...
(set_visibility_for_decl): ... here.  New function.
* types.cc (TypeVisitor::visit (TypeStruct *)): Call
set_visibility_for_decl().
(TypeVisitor::visit (TypeClass *)): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/attr_visibility1.d: New test.
* gdc.dg/attr_visibility2.d: New test.
* gdc.dg/attr_visibility3.d: New test.

libphobos/ChangeLog:

* libdruntime/gcc/attributes.d (visibility): Define.
(hidden): Define.
gcc/d/d-attribs.cc
gcc/d/d-gimplify.cc
gcc/d/d-tree.h
gcc/d/decl.cc
gcc/d/types.cc
gcc/testsuite/gdc.dg/attr_visibility1.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/attr_visibility2.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/attr_visibility3.d [new file with mode: 0644]
libphobos/libdruntime/gcc/attributes.d