Author: rsmith Date: Fri Jun 24 07:15:12 2016 New Revision: 273666 URL: http://llvm.org/viewvc/llvm-project?rev=273666&view=rev Log: Using for attributes voted into C++17.
Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/www/cxx_status.html Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=273666&r1=273665&r2=273666&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Jun 24 07:15:12 2016 @@ -560,6 +560,14 @@ def err_cxx11_attribute_forbids_ellipsis "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 " Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=273666&r1=273665&r2=273666&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jun 24 07:15:12 2016 @@ -3771,6 +3771,23 @@ void Parser::ParseCXX11AttributeSpecifie 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)) { @@ -3799,6 +3816,16 @@ void Parser::ParseCXX11AttributeSpecifie } } + 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; Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp?rev=273666&view=auto ============================================================================== --- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp (added) +++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp Fri Jun 24 07:15:12 2016 @@ -0,0 +1,16 @@ +// 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}} Modified: cfe/trunk/www/cxx_status.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=273666&r1=273665&r2=273666&view=diff ============================================================================== --- cfe/trunk/www/cxx_status.html (original) +++ cfe/trunk/www/cxx_status.html Fri Jun 24 07:15:12 2016 @@ -672,12 +672,12 @@ as the draft C++1z standard evolves.</p> <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> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits