"attribute '%0' cannot be used as an attribute pack">;
def err_cxx11_attribute_repeated : Error<
"attribute %0 cannot appear multiple times in an attribute specifier">;
+def warn_cxx14_compat_using_attribute_ns : Warning<
+ "default scope specifier for attributes is incompatible with C++ standards "
+ "before C++1z">, InGroup<CXXPre1zCompat>, DefaultIgnore;
+def ext_using_attribute_ns : ExtWarn<
+ "default scope specifier for attributes is a C++1z extension">,
+ InGroup<CXX1z>;
+def err_using_attribute_ns_conflict : Error<
+ "attribute with scope specifier cannot follow default scope specifier">;
def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
def err_l_square_l_square_not_attribute : Error<
"C++11 only allows consecutive left square brackets when "
ConsumeBracket();
ConsumeBracket();
+ SourceLocation CommonScopeLoc;
+ IdentifierInfo *CommonScopeName = nullptr;
+ if (Tok.is(tok::kw_using)) {
+ Diag(Tok.getLocation(), getLangOpts().CPlusPlus1z
+ ? diag::warn_cxx14_compat_using_attribute_ns
+ : diag::ext_using_attribute_ns);
+ ConsumeToken();
+
+ CommonScopeName = TryParseCXX11AttributeIdentifier(CommonScopeLoc);
+ if (!CommonScopeName) {
+ Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
+ SkipUntil(tok::r_square, tok::colon, StopBeforeMatch);
+ }
+ if (!TryConsumeToken(tok::colon) && CommonScopeName)
+ Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
+ }
+
llvm::SmallDenseMap<IdentifierInfo*, SourceLocation, 4> SeenAttrs;
while (Tok.isNot(tok::r_square)) {
}
}
+ if (CommonScopeName) {
+ if (ScopeName) {
+ Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
+ << SourceRange(CommonScopeLoc);
+ } else {
+ ScopeName = CommonScopeName;
+ ScopeLoc = CommonScopeLoc;
+ }
+ }
+
bool StandardAttr = IsBuiltInOrStandardCXX11Attribute(AttrName, ScopeName);
bool AttrParsed = false;
--- /dev/null
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+[[disable_tail_calls, noduplicate]] void f() {} // expected-warning {{unknown attribute 'disable_tail_calls'}} expected-warning {{unknown attribute 'noduplicate'}}
+
+[[using clang: disable_tail_calls, noduplicate]] void g() {} // ok
+
+[[using]] extern int n; // expected-error {{expected identifier}}
+[[using foo
+] // expected-error {{expected ':'}}
+] extern int n;
+[[using 42:]] extern int n; // expected-error {{expected identifier}}
+[[using clang:]] extern int n; // ok
+[[using blah: clang::optnone]] extern int n; // expected-error {{attribute with scope specifier cannot follow}} expected-warning {{only applies to functions}}
+
+[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown attribute}}
+[[using unknown_ns: something]] extern int n; // expected-warning {{unknown attribute}}
<td class="full" align="center">Yes</td>
</tr>
<!-- Oulu papers -->
- <!--
<tr>
<td>Using attribute namespaces without repetition</td>
<td><a href="http://wg21.link/p0028r4">P0028R4</a></td>
<td class="none" align="center">No</td>
</tr>
+ <!--
<tr>
<td>Dynamic memory allocation for over-aligned data</td>
<td><a href="http://wg21.link/p0035r4">P0035R4</a></td>