diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 8f7727e27bf6..60b1ed383a1f 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -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: diff --git a/clang/test/Parser/pragma-attribute.cpp b/clang/test/Parser/pragma-attribute.cpp index d51f8159c263..d82eaa3f01b0 100644 --- a/clang/test/Parser/pragma-attribute.cpp +++ b/clang/test/Parser/pragma-attribute.cpp @@ -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.