24 #include "llvm/Support/ErrorHandling.h"
27 using namespace clang;
32 case tok::unknown:
return 0;
34 case tok::kw_addrspace_cast:
return 1;
35 case tok::kw_const_cast:
return 2;
36 case tok::kw_dynamic_cast:
return 3;
37 case tok::kw_reinterpret_cast:
return 4;
38 case tok::kw_static_cast:
return 5;
40 llvm_unreachable(
"Unknown type for digraph error message.");
45 bool Parser::areTokensAdjacent(
const Token &First,
const Token &Second) {
63 P.Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
68 ColonToken.
setKind(tok::coloncolon);
71 DigraphToken.
setKind(tok::less);
82 void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
85 if (!Next.is(tok::l_square) || Next.getLength() != 2)
88 Token SecondToken = GetLookAheadToken(2);
89 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
95 bool MemberOfUnknownSpecialization;
98 Template, MemberOfUnknownSpecialization))
101 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
154 bool Parser::ParseOptionalCXXScopeSpecifier(
156 bool EnteringContext,
bool *MayBePseudoDestructor,
bool IsTypename,
157 IdentifierInfo **LastII,
bool OnlyNamespace,
bool InUsingDeclaration) {
159 "Call sites of this function should be guarded by checking for C++");
161 if (Tok.
is(tok::annot_cxxscope)) {
162 assert(!LastII &&
"want last identifier but have already annotated scope");
163 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
167 ConsumeAnnotationToken();
172 bool CheckForDestructor =
false;
173 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
174 CheckForDestructor =
true;
175 *MayBePseudoDestructor =
false;
181 bool HasScopeSpecifier =
false;
183 if (Tok.
is(tok::coloncolon)) {
186 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
189 if (NextKind == tok::l_brace) {
198 HasScopeSpecifier =
true;
202 if (Tok.
is(tok::kw___super)) {
204 if (!Tok.
is(tok::coloncolon)) {
212 if (!HasScopeSpecifier &&
213 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
223 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
230 HasScopeSpecifier =
true;
234 auto SavedType = PreferredType;
236 if (HasScopeSpecifier) {
237 if (Tok.
is(tok::code_completion)) {
242 InUsingDeclaration, ObjectType.
get(),
262 ObjectType =
nullptr;
270 if (Tok.
is(tok::kw_template)) {
274 if (!HasScopeSpecifier && !ObjectType)
277 TentativeParsingAction TPA(*
this);
281 if (Tok.
is(tok::identifier)) {
285 }
else if (Tok.
is(tok::kw_operator)) {
290 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
299 diag::err_id_after_template_in_nested_name_spec)
312 if (Tok.
isNot(tok::less)) {
322 EnteringContext, Template,
true);
323 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
330 if (Tok.
is(tok::annot_template_id) &&
NextToken().is(tok::coloncolon)) {
339 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
340 *MayBePseudoDestructor =
true;
345 *LastII = TemplateId->
Name;
348 ConsumeAnnotationToken();
350 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
353 HasScopeSpecifier =
true;
380 if (Tok.
isNot(tok::identifier))
395 if (Next.is(tok::colon) && !ColonIsSacred) {
402 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
405 Next.setKind(tok::coloncolon);
409 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
420 if (Next.is(tok::coloncolon)) {
421 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
422 *MayBePseudoDestructor =
true;
427 const Token &Next2 = GetLookAheadToken(2);
428 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
429 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
430 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
435 ColonColon.
setKind(tok::colon);
448 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
449 "NextToken() not working properly!");
450 Token ColonColon = Tok;
453 bool IsCorrectedToColon =
false;
454 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
457 CorrectionFlagPtr, OnlyNamespace)) {
460 if (CorrectionFlagPtr && IsCorrectedToColon) {
461 ColonColon.
setKind(tok::colon);
469 HasScopeSpecifier =
true;
473 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
477 if (Next.is(tok::less)) {
482 bool MemberOfUnknownSpecialization;
489 MemberOfUnknownSpecialization)) {
495 isTemplateArgumentList(1) == TPResult::False)
512 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
513 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
516 if (!ObjectHadErrors) {
521 unsigned DiagID = diag::err_missing_dependent_template_keyword;
523 DiagID = diag::warn_missing_dependent_template_keyword;
534 EnteringContext, Template,
true);
551 if (CheckForDestructor && !HasScopeSpecifier && Tok.
is(tok::tilde))
552 *MayBePseudoDestructor =
true;
558 bool isAddressOfOperand,
559 Token &Replacement) {
564 case tok::annot_non_type: {
565 NamedDecl *ND = getNonTypeAnnotation(Tok);
571 case tok::annot_non_type_dependent: {
577 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
578 isAddressOfOperand =
false;
585 case tok::annot_non_type_undeclared: {
587 "undeclared non-type annotation should be unqualified");
602 false, &TemplateKWLoc, Name))
607 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
608 isAddressOfOperand =
false;
611 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
612 isAddressOfOperand,
nullptr,
false,
618 checkPotentialAngleBracket(E);
664 ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
670 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
676 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
677 if (Result.isUnset()) {
680 UnconsumeToken(Replacement);
681 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
683 assert(!Result.isUnset() &&
"Typo correction suggested a keyword replacement "
684 "for a previous keyword suggestion");
736 if (ParseLambdaIntroducer(Intro)) {
743 return ParseLambdaExpressionAfterIntroducer(Intro);
750 ExprResult Parser::TryParseLambdaExpression() {
752 && Tok.
is(tok::l_square)
753 &&
"Not at the start of a possible lambda expression.");
761 if (Next.is(tok::r_square) ||
762 Next.is(tok::equal) ||
763 (Next.is(tok::amp) &&
764 After.isOneOf(tok::r_square, tok::comma)) ||
765 (Next.is(tok::identifier) &&
766 After.is(tok::r_square)) ||
767 Next.is(tok::ellipsis)) {
768 return ParseLambdaExpression();
773 if (Next.is(tok::identifier) &&
After.is(tok::identifier))
783 TentativeParsingAction TPA(*
this);
784 LambdaIntroducerTentativeParse Tentative;
785 if (ParseLambdaIntroducer(Intro, &Tentative)) {
791 case LambdaIntroducerTentativeParse::Success:
795 case LambdaIntroducerTentativeParse::Incomplete:
800 if (ParseLambdaIntroducer(Intro))
804 case LambdaIntroducerTentativeParse::MessageSend:
805 case LambdaIntroducerTentativeParse::Invalid:
812 return ParseLambdaExpressionAfterIntroducer(Intro);
825 LambdaIntroducerTentativeParse *Tentative) {
827 *Tentative = LambdaIntroducerTentativeParse::Success;
829 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
839 auto Invalid = [&](llvm::function_ref<void()> Action) {
841 *Tentative = LambdaIntroducerTentativeParse::Invalid;
850 auto NonTentativeAction = [&](llvm::function_ref<void()> Action) {
852 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
858 if (Tok.
is(tok::amp) &&
868 }
else if (Tok.
is(tok::equal)) {
875 while (Tok.
isNot(tok::r_square)) {
877 if (Tok.
isNot(tok::comma)) {
882 if (Tok.
is(tok::code_completion) &&
897 if (Tok.
is(tok::code_completion)) {
920 if (Tok.
is(tok::star)) {
922 if (Tok.
is(tok::kw_this)) {
930 }
else if (Tok.
is(tok::kw_this)) {
933 }
else if (Tok.
isOneOf(tok::amp, tok::equal) &&
945 if (Tok.
is(tok::amp)) {
949 if (Tok.
is(tok::code_completion)) {
959 if (Tok.
is(tok::identifier)) {
962 }
else if (Tok.
is(tok::kw_this)) {
975 if (Tok.
is(tok::l_paren)) {
977 Parens.consumeOpen();
985 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
986 }
else if (ParseExpressionList(Exprs, Commas)) {
990 Parens.consumeClose();
992 Parens.getCloseLocation(),
995 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
1008 Init = ParseInitializer();
1009 }
else if (Tok.
is(tok::l_brace)) {
1011 Braces.consumeOpen();
1013 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1037 Init = ParseInitializer();
1038 if (!Init.isInvalid())
1047 Tok.
setKind(tok::annot_primary_expr);
1048 setExprAnnotation(Tok, Init);
1053 ConsumeAnnotationToken();
1062 if (Tentative && Tok.
is(tok::identifier) &&
1065 *Tentative = LambdaIntroducerTentativeParse::MessageSend;
1071 if (llvm::any_of(EllipsisLocs,
1077 !InitCapture ? &EllipsisLocs[2] :
1080 EllipsisLoc = *ExpectedEllipsisLoc;
1082 unsigned DiagID = 0;
1084 DiagID = diag::err_lambda_capture_misplaced_ellipsis;
1090 unsigned NumEllipses = std::accumulate(
1091 std::begin(EllipsisLocs), std::end(EllipsisLocs), 0,
1093 if (NumEllipses > 1)
1094 DiagID = diag::err_lambda_capture_multiple_ellipses;
1097 NonTentativeAction([&] {
1101 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid()) {
1106 assert(DiagLoc.
isValid() &&
"no location for diagnostic");
1110 auto &&D =
Diag(DiagLoc, DiagID);
1111 if (DiagID == diag::err_lambda_capture_misplaced_ellipsis) {
1119 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid())
1131 if (Init.isUsable())
1133 if (Init.isUsable()) {
1134 NonTentativeAction([&] {
1137 Expr *InitExpr = Init.get();
1169 switch (
P.getCurToken().getKind()) {
1170 case tok::kw_mutable: {
1172 P.Diag(
P.getCurToken().getLocation(),
1173 diag::err_lambda_decl_specifier_repeated)
1176 MutableLoc =
P.ConsumeToken();
1177 DeclEndLoc = MutableLoc;
1180 case tok::kw_constexpr:
1182 P.Diag(
P.getCurToken().getLocation(),
1183 diag::err_lambda_decl_specifier_repeated)
1186 ConstexprLoc =
P.ConsumeToken();
1187 DeclEndLoc = ConstexprLoc;
1189 case tok::kw_consteval:
1191 P.Diag(
P.getCurToken().getLocation(),
1192 diag::err_lambda_decl_specifier_repeated)
1195 ConstevalLoc =
P.ConsumeToken();
1196 DeclEndLoc = ConstevalLoc;
1208 P.Diag(ConstexprLoc, !
P.getLangOpts().CPlusPlus17
1209 ? diag::ext_constexpr_on_lambda_cxx17
1210 : diag::warn_cxx14_compat_constexpr_on_lambda);
1211 const char *PrevSpec =
nullptr;
1212 unsigned DiagID = 0;
1215 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1216 "Constexpr cannot have been set previously!");
1224 P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval);
1225 const char *PrevSpec =
nullptr;
1226 unsigned DiagID = 0;
1230 P.Diag(ConstevalLoc, DiagID) << PrevSpec;
1236 ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1239 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1242 "lambda expression parsing");
1252 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1259 MaybeParseGNUAttributes(D);
1264 auto WarnIfHasCUDATargetAttr = [&] {
1267 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1268 A.getKind() == ParsedAttr::AT_CUDAHost ||
1269 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1270 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1271 << A.getAttrName()->getName();
1274 MultiParseScope TemplateParamScope(*
this);
1275 if (Tok.
is(tok::less)) {
1277 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1278 : diag::ext_lambda_template_parameter_list);
1282 if (ParseTemplateParameters(TemplateParamScope,
1283 CurTemplateDepthTracker.getDepth(),
1284 TemplateParams, LAngleLoc, RAngleLoc)) {
1289 if (TemplateParams.empty()) {
1291 diag::err_lambda_template_parameter_list_empty);
1303 LAngleLoc, TemplateParams, RAngleLoc, RequiresClause);
1304 ++CurTemplateDepthTracker;
1312 if (isCXX11AttributeSpecifier()) {
1314 ? diag::warn_cxx20_compat_decl_attrs_on_lambda
1315 : diag::ext_decl_attrs_on_lambda);
1316 MaybeParseCXX11Attributes(D);
1322 auto ParseLambdaSpecifiers =
1331 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec,
Attr);
1339 ConstevalLoc, DeclEndLoc);
1350 ESpecType = tryParseExceptionSpecification(
1351 false, ESpecRange, DynamicExceptions,
1352 DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
1355 DeclEndLoc = ESpecRange.
getEnd();
1358 if (MaybeParseCXX11Attributes(
Attr))
1359 DeclEndLoc =
Attr.Range.getEnd();
1362 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1363 tok::kw___constant, tok::kw___generic)) {
1364 ParseOpenCLQualifiers(DS.getAttributes());
1371 if (Tok.
is(tok::arrow)) {
1374 TrailingReturnType = ParseTrailingReturnType(
1376 TrailingReturnTypeLoc =
Range.getBegin();
1377 if (
Range.getEnd().isValid())
1378 DeclEndLoc =
Range.getEnd();
1385 false, LParenLoc, ParamInfo.data(),
1386 ParamInfo.size(), EllipsisLoc, RParenLoc,
1388 NoLoc, MutableLoc, ESpecType, ESpecRange,
1389 DynamicExceptions.data(), DynamicExceptionRanges.data(),
1390 DynamicExceptions.size(),
1391 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1393 None, LParenLoc, FunLocalRangeEnd, D,
1394 TrailingReturnType, TrailingReturnTypeLoc, &DS),
1395 std::move(
Attr), DeclEndLoc);
1398 if (Tok.
is(tok::l_paren)) {
1411 if (Tok.
isNot(tok::r_paren)) {
1413 CurTemplateDepthTracker.getOriginalDepth());
1415 ParseParameterDeclarationClause(D.getContext(),
Attr, ParamInfo,
1423 CurTemplateDepthTracker.setAddedDepth(1);
1429 ParseLambdaSpecifiers(LParenLoc, T.getCloseLocation(),
1430 ParamInfo, EllipsisLoc);
1433 if (Tok.
is(tok::kw_requires))
1434 ParseTrailingRequiresClause(D);
1435 }
else if (Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1436 tok::kw_constexpr, tok::kw_consteval,
1437 tok::kw___private, tok::kw___global, tok::kw___local,
1438 tok::kw___constant, tok::kw___generic,
1439 tok::kw_requires, tok::kw_noexcept) ||
1440 (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square))) {
1445 Diag(Tok, diag::ext_lambda_missing_parens)
1450 std::vector<DeclaratorChunk::ParamInfo> EmptyParamInfo;
1451 ParseLambdaSpecifiers(NoLoc, NoLoc,
1452 EmptyParamInfo, NoLoc);
1455 WarnIfHasCUDATargetAttr();
1461 ParseScope BodyScope(
this, ScopeFlags);
1466 if (!Tok.
is(tok::l_brace)) {
1467 Diag(Tok, diag::err_expected_lambda_body);
1474 TemplateParamScope.Exit();
1496 const char *CastName =
nullptr;
1499 default: llvm_unreachable(
"Unknown C++ cast!");
1500 case tok::kw_addrspace_cast: CastName =
"addrspace_cast";
break;
1501 case tok::kw_const_cast: CastName =
"const_cast";
break;
1502 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1503 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1504 case tok::kw_static_cast: CastName =
"static_cast";
break;
1512 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1514 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1518 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1523 ParseSpecifierQualifierList(DS);
1527 ParseDeclarator(DeclaratorInfo);
1531 if (ExpectAndConsume(tok::greater))
1532 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1536 if (T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1544 if (!Result.isInvalid() && !DeclaratorInfo.isInvalidType())
1546 LAngleBracketLoc, DeclaratorInfo,
1548 T.getOpenLocation(), Result.get(),
1549 T.getCloseLocation());
1561 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1568 if (T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1570 LParenLoc = T.getOpenLocation();
1591 if (isTypeIdInParens()) {
1596 RParenLoc = T.getCloseLocation();
1601 Ty.
get().getAsOpaquePtr(), RParenLoc);
1606 if (Result.isInvalid())
1610 RParenLoc = T.getCloseLocation();
1615 Result.get(), RParenLoc);
1628 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1634 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1639 if (isTypeIdInParens()) {
1648 Result = Actions.
ActOnCXXUuidof(OpLoc, T.getOpenLocation(),
true,
1649 Ty.
get().getAsOpaquePtr(),
1650 T.getCloseLocation());
1657 if (Result.isInvalid())
1664 Result.get(), T.getCloseLocation());
1711 if (Tok.
is(tok::identifier)) {
1714 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1716 }
else if (Tok.
is(tok::annot_template_id)) {
1722 ConsumeAnnotationToken();
1723 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1726 assert(SS.
isEmpty() &&
"missing last component of nested name specifier");
1731 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1734 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid()) {
1736 ParseDecltypeSpecifier(DS);
1743 if (!Tok.
is(tok::identifier)) {
1744 Diag(Tok, diag::err_destructor_tilde_identifier);
1762 if (Tok.
is(tok::less) &&
1763 ParseUnqualifiedIdTemplateId(
1765 Name, NameLoc,
false, SecondTypeName,
1770 SS, FirstTypeName, CCLoc, TildeLoc,
1789 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1815 ExprResult Parser::ParseCoyieldExpression() {
1816 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1821 if (!
Expr.isInvalid())
1832 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1851 Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1855 assert((Tok.
is(tok::l_paren) ||
1857 &&
"Expected '(' or '{'!");
1859 if (Tok.
is(tok::l_brace)) {
1862 if (Init.isInvalid())
1864 Expr *InitList = Init.get();
1875 CommaLocsTy CommaLocs;
1877 auto RunSignatureHelp = [&]() {
1882 T.getOpenLocation(),
false);
1883 CalledSignatureHelp =
true;
1884 return PreferredType;
1887 if (Tok.
isNot(tok::r_paren)) {
1888 if (ParseExpressionList(Exprs, CommaLocs, [&] {
1889 PreferredType.enterFunctionArgument(Tok.
getLocation(),
1906 assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
1907 "Unexpected number of commas!");
1909 Exprs, T.getCloseLocation(),
1917 assert(Tok.
is(tok::kw_using) &&
"Expected using");
1920 "Unexpected Declarator Context");
1924 DG = ParseUsingDeclaration(Context, {}, DeclStart, DeclEnd, Attrs,
AS_none);
1929 ? diag::ext_alias_in_init_statement
1930 : diag::warn_cxx20_alias_in_init_statement)
1970 ForRangeInfo *FRI,
bool EnterForConditionScope) {
1972 struct ForConditionScopeRAII {
1974 void enter(
bool IsConditionVariable) {
1977 S->setIsConditionVarScope(IsConditionVariable);
1980 ~ForConditionScopeRAII() {
1982 S->setIsConditionVarScope(
false);
1984 } ForConditionScope{EnterForConditionScope ?
getCurScope() : nullptr};
1987 PreferredType.enterCondition(Actions, Tok.
getLocation());
1989 if (Tok.
is(tok::code_completion)) {
1996 MaybeParseCXX11Attributes(attrs);
1998 const auto WarnOnInit = [
this, &CK] {
2000 ? diag::warn_cxx14_compat_init_statement
2001 : diag::ext_init_statement)
2006 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
2007 case ConditionOrInitStatement::Expression: {
2009 ForConditionScope.enter(
false);
2011 ProhibitAttributes(attrs);
2015 if (InitStmt && Tok.
is(tok::semi)) {
2019 Diag(SemiLoc, diag::warn_empty_init_statement)
2025 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2030 if (
Expr.isInvalid())
2033 if (InitStmt && Tok.
is(tok::semi)) {
2037 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2044 case ConditionOrInitStatement::InitStmtDecl: {
2048 if (Tok.
is(tok::kw_using))
2049 DG = ParseAliasDeclarationInInitStatement(
2055 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2058 case ConditionOrInitStatement::ForRangeDecl: {
2062 assert(FRI &&
"should not parse a for range declaration here");
2065 DeclEnd, attrs,
false, FRI);
2067 assert((FRI->ColonLoc.isValid() || !DG) &&
2068 "cannot find for range declaration");
2072 case ConditionOrInitStatement::ConditionDecl:
2073 case ConditionOrInitStatement::Error:
2078 ForConditionScope.enter(
true);
2083 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2087 ParseDeclarator(DeclaratorInfo);
2090 if (Tok.
is(tok::kw_asm)) {
2092 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2093 if (AsmLabel.isInvalid()) {
2097 DeclaratorInfo.setAsmLabel(AsmLabel.get());
2098 DeclaratorInfo.SetRangeEnd(Loc);
2102 MaybeParseGNUAttributes(DeclaratorInfo);
2113 bool CopyInitialization = isTokenEqualOrEqualTypo();
2114 if (CopyInitialization)
2120 diag::warn_cxx98_compat_generalized_initializer_lists);
2121 InitExpr = ParseBraceInitializer();
2122 }
else if (CopyInitialization) {
2123 PreferredType.enterVariableInit(Tok.
getLocation(), DeclOut);
2125 }
else if (Tok.
is(tok::l_paren)) {
2129 RParen = ConsumeParen();
2131 diag::err_expected_init_in_condition_lparen)
2172 void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2174 const char *PrevSpec;
2181 case tok::identifier:
2182 case tok::coloncolon:
2183 llvm_unreachable(
"Annotation token should already be formed!");
2185 llvm_unreachable(
"Not a simple-type-specifier token!");
2188 case tok::annot_typename: {
2192 ConsumeAnnotationToken();
2194 DS.
Finish(Actions, Policy);
2198 case tok::kw__ExtInt:
2199 case tok::kw__BitInt: {
2200 DiagnoseBitIntUse(Tok);
2209 DS.
Finish(Actions, Policy);
2222 case tok::kw___int64:
2226 case tok::kw_signed:
2229 case tok::kw_unsigned:
2244 case tok::kw___int128:
2247 case tok::kw___bf16:
2256 case tok::kw_double:
2259 case tok::kw__Float16:
2262 case tok::kw___float128:
2265 case tok::kw___ibm128:
2268 case tok::kw_wchar_t:
2271 case tok::kw_char8_t:
2274 case tok::kw_char16_t:
2277 case tok::kw_char32_t:
2283 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
2284 case tok::kw_##ImgType##_t: \
2285 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
2288 #include "clang/Basic/OpenCLImageTypes.def"
2290 case tok::annot_decltype:
2291 case tok::kw_decltype:
2293 return DS.
Finish(Actions, Policy);
2296 case tok::kw_typeof:
2297 ParseTypeofSpecifier(DS);
2298 DS.
Finish(Actions, Policy);
2303 DS.
Finish(Actions, Policy);
2317 bool Parser::ParseCXXTypeSpecifierSeq(
DeclSpec &DS) {
2318 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_type_specifier);
2358 bool Parser::ParseUnqualifiedIdTemplateId(
2362 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2366 switch (
Id.getKind()) {
2370 if (AssumeTemplateId) {
2374 ObjectType, EnteringContext, Template,
2377 bool MemberOfUnknownSpecialization;
2380 ObjectType, EnteringContext, Template,
2381 MemberOfUnknownSpecialization);
2386 isTemplateArgumentList(0) == TPResult::False)
2390 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2393 if (!ObjectHadErrors) {
2406 Name +=
Id.Identifier->getName();
2408 Diag(
Id.StartLocation, diag::err_missing_dependent_template_keyword)
2413 getCurScope(), SS, TemplateKWLoc,
Id, ObjectType, EnteringContext,
2423 bool MemberOfUnknownSpecialization;
2427 EnteringContext, Template,
2428 MemberOfUnknownSpecialization);
2436 bool MemberOfUnknownSpecialization;
2441 EnteringContext, Template,
true);
2445 EnteringContext, Template,
2446 MemberOfUnknownSpecialization);
2449 Diag(NameLoc, diag::err_destructor_template_id)
2463 TemplateArgList TemplateArgs;
2464 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs, RAngleLoc,
2485 :
Id.OperatorFunctionId.Operator;
2488 TemplateKWLoc,
Id.StartLocation, TemplateII, OpKind, Template, TNK,
2489 LAngleLoc, RAngleLoc, TemplateArgs,
false, TemplateIds);
2491 Id.setTemplateId(TemplateId);
2500 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2501 TemplateArgsPtr, RAngleLoc,
true);
2502 if (
Type.isInvalid())
2506 Id.setConstructorName(
Type.get(), NameLoc, RAngleLoc);
2508 Id.setDestructorName(
Id.StartLocation,
Type.get(), RAngleLoc);
2553 bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2556 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2562 unsigned SymbolIdx = 0;
2567 case tok::kw_delete: {
2568 bool isNew = Tok.
getKind() == tok::kw_new;
2572 if (Tok.
is(tok::l_square) &&
2578 if (T.getCloseLocation().isInvalid())
2581 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2582 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2583 Op = isNew? OO_Array_New : OO_Array_Delete;
2585 Op = isNew? OO_New : OO_Delete;
2590 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2592 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2595 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2596 #include "clang/Basic/OperatorKinds.def"
2598 case tok::l_paren: {
2603 if (T.getCloseLocation().isInvalid())
2606 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2607 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2612 case tok::l_square: {
2617 if (T.getCloseLocation().isInvalid())
2620 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2621 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2626 case tok::code_completion: {
2640 Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations);
2654 unsigned DiagId = 0;
2660 while (isTokenStringLiteral()) {
2661 if (!Tok.
is(tok::string_literal) && !DiagId) {
2666 DiagId = diag::err_literal_operator_string_prefix;
2668 Toks.push_back(Tok);
2669 TokLocs.push_back(ConsumeStringToken());
2678 bool IsUDSuffix = !
Literal.getUDSuffix().empty();
2687 }
else if (Tok.
is(tok::identifier)) {
2690 TokLocs.push_back(SuffixLoc);
2702 DiagLoc = TokLocs.front();
2703 DiagId = diag::err_literal_operator_string_not_empty;
2713 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2716 Result.setLiteralOperatorId(II, KeywordLoc, SuffixLoc);
2734 if (ParseCXXTypeSpecifierSeq(DS))
2740 ParseDeclaratorInternal(D,
nullptr);
2748 Result.setConversionFunctionId(KeywordLoc, Ty.
get(),
2749 D.getSourceRange().getEnd());
2790 bool ObjectHadErrors,
bool EnteringContext,
2791 bool AllowDestructorName,
2792 bool AllowConstructorName,
2793 bool AllowDeductionGuide,
2801 bool TemplateSpecified =
false;
2802 if (Tok.
is(tok::kw_template)) {
2803 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2804 TemplateSpecified =
true;
2808 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2816 if (Tok.
is(tok::identifier)) {
2824 Result.setIdentifier(
Id, IdLoc);
2829 if (AllowConstructorName &&
2836 Result.setConstructorName(Ty, IdLoc, IdLoc);
2838 AllowDeductionGuide && SS.
isEmpty() &&
2845 Result.setIdentifier(
Id, IdLoc);
2850 if (Tok.
is(tok::less))
2851 return ParseUnqualifiedIdTemplateId(
2852 SS, ObjectType, ObjectHadErrors,
2854 EnteringContext, Result, TemplateSpecified);
2855 else if (TemplateSpecified &&
2857 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2858 EnteringContext, Template,
2867 if (Tok.
is(tok::annot_template_id)) {
2873 ConsumeAnnotationToken();
2878 if (AllowConstructorName && TemplateId->
Name &&
2886 diag::err_out_of_line_constructor_template_id)
2897 ConsumeAnnotationToken();
2901 Result.setConstructorTemplateId(TemplateId);
2902 ConsumeAnnotationToken();
2908 Result.setTemplateId(TemplateId);
2911 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
2912 *TemplateKWLoc = TemplateLoc;
2914 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2917 ConsumeAnnotationToken();
2924 if (Tok.
is(tok::kw_operator)) {
2925 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result))
2937 return ParseUnqualifiedIdTemplateId(
2938 SS, ObjectType, ObjectHadErrors,
2941 else if (TemplateSpecified &&
2943 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2944 EnteringContext, Template,
2952 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
2961 if (TemplateSpecified) {
2972 Diag(*TemplateKWLoc, diag::err_unexpected_template_in_destructor_name)
2977 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
2982 Result.setDestructorName(TildeLoc,
Type, EndLoc);
2989 if (Tok.
isNot(tok::identifier)) {
2990 Diag(Tok, diag::err_destructor_tilde_identifier);
2995 DeclaratorScopeObj DeclScopeObj(*
this, SS);
3003 AnnotateScopeToken(SS,
true);
3006 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, ObjectHadErrors,
3010 ObjectType =
nullptr;
3011 if (Tok.
isNot(tok::identifier) ||
NextToken().is(tok::coloncolon) ||
3013 Diag(TildeLoc, diag::err_destructor_tilde_scope);
3018 Diag(TildeLoc, diag::err_destructor_tilde_scope)
3024 DeclScopeObj.EnterDeclaratorScope();
3031 if (Tok.
is(tok::less)) {
3032 Result.setDestructorName(TildeLoc,
nullptr, ClassNameLoc);
3033 return ParseUnqualifiedIdTemplateId(
3034 SS, ObjectType, ObjectHadErrors,
3036 ClassNameLoc, EnteringContext, Result, TemplateSpecified);
3047 Result.setDestructorName(TildeLoc, Ty, ClassNameLoc);
3051 Diag(Tok, diag::err_expected_unqualified_id)
3085 Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
3086 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
3092 ExprVector PlacementArgs;
3098 if (Tok.
is(tok::l_paren)) {
3102 PlacementLParen = T.getOpenLocation();
3103 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
3109 PlacementRParen = T.getCloseLocation();
3115 if (PlacementArgs.empty()) {
3117 TypeIdParens = T.getRange();
3121 if (Tok.
is(tok::l_paren)) {
3124 MaybeParseGNUAttributes(DeclaratorInfo);
3125 ParseSpecifierQualifierList(DS);
3127 ParseDeclarator(DeclaratorInfo);
3129 TypeIdParens = T.getRange();
3131 MaybeParseGNUAttributes(DeclaratorInfo);
3132 if (ParseCXXTypeSpecifierSeq(DS))
3133 DeclaratorInfo.setInvalidType(
true);
3136 ParseDeclaratorInternal(DeclaratorInfo,
3137 &Parser::ParseDirectNewDeclarator);
3144 MaybeParseGNUAttributes(DeclaratorInfo);
3145 if (ParseCXXTypeSpecifierSeq(DS))
3146 DeclaratorInfo.setInvalidType(
true);
3149 ParseDeclaratorInternal(DeclaratorInfo,
3150 &Parser::ParseDirectNewDeclarator);
3153 if (DeclaratorInfo.isInvalidType()) {
3160 if (Tok.
is(tok::l_paren)) {
3162 ExprVector ConstructorArgs;
3165 ConstructorLParen = T.getOpenLocation();
3166 if (Tok.
isNot(tok::r_paren)) {
3167 CommaLocsTy CommaLocs;
3168 auto RunSignatureHelp = [&]() {
3178 DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen,
3180 CalledSignatureHelp =
true;
3181 return PreferredType;
3183 if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
3184 PreferredType.enterFunctionArgument(Tok.
getLocation(),
3194 ConstructorRParen = T.getCloseLocation();
3204 diag::warn_cxx98_compat_generalized_initializer_lists);
3210 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3211 PlacementArgs, PlacementRParen,
3222 void Parser::ParseDirectNewDeclarator(
Declarator &D) {
3225 while (Tok.
is(tok::l_square)) {
3227 if (CheckProhibitedCXX11Attribute())
3236 if (
Size.isInvalid()) {
3247 MaybeParseCXX11Attributes(Attrs);
3251 Size.get(), T.getOpenLocation(),
3252 T.getCloseLocation()),
3253 std::move(Attrs), T.getCloseLocation());
3255 if (T.getCloseLocation().isInvalid())
3270 bool Parser::ParseExpressionListOrTypeId(
3274 if (isTypeIdInParens()) {
3283 CommaLocsTy CommaLocs;
3284 return ParseExpressionList(PlacementArgs, CommaLocs);
3299 Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3300 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3304 bool ArrayDelete =
false;
3305 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::r_square)) {
3313 const Token Next = GetLookAheadToken(2);
3316 if (Next.isOneOf(tok::l_brace, tok::less) ||
3317 (Next.is(tok::l_paren) &&
3318 (GetLookAheadToken(3).is(tok::r_paren) ||
3319 (GetLookAheadToken(3).is(tok::identifier) &&
3320 GetLookAheadToken(4).is(tok::identifier))))) {
3321 TentativeParsingAction TPA(*
this);
3329 bool EmitFixIt =
false;
3330 if (Tok.
is(tok::l_brace)) {
3340 Diag(Start, diag::err_lambda_after_delete)
3348 Diag(Start, diag::err_lambda_after_delete)
3358 Lambda = ParsePostfixExpressionSuffix(Lambda);
3370 if (T.getCloseLocation().isInvalid())
3405 ExprResult Parser::ParseRequiresExpression() {
3406 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3410 if (Tok.
is(tok::l_paren)) {
3415 Parens.consumeOpen();
3416 if (!Tok.
is(tok::r_paren)) {
3421 FirstArgAttrs, LocalParameters,
3424 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3425 for (
auto &ParamInfo : LocalParameters)
3426 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3428 Parens.consumeClose();
3432 if (Braces.expectAndConsume())
3445 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3447 if (Tok.
is(tok::r_brace)) {
3454 Diag(Tok, diag::err_empty_requires_expr);
3457 while (!Tok.
is(tok::r_brace)) {
3459 case tok::l_brace: {
3470 ExprBraces.consumeOpen();
3474 ExprBraces.skipToEnd();
3475 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3478 if (ExprBraces.consumeClose())
3479 ExprBraces.skipToEnd();
3484 if (Tok.
is(tok::semi)) {
3487 Requirements.push_back(Req);
3492 Diag(Tok, diag::err_requires_expr_missing_arrow)
3495 if (TryAnnotateTypeConstraint()) {
3496 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3499 if (!isTypeConstraintAnnotation()) {
3500 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3501 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3505 if (Tok.
is(tok::annot_cxxscope)) {
3509 ConsumeAnnotationToken();
3513 Expression.get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3514 TemplateParameterDepth);
3515 ConsumeAnnotationToken();
3517 Requirements.push_back(Req);
3521 bool PossibleRequiresExprInSimpleRequirement =
false;
3522 if (Tok.
is(tok::kw_requires)) {
3523 auto IsNestedRequirement = [&] {
3524 RevertingTentativeParsingAction TPA(*
this);
3526 if (Tok.
is(tok::l_brace))
3533 if (Tok.
is(tok::l_paren)) {
3536 auto Res = TryParseParameterDeclarationClause();
3537 if (Res != TPResult::False) {
3542 while (
Depth != 0) {
3543 if (Tok.
is(tok::l_paren))
3545 else if (Tok.
is(tok::r_paren))
3556 if (Tok.
is(tok::l_brace))
3565 if (IsNestedRequirement()) {
3575 SkipUntilFlags::StopBeforeMatch);
3580 Requirements.push_back(Req);
3583 SkipUntilFlags::StopBeforeMatch);
3588 PossibleRequiresExprInSimpleRequirement =
true;
3589 }
else if (Tok.
is(tok::kw_typename)) {
3592 TentativeParsingAction TPA(*
this);
3598 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3602 if (Tok.
is(tok::annot_cxxscope)) {
3605 ConsumeAnnotationToken();
3608 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3614 if (Tok.
is(tok::identifier)) {
3618 TemplateId = takeTemplateIdAnnotation(Tok);
3619 ConsumeAnnotationToken();
3627 Requirements.push_back(Req);
3641 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3644 if (!
Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
3645 Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
3648 Requirements.push_back(Req);
3650 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3654 if (Tok.
is(tok::kw_noexcept)) {
3655 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3658 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3664 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3665 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3670 if (Requirements.empty()) {
3674 Braces.consumeClose();
3679 Braces.consumeClose();
3682 Requirements, Braces.getCloseLocation());
3687 default: llvm_unreachable(
"Not a known type trait");
3688 #define TYPE_TRAIT_1(Spelling, Name, Key) \
3689 case tok::kw_ ## Spelling: return UTT_ ## Name;
3690 #define TYPE_TRAIT_2(Spelling, Name, Key) \
3691 case tok::kw_ ## Spelling: return BTT_ ## Name;
3692 #include "clang/Basic/TokenKinds.def"
3693 #define TYPE_TRAIT_N(Spelling, Name, Key) \
3694 case tok::kw_ ## Spelling: return TT_ ## Name;
3695 #include "clang/Basic/TokenKinds.def"
3702 llvm_unreachable(
"Not a known array type trait");
3703 #define ARRAY_TYPE_TRAIT(Spelling, Name, Key) \
3704 case tok::kw_##Spelling: \
3706 #include "clang/Basic/TokenKinds.def"
3713 llvm_unreachable(
"Not a known unary expression trait.");
3714 #define EXPRESSION_TRAIT(Spelling, Name, Key) \
3715 case tok::kw_##Spelling: \
3717 #include "clang/Basic/TokenKinds.def"
3723 default: llvm_unreachable(
"Not a known type trait");
3724 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N;
3725 #include "clang/Basic/TokenKinds.def"
3747 if (Parens.expectAndConsume())
3760 if (Tok.
is(tok::ellipsis)) {
3769 Args.push_back(Ty.
get());
3772 if (Parens.consumeClose())
3777 if (Arity && Args.size() != Arity) {
3778 Diag(EndLoc, diag::err_type_trait_arity)
3779 << Arity << 0 << (Arity > 1) << (
int)Args.size() <<
SourceRange(Loc);
3783 if (!Arity && Args.empty()) {
3784 Diag(EndLoc, diag::err_type_trait_arity)
3804 if (T.expectAndConsume())
3815 case ATT_ArrayRank: {
3818 T.getCloseLocation());
3820 case ATT_ArrayExtent: {
3821 if (ExpectAndConsume(tok::comma)) {
3830 T.getCloseLocation());
3833 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3847 if (T.expectAndConsume())
3855 T.getCloseLocation());
3863 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
3868 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
3869 assert(isTypeIdInParens() &&
"Not a type-id!");
3893 ParenParseOption ParseAs;
3898 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3904 if (Tok.
is(tok::l_brace)) {
3905 ParseAs = CompoundLiteral;
3908 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::r_paren)) {
3915 Result = ParseCastExpression(AnyCastExpr,
3924 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
3933 Toks.push_back(AttrEnd);
3936 Toks.push_back(Tok);
3939 PP.EnterTokenStream(Toks,
true,
3945 if (ParseAs >= CompoundLiteral) {
3951 ParseSpecifierQualifierList(DS);
3952 ParseDeclarator(DeclaratorInfo);
3963 if (ParseAs == CompoundLiteral) {
3964 ExprType = CompoundLiteral;
3965 if (DeclaratorInfo.isInvalidType())
3969 return ParseCompoundLiteralExpression(Ty.
get(),
3977 if (DeclaratorInfo.isInvalidType())
3981 if (!Result.isInvalid())
3983 DeclaratorInfo, CastTy,
3989 assert(ParseAs == SimpleExpr);
3991 ExprType = SimpleExpr;
3993 if (!Result.isInvalid() && Tok.
is(tok::r_paren))
3998 if (Result.isInvalid()) {
4018 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
4023 ParseSpecifierQualifierList(DS);
4027 ParseDeclarator(DeclaratorInfo);
4029 if (ExpectAndConsume(tok::comma)) {
4037 if (T.consumeClose())
4040 if (
Operand.isInvalid() || DeclaratorInfo.isInvalidType())
4044 T.getCloseLocation());