Skip to content

Commit c48988a

Browse files
committed
Accept 'T...[]' within a function parameter scope
1 parent 5973de1 commit c48988a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

clang/lib/Parse/ParseExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
238238

239239
else if (!HasScopeSpecifier && Tok.is(tok::identifier) &&
240240
GetLookAheadToken(1).is(tok::ellipsis) &&
241-
GetLookAheadToken(2).is(tok::l_square)) {
241+
GetLookAheadToken(2).is(tok::l_square) &&
242+
!GetLookAheadToken(3).is(tok::r_square)) {
242243
SourceLocation Start = Tok.getLocation();
243244
DeclSpec DS(AttrFactory);
244245
SourceLocation CCLoc;

clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ template<typename T>
5757
void b(T[] ...);
5858

5959
template<typename T>
60-
void c(T ... []); // expected-error {{expected expression}} \
61-
// expected-error {{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}} \
62-
// expected-warning {{would become a pack indexing declaration in C++2c onwards}} \
63-
// expected-note {{add a name to disambiguate}}
60+
void c(T ... []); // expected-error {{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}}
61+
62+
// A function that takes pointers to each type T as arguments, after any decay.
63+
template <typename ...T>
64+
void g(T...[]);
6465

6566
template<typename T>
6667
void d(T ... x[]); // expected-error{{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}}

clang/test/Parser/cxx2c-pack-indexing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ struct S {
1212
// expected-note {{to match this '['}} \
1313
// expected-warning{{declaration does not declare anything}}
1414

15-
T...[]; // expected-error{{expected expression}} \
16-
// expected-warning{{declaration does not declare anything}}
15+
T...[]; // expected-error{{expected member name or ';' after declaration specifiers}}
1716

1817
void f(auto... v) {
1918
decltype(v...[1]) a = v...[1];
@@ -65,7 +64,7 @@ int main() {
6564
}
6665

6766

68-
namespace GH11460 {
67+
namespace GH111460 {
6968
template <typename... T>
7069
requires( ); // expected-error {{expected expression}}
7170
struct SS {

0 commit comments

Comments
 (0)