diff options
-rw-r--r-- | clang/lib/Sema/ParsedAttr.cpp | 3 | ||||
-rw-r--r-- | clang/test/Preprocessor/has_attribute.cpp | 3 | ||||
-rw-r--r-- | clang/test/Preprocessor/has_c_attribute.c | 4 | ||||
-rw-r--r-- | clang/test/Sema/attr-cx2.c | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/attr-cxx0x.cpp | 2 |
5 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp index 5c04443460b..6c103081c60 100644 --- a/clang/lib/Sema/ParsedAttr.cpp +++ b/clang/lib/Sema/ParsedAttr.cpp @@ -125,7 +125,8 @@ static StringRef normalizeAttrName(StringRef AttrName, SyntaxUsed == ParsedAttr::AS_GNU || ((SyntaxUsed == ParsedAttr::AS_CXX11 || SyntaxUsed == ParsedAttr::AS_C2x) && - (NormalizedScopeName == "gnu" || NormalizedScopeName == "clang")); + (NormalizedScopeName.empty() || NormalizedScopeName == "gnu" || + NormalizedScopeName == "clang")); if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") && AttrName.endswith("__")) AttrName = AttrName.slice(2, AttrName.size() - 2); diff --git a/clang/test/Preprocessor/has_attribute.cpp b/clang/test/Preprocessor/has_attribute.cpp index 83ee0e3c6cf..e7303c7c5b4 100644 --- a/clang/test/Preprocessor/has_attribute.cpp +++ b/clang/test/Preprocessor/has_attribute.cpp @@ -31,6 +31,9 @@ __clang__::fallthrough: __has_cpp_attribute(__clang__::fallthrough) // CHECK: _Clang::fallthrough: 201603L CXX11(_Clang::fallthrough) +// CHECK: __nodiscard__: 201907L +CXX11(__nodiscard__) + // CHECK: __gnu__::__const__: 1 CXX11(__gnu__::__const__) diff --git a/clang/test/Preprocessor/has_c_attribute.c b/clang/test/Preprocessor/has_c_attribute.c index dc22da7e4cd..843a67a2646 100644 --- a/clang/test/Preprocessor/has_c_attribute.c +++ b/clang/test/Preprocessor/has_c_attribute.c @@ -10,3 +10,7 @@ int does_not_have_selectany(); #endif +// CHECK: has_nodiscard_underscore +#if __has_c_attribute(__nodiscard__) + int has_nodiscard_underscore(); +#endif diff --git a/clang/test/Sema/attr-cx2.c b/clang/test/Sema/attr-cx2.c index ec74edf058e..561b88edfc8 100644 --- a/clang/test/Sema/attr-cx2.c +++ b/clang/test/Sema/attr-cx2.c @@ -24,3 +24,6 @@ void foo2(void) [[clang::unavailable("not available - replaced")]]; // expected- void bar(void) { foo2(); // expected-error {{'foo2' is unavailable: not available - replaced}} } + +[[nodiscard]] int without_underscores(void); +[[__nodiscard__]] int underscores(void); diff --git a/clang/test/SemaCXX/attr-cxx0x.cpp b/clang/test/SemaCXX/attr-cxx0x.cpp index 6ba89a62d70..b405e113948 100644 --- a/clang/test/SemaCXX/attr-cxx0x.cpp +++ b/clang/test/SemaCXX/attr-cxx0x.cpp @@ -46,7 +46,7 @@ static_assert(alignof(outer<int,char>::inner<double,short>) == alignof(int) * al static_assert(alignof(int(int)) >= 1, "alignof(function) not positive"); // expected-error{{invalid application of 'alignof' to a function type}} -[[__carries_dependency__]] // expected-warning{{unknown attribute '__carries_dependency__' ignored}} +[[__carries_dependency__]] void func(void); alignas(4) auto PR19252 = 0; |