diff options
| author | Erik Pilkington <erik.pilkington@gmail.com> | 2019-01-07 21:54:00 +0000 |
|---|---|---|
| committer | Erik Pilkington <erik.pilkington@gmail.com> | 2019-01-07 21:54:00 +0000 |
| commit | b460f1624cd57698a8cd94912a50890f01e2ed4d (patch) | |
| tree | b517b82081a18384315eb61f3e534991fc8ee81e | |
| parent | 7bb3353f6ab94326a79e2e5bdb8f77675666ba84 (diff) | |
| download | bcm5719-llvm-b460f1624cd57698a8cd94912a50890f01e2ed4d.tar.gz bcm5719-llvm-b460f1624cd57698a8cd94912a50890f01e2ed4d.zip | |
Add a __has_feature check for namespaces on #pragma clang attribute.
Support for this was added in r349845.
llvm-svn: 350572
| -rw-r--r-- | clang/docs/LanguageExtensions.rst | 4 | ||||
| -rw-r--r-- | clang/include/clang/Basic/Features.def | 1 | ||||
| -rw-r--r-- | clang/test/Sema/pragma-attribute-namespace.c | 4 |
3 files changed, 8 insertions, 1 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index c800a96e6dc..574bb77345a 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 0cece27eefd..e3b97fd078e 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 35b6419f7dd..2db788865b2 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}} |

