Skip to content

Commit

Permalink
Recognize splices as parts of valid declaration specifiers.
Browse files Browse the repository at this point in the history
Closes llvm#29.
  • Loading branch information
katzdm committed May 1, 2024
1 parent f247b56 commit 96f0ab9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5862,12 +5862,15 @@ bool Parser::isDeclarationSpecifier(
[[fallthrough]];
case tok::kw_decltype: // decltype(T())::type
case tok::kw_typename: // typename T::type
case tok::l_splice:
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken(AllowImplicitTypename))
return true;
if (TryAnnotateTypeConstraint())
return true;
if (Tok.is(tok::annot_splice))
return true;
if (Tok.is(tok::identifier))
return false;

Expand Down
4 changes: 4 additions & 0 deletions clang/test/Reflection/splice-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ consteval auto decr(typename [:r_int:] p) -> [:r_const_int:] {
return p - 1;
}
static_assert(decr(13) == 12);

// 'typename' should be optional in parameter declarations.
void fn([:r_int:]);
class S { S([:r_int:]); };
} // in_fn_defs

// ======
Expand Down

0 comments on commit 96f0ab9

Please sign in to comment.