]> granicus.if.org Git - clang/commitdiff
Add a __has_feature check for namespaces on #pragma clang attribute.
authorErik Pilkington <erik.pilkington@gmail.com>
Mon, 7 Jan 2019 21:54:00 +0000 (21:54 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Mon, 7 Jan 2019 21:54:00 +0000 (21:54 +0000)
Support for this was added in r349845.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350572 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LanguageExtensions.rst
include/clang/Basic/Features.def
test/Sema/pragma-attribute-namespace.c

index c800a96e6dc8b5bcd675488d9c2fa4f6b8184988..574bb77345a80115064f13fe5a7601fdd11b0a70 100644 (file)
@@ -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
 -------------------
index 0cece27eefda985a45e3f9788467a7b3aee9d19e..e3b97fd078e400ac31468fb8af90c4c2b74c1cec 100644 (file)
@@ -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)
index 35b6419f7dd3e1aa5b73a7ac915ea063ae8fb7fa..2db788865b26eeed988b6fbaf434745f64af3132 100644 (file)
@@ -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}}