r350572 - Add a __has_feature check for namespaces on #pragma clang attribute.

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 7 16:10:54 PST 2019


On 1/7/19 3:51 PM, Richard Smith wrote:
> On Mon, 7 Jan 2019 at 13:57, Erik Pilkington via cfe-commits 
> <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>> wrote:
>
>     Author: epilk
>     Date: Mon Jan  7 13:54:00 2019
>     New Revision: 350572
>
>     URL: http://llvm.org/viewvc/llvm-project?rev=350572&view=rev
>     Log:
>     Add a __has_feature check for namespaces on #pragma clang attribute.
>
>
> Should this be __has_extension rather than __has_feature, since it's 
> not a standard feature?


I suppose, but it doesn't really seem like that's the rule that we're 
following here. If you look at every other FEATURE(...) above this, they 
all have to do with clang extensions like attributes and sanitizers, 
which obviously aren't standard features. Every EXTENSION(...) has to do 
with language features that are shared between languages (cxx_fixed_enum 
in C, for instance). So it seems like the most internally consistent 
place to put this is in FEATURE(...). WDYT?


>     Support for this was added in r349845.
>
>     Modified:
>         cfe/trunk/docs/LanguageExtensions.rst
>         cfe/trunk/include/clang/Basic/Features.def
>         cfe/trunk/test/Sema/pragma-attribute-namespace.c
>
>     Modified: cfe/trunk/docs/LanguageExtensions.rst
>     URL:
>     http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=350572&r1=350571&r2=350572&view=diff
>     ==============================================================================
>     --- cfe/trunk/docs/LanguageExtensions.rst (original)
>     +++ cfe/trunk/docs/LanguageExtensions.rst Mon Jan  7 13:54:00 2019
>     @@ -2725,7 +2725,9 @@ same namespace. For instance:
>      Without the namespaces on the macros, ``other_function`` will be
>     annotated with
>      ``[[noreturn]]`` instead of ``__attribute__((unavailable))``.
>     This may seem like
>      a contrived example, but its very possible for this kind of
>     situation to appear
>     -in real code if the pragmas are spread out across a large file.
>     +in real code if the pragmas are spread out across a large file.
>     You can test if
>     +your version of clang supports namespaces on ``#pragma clang
>     attribute`` with
>     +``__has_feature(pragma_clang_attribute_namespaces)``.
>
>      Subject Match Rules
>      -------------------
>
>     Modified: cfe/trunk/include/clang/Basic/Features.def
>     URL:
>     http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=350572&r1=350571&r2=350572&view=diff
>     ==============================================================================
>     --- cfe/trunk/include/clang/Basic/Features.def (original)
>     +++ cfe/trunk/include/clang/Basic/Features.def Mon Jan  7 13:54:00
>     2019
>     @@ -69,6 +69,7 @@ FEATURE(attribute_overloadable, true)
>      FEATURE(attribute_unavailable_with_message, true)
>      FEATURE(attribute_unused_on_fields, true)
>      FEATURE(attribute_diagnose_if_objc, true)
>     +FEATURE(pragma_clang_attribute_namespaces, true)
>      FEATURE(blocks, LangOpts.Blocks)
>      FEATURE(c_thread_safety_attributes, true)
>      FEATURE(cxx_exceptions, LangOpts.CXXExceptions)
>
>     Modified: cfe/trunk/test/Sema/pragma-attribute-namespace.c
>     URL:
>     http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-attribute-namespace.c?rev=350572&r1=350571&r2=350572&view=diff
>     ==============================================================================
>     --- cfe/trunk/test/Sema/pragma-attribute-namespace.c (original)
>     +++ cfe/trunk/test/Sema/pragma-attribute-namespace.c Mon Jan  7
>     13:54:00 2019
>     @@ -1,5 +1,9 @@
>      // RUN: %clang_cc1 -fsyntax-only -verify %s
>
>     +#if !__has_feature(pragma_clang_attribute_namespaces)
>     +#error
>     +#endif
>     +
>      #pragma clang attribute MyNamespace.push
>     (__attribute__((annotate)), apply_to=function) // expected-error 2
>     {{'annotate' attribute}}
>
>      int some_func(); // expected-note{{when applied to this declaration}}
>
>
>     _______________________________________________
>     cfe-commits mailing list
>     cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190107/494dd433/attachment.html>


More information about the cfe-commits mailing list