From: Erik Pilkington Date: Mon, 7 Jan 2019 21:54:00 +0000 (+0000) Subject: Add a __has_feature check for namespaces on #pragma clang attribute. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4cc996c03cf35e987db6c831d711ed8996e4ec1;p=clang Add a __has_feature check for namespaces on #pragma clang attribute. Support for this was added in r349845. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350572 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index c800a96e6d..574bb77345 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -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 ------------------- diff --git a/include/clang/Basic/Features.def b/include/clang/Basic/Features.def index 0cece27eef..e3b97fd078 100644 --- a/include/clang/Basic/Features.def +++ b/include/clang/Basic/Features.def @@ -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) diff --git a/test/Sema/pragma-attribute-namespace.c b/test/Sema/pragma-attribute-namespace.c index 35b6419f7d..2db788865b 100644 --- a/test/Sema/pragma-attribute-namespace.c +++ b/test/Sema/pragma-attribute-namespace.c @@ -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}}