aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/docs/LanguageExtensions.rst4
-rw-r--r--clang/include/clang/Basic/Features.def1
-rw-r--r--clang/test/Sema/pragma-attribute-namespace.c4
3 files changed, 8 insertions, 1 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index c800a96e6dc8..574bb77345a8 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/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/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def
index 0cece27eefda..e3b97fd078e4 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/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/clang/test/Sema/pragma-attribute-namespace.c b/clang/test/Sema/pragma-attribute-namespace.c
index 35b6419f7dd3..2db788865b26 100644
--- a/clang/test/Sema/pragma-attribute-namespace.c
+++ b/clang/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}}