-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Open
Clang (C23): Attributes with unknown "attribute-prefix" should not raise "-Wunknown-attributes"#120875
Feature
Copy link
Labels
c23clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
With --std=c23, when using attributes with an arbitrary attribute-prefix, Clang raises the warning -Wunknown-attributes as shown below.
$ cat test.c
[[cthrough::hello(bye((no)) go(away((please)))), cthrough::alvida(la la la la)]]
int main (void)
{
return 3;
}
$
$
$ clang --std=c23 test.c -o exe
test.c:1:3: warning: unknown attribute 'hello' ignored [-Wunknown-attributes]
1 | [[cthrough::hello(bye((no)) go(away((please)))), cthrough::alvida(la la la la)]]
| ^~~~~~~~~~~~~~~
test.c:1:50: warning: unknown attribute 'alvida' ignored [-Wunknown-attributes]
1 | [[cthrough::hello(bye((no)) go(away((please)))), cthrough::alvida(la la la la)]]
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~The whole point of attribute-prefixs is to be able to use attributes for multiple compilers without a #ifdef-hell. Thus, there is no reason for this warning to be raised. And if a warning has to be raised, it should be a different one (perhaps -Wunknown-attribute-prefix) such that it can selectively be disabled (since -Wunknown-attributes is useful in case of misspelled attributes in general).
Metadata
Metadata
Assignees
Labels
c23clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer