This gives library implementers a way to use standards-based attributes that do not conflict with user-defined macros of the same name. Attributes in C2x require this behavior normatively (C2x 6.7.11p4), but there's no reason to not have the same behavior in C++, especially given that such attributes may be used by a C library consumed by a C++ compilation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369033
91177308-0d34-0410-b5e6-
96231b3b80d8
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);
// CHECK: _Clang::fallthrough: 201603L
CXX11(_Clang::fallthrough)
+// CHECK: __nodiscard__: 201907L
+CXX11(__nodiscard__)
+
// CHECK: __gnu__::__const__: 1
CXX11(__gnu__::__const__)
int does_not_have_selectany();
#endif
+// CHECK: has_nodiscard_underscore
+#if __has_c_attribute(__nodiscard__)
+ int has_nodiscard_underscore();
+#endif
void bar(void) {
foo2(); // expected-error {{'foo2' is unavailable: not available - replaced}}
}
+
+[[nodiscard]] int without_underscores(void);
+[[__nodiscard__]] int underscores(void);
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;