diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-20 20:19:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-20 20:19:27 +0000 |
commit | 30f2a74f882adcadb8060d914684f65a401d87ba (patch) | |
tree | 320a18e9f78285f9ebc962aa5da5d7ea33e2cd1e | |
parent | 3bba3efba0e57071d60b355ed62639f93e37711c (diff) |
PR15311: Finish implementation of the suggested resolution of core issue 1488,
which allows grouping parens in an abstract-pack-declarator. This was already
mostly implemented, but missed some cases. Add an ExtWarn for use of this
extension until CWG ratifies it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175660 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 3 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 7 | ||||
-rw-r--r-- | test/FixIt/fixit-cxx0x.cpp | 2 | ||||
-rw-r--r-- | test/Parser/cxx0x-ambig.cpp | 5 |
4 files changed, 15 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index a3ad84edf3..c75241e623 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -470,6 +470,9 @@ def err_parser_impl_limit_overflow : Error< def err_misplaced_ellipsis_in_declaration : Error< "'...' must %select{immediately precede declared identifier|" "be innermost component of anonymous pack declaration}0">; +def ext_abstract_pack_declarator_parens : ExtWarn< + "ISO C++11 requires a parenthesized pack declaration to have a name">, + InGroup<DiagGroup<"anonymous-pack-parens">>; // C++ derived classes def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">; diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 8bfdffc865..a204532789 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4439,6 +4439,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { !((D.getContext() == Declarator::PrototypeContext || D.getContext() == Declarator::BlockLiteralContext) && NextToken().is(tok::r_paren) && + !D.hasGroupingParens() && !Actions.containsUnexpandedParameterPacks(D))) { SourceLocation EllipsisLoc = ConsumeToken(); if (isPtrOperatorToken(Tok.getKind(), getLangOpts())) { @@ -4521,6 +4522,12 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // This could be something simple like "int" (in which case the declarator // portion is empty), if an abstract-declarator is allowed. D.SetIdentifier(0, Tok.getLocation()); + + // The grammar for abstract-pack-declarator does not allow grouping parens. + // FIXME: Revisit this once core issue 1488 is resolved. + if (D.hasEllipsis() && D.hasGroupingParens()) + Diag(PP.getLocForEndOfToken(D.getEllipsisLoc()), + diag::ext_abstract_pack_declarator_parens); } else { if (Tok.getKind() == tok::annot_pragma_parser_crash) LLVM_BUILTIN_TRAP; diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index 3884c64516..1f6275f933 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=c++11 -Wno-anonymous-pack-parens %s // RUN: cp %s %t // RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t // RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t diff --git a/test/Parser/cxx0x-ambig.cpp b/test/Parser/cxx0x-ambig.cpp index 96e200642b..ac9c75ea68 100644 --- a/test/Parser/cxx0x-ambig.cpp +++ b/test/Parser/cxx0x-ambig.cpp @@ -110,7 +110,7 @@ namespace ellipsis { void f(S(...args[sizeof(T)])); // expected-note {{here}} void f(S(...args)[sizeof(T)]); // expected-error {{redeclared}} expected-note {{here}} void f(S ...args[sizeof(T)]); // expected-error {{redeclared}} - void g(S(...[sizeof(T)])); // expected-note {{here}} + void g(S(...[sizeof(T)])); // expected-note {{here}} expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}} void g(S(...)[sizeof(T)]); // expected-error {{function cannot return array type}} void g(S ...[sizeof(T)]); // expected-error {{redeclared}} void h(T(...)); // function type, expected-error {{unexpanded parameter pack}} @@ -125,5 +125,8 @@ namespace ellipsis { void j(T(T...)); // expected-error {{unexpanded parameter pack}} void k(int(...)(T)); // expected-error {{cannot return function type}} void k(int ...(T)); + void l(int(&...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}} + void l(int(*...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}} + void l(int(S<int>::*...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}} }; } |