Explicitly forbid inheriting SME keyword attributes#439
Open
acoplan-arm wants to merge 1 commit into
Open
Conversation
This patch aims to clarify the interaction between SME keyword attributes and a common compiler extension which allows type attributes to be inherited given a pair of subsequent declarations D1, D2 where D1 has type attributes and D2 has none. The patch just explicitly spells out behaviour which (in my understanding) is: - the intent of the existing specification - existing clang behaviour - intended GCC behaviour (which has regressed in GCC 16, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122483). The hope is that the new wording will help smooth the way for this regression to be fixed in GCC 17. The SME keyword attributes section says: > Except where noted otherwise, function types that have an attribute > are incompatible with function types that do not. I believe the intent here was for this incompatibility to extend to compiler extensions which currently allow code such as: ```c void f(void) [[attr1, ..., attrN]]; void f(void); ``` as a convenience for situations where f is likely to be included from a header file, and the user doesn't want to have to write out all of the attributes in a local redeclaration. E.g. the following C code is currently accepted by both GCC and clang: ```c void f(void) __attribute__((aarch64_vector_pcs)); void f(void); // accepted ``` but if we switch the order of the declarations, it is (correctly) rejected by both compilers: ```c void g(void); void g(void) __attribute__((aarch64_vector_pcs)); // rejected ``` I believe the intent of the ACLE for SME keyword attributes was always to reject code such as: ```cpp void f(void) __arm_inout("za"); void f(void); ``` i.e. that this convenience feature should _not_ apply to those SME keyword attributes that affect type identity. The rationale is along the lines that the above is logically equivalent to something like: ```cpp void f(za_state &); void f(void); ``` which should be considered ill-formed in the same way that e.g.: ```cpp int f(int x); void f(void); ``` is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch aims to clarify the interaction between SME keyword attributes and a common compiler extension which allows type attributes to be inherited given a pair of subsequent declarations D1, D2 where D1 has type attributes and D2 has none.
The patch just explicitly spells out behaviour which (in my understanding) is:
The SME keyword attributes section says:
I believe the intent here was for this incompatibility to extend to compiler extensions which currently allow code such as:
as a convenience for situations where f is likely to be included from a header file, and the user doesn't want to have to write out all of the attributes in a local redeclaration.
E.g. the following C code is currently accepted by both GCC and clang:
but if we switch the order of the declarations, it is (correctly) rejected by both compilers:
I believe the intent of the ACLE for SME keyword attributes was always to reject code such as:
i.e. that this convenience feature should not apply to those SME keyword attributes that affect type identity. The rationale is along the lines that the above is logically equivalent to something like:
which should be considered ill-formed in the same way that e.g.:
is.