]> gcc.gnu.org Git - gcc.git/commit
c++: correct __has_attribute(init_priority)
authorPatrick Palka <ppalka@redhat.com>
Sun, 6 Nov 2022 16:09:26 +0000 (11:09 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sun, 6 Nov 2022 16:09:26 +0000 (11:09 -0500)
commitd0a492faa6478c99d325fa4a7ed2e5633cef7529
tree733fcf33b077d090c956b85e6d13a6307bc1aebe
parent89d0a14a1fdf89d38d9db1156ffde8c1b276823c
c++: correct __has_attribute(init_priority)

Currently __has_attribute(init_priority) always returns true, even on
targets that don't actually support init priorities, and when using the
attribute on such targets we just get a hard error about them being
unsupported.  This makes it impossible to conditionally use the attribute
by querying __has_attribute.

This patch fixes this by including init_priority in the attribute table
only if the target supports init priorities.  Thus on such targets
__has_attribute(init_priority) will now return false and we'll treat it
as just another unrecognized attribute (e.g. using it gives a -Wattribute
warning instead of a hard error).

gcc/cp/ChangeLog:

* tree.cc (cxx_attribute_table): Include init_priority entry
only if SUPPORTS_INIT_PRIORITY.
(handle_init_priority_attribute): Add ATTRIBUTE_UNUSED.  Assert
SUPPORTS_INIT_PRIORITY is true.

gcc/testsuite/ChangeLog:

* g++.dg/special/initpri3.C: New test.
gcc/cp/tree.cc
gcc/testsuite/g++.dg/special/initpri3.C [new file with mode: 0644]
This page took 0.055861 seconds and 5 git commands to generate.