Improve docs & test for #pragma clang attribute's any clause; NFC
There was some confusion during the discussion of a patch as to whether `any` can be used to blast an attribute with no subject list onto basically everything in a program by not specifying a subrule. This patch adds documentation and tests to make it clear that this situation is not supported and will be diagnosed.
This commit is contained in:
parent
8d77555b12
commit
3874277f41
|
@ -3798,7 +3798,8 @@ Multiple match rules can be specified using the ``any`` match rule, as shown
|
|||
in the example above. The ``any`` rule applies attributes to all declarations
|
||||
that are matched by at least one of the rules in the ``any``. It doesn't nest
|
||||
and can't be used inside the other match rules. Redundant match rules or rules
|
||||
that conflict with one another should not be used inside of ``any``.
|
||||
that conflict with one another should not be used inside of ``any``. Failing to
|
||||
specify a rule within the ``any`` rule results in an error.
|
||||
|
||||
Clang supports the following match rules:
|
||||
|
||||
|
|
|
@ -204,3 +204,9 @@ _Pragma("clang attribute pop");
|
|||
#pragma clang attribute pop
|
||||
#pragma clang attribute push([[clang::no_destroy]], apply_to = any(variable(is_parameter), variable(unless(is_parameter))))
|
||||
#pragma clang attribute pop
|
||||
|
||||
// We explicitly do not wish to allow users to blast an attribute to everything
|
||||
// using an unconstrained "any", so "any" must have a valid argument list.
|
||||
#pragma clang attribute push([[clang::uninitialized]], apply_to=any) // expected-error {{expected '('}}
|
||||
#pragma clang attribute push([[clang::uninitialized]], apply_to = any()) // expected-error {{expected an identifier that corresponds to an attribute subject rule}}
|
||||
// NB: neither of these need to be popped; they were never successfully pushed.
|
||||
|
|
Loading…
Reference in a new issue