Lines Matching +full:semi +full:- +full:static

1 //===--- ParseDecl.cpp - Declaration Parsing --------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
41 //===----------------------------------------------------------------------===//
43 //===----------------------------------------------------------------------===//
46 /// type-name: [C99 6.7.6]
47 /// specifier-qualifier-list abstract-declarator[opt]
49 /// Called type-id in C++.
57 // Parse the common declaration-specifiers piece. in ParseTypeName()
74 Attrs->takeOneFrom(DS.getAttributes(), AL); in ParseTypeName()
77 // Parse the abstract-declarator, if present. in ParseTypeName()
90 static StringRef normalizeAttrName(StringRef Name) { in normalizeAttrName()
98 static bool IsAttributeLateParsedExperimentalExt(const IdentifierInfo &II) { in IsAttributeLateParsedExperimentalExt()
108 static bool IsAttributeLateParsedStandard(const IdentifierInfo &II) { in IsAttributeLateParsedStandard()
117 static bool FindLocsWithCommonFileID(Preprocessor &PP, SourceLocation StartLoc, in FindLocsWithCommonFileID()
149 /// ParseGNUAttributes - Parse a non-empty attributes list.
156 /// '__attribute__' '(' '(' attribute-list ')' ')'
158 /// [GNU] attribute-list:
164 /// attrib-name
165 /// attrib-name '(' identifier ')'
166 /// attrib-name '(' identifier ',' nonempty-expr-list ')'
167 /// attrib-name '(' argument-expression-list [C99 6.5.2] ')'
169 /// [GNU] attrib-name:
176 /// attrib-name. GCC's behavior here is not worth imitating:
200 unsigned OldNumLateAttrs = LateAttrs ? LateAttrs->size() : 0; in ParseGNUAttributes()
211 // Parse the attribute-list. e.g. __attribute__(( weak, alias("__f") )) in ParseGNUAttributes()
241 else if (LateAttrs->lateAttrParseExperimentalExtOnly()) { in ParseGNUAttributes()
266 LateAttrs->push_back(LA); in ParseGNUAttributes()
269 // with other late-parsed declarations. in ParseGNUAttributes()
270 if (!ClassStack.empty() && !LateAttrs->parseSoon()) in ParseGNUAttributes()
275 LA->Toks.push_back(Tok); in ParseGNUAttributes()
278 ConsumeAndStoreUntil(tok::r_paren, LA->Toks, /*StopAtSemi=*/true); in ParseGNUAttributes()
283 LA->Toks.push_back(Eof); in ParseGNUAttributes()
307 for (unsigned i = OldNumLateAttrs; i < LateAttrs->size(); ++i) in ParseGNUAttributes()
308 (*LateAttrs)[i]->MacroII = MacroII; in ParseGNUAttributes()
317 static bool attributeHasIdentifierArg(const IdentifierInfo &II) { in attributeHasIdentifierArg()
326 static ParsedAttributeArgumentsProperties
336 static bool attributeHasVariadicIdentifierArg(const IdentifierInfo &II) { in attributeHasVariadicIdentifierArg()
345 static bool attributeTreatsKeywordThisAsIdentifier(const IdentifierInfo &II) { in attributeTreatsKeywordThisAsIdentifier()
354 static bool attributeAcceptsExprPack(const IdentifierInfo &II) { in attributeAcceptsExprPack()
363 static bool attributeIsTypeArgAttr(const IdentifierInfo &II) { in attributeIsTypeArgAttr()
372 static bool attributeHasStrictIdentifierArgs(const IdentifierInfo &II) { in attributeHasStrictIdentifierArgs()
382 static bool attributeHasStrictIdentifierArgAtIndex(const IdentifierInfo &II, in attributeHasStrictIdentifierArgAtIndex()
394 static bool attributeParsedArgsUnevaluated(const IdentifierInfo &II) { in attributeParsedArgsUnevaluated()
718 if (normalizeAttrName(AttrName->getName()) == "enable_if" && in ParseGNUAttributeArgs()
719 D && D->isFunctionDeclarator()) { in ParseGNUAttributeArgs()
720 DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo(); in ParseGNUAttributeArgs()
772 return !Attrs.empty() ? Attrs.begin()->getNumArgs() : 0; in ParseClangAttributeArgs()
792 if (AttrName->getName() == "property") { in ParseMicrosoftDeclSpecArgs()
799 AttrName->getNameStart(), tok::r_paren); in ParseMicrosoftDeclSpecArgs()
802 AK_Invalid = -1, in ParseMicrosoftDeclSpecArgs()
827 StringRef KindStr = Tok.getIdentifierInfo()->getName(); in ParseMicrosoftDeclSpecArgs()
897 // Only add the property attribute if it was well-formed. in ParseMicrosoftDeclSpecArgs()
919 /// [MS] decl-specifier:
920 /// __declspec ( extended-decl-modifier-seq )
922 /// [MS] extended-decl-modifier-seq:
923 /// extended-decl-modifier[opt]
924 /// extended-decl-modifier extended-decl-modifier-seq
953 // We expect either a well-known identifier or a generic string. Anything in ParseMicrosoftDeclSpecs()
985 else if (AttrName->getName() == "property") in ParseMicrosoftDeclSpecs()
988 << AttrName->getName(); in ParseMicrosoftDeclSpecs()
1152 static bool VersionNumberSeparator(const char Separator) { in VersionNumberSeparator()
1159 /// simple-integer
1160 /// simple-integer '.' simple-integer
1161 /// simple-integer '_' simple-integer
1162 /// simple-integer '.' simple-integer '.' simple-integer
1163 /// simple-integer '_' simple-integer '_' simple-integer
1192 Major = Major * 10 + ThisTokBegin[AfterMajor] - '0'; in ParseVersionTuple()
1228 Minor = Minor * 10 + ThisTokBegin[AfterMinor] - '0'; in ParseVersionTuple()
1261 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] - '0'; in ParseVersionTuple()
1277 /// availability-attribute:
1278 /// 'availability' '(' platform ',' opt-strict version-arg-list,
1279 /// opt-replacement, opt-message')'
1284 /// opt-strict:
1287 /// version-arg-list:
1288 /// version-arg
1289 /// version-arg ',' version-arg-list
1291 /// version-arg:
1296 /// opt-replacement:
1298 /// opt-message:
1323 if (const IdentifierInfo *const Ident = Platform->Ident) { in ParseAvailabilityAttribute()
1325 if (Ident->getName().contains("xrOS") || Ident->getName().contains("xros")) in ParseAvailabilityAttribute()
1326 Diag(Platform->Loc, diag::warn_availability_unknown_platform) << Ident; in ParseAvailabilityAttribute()
1328 else if (Ident->getName() == "macosx") in ParseAvailabilityAttribute()
1329 Platform->Ident = PP.getIdentifierInfo("macos"); in ParseAvailabilityAttribute()
1332 else if (Ident->getName() == "macosx_app_extension") in ParseAvailabilityAttribute()
1333 Platform->Ident = PP.getIdentifierInfo("macos_app_extension"); in ParseAvailabilityAttribute()
1335 Platform->Ident = PP.getIdentifierInfo( in ParseAvailabilityAttribute()
1336 AvailabilityAttr::canonicalizePlatformName(Ident->getName())); in ParseAvailabilityAttribute()
1388 if (Keyword == Ident_deprecated && Platform->Ident && in ParseAvailabilityAttribute()
1389 Platform->Ident->isStr("swift")) { in ParseAvailabilityAttribute()
1406 << Keyword << SourceRange(EnvironmentLoc->Loc); in ParseAvailabilityAttribute()
1446 if (NA->getName() == "NA") { in ParseAvailabilityAttribute()
1526 /// external-source-symbol-attribute:
1527 /// 'external_source_symbol' '(' keyword-arg-list ')'
1529 /// keyword-arg-list:
1530 /// keyword-arg
1531 /// keyword-arg ',' keyword-arg-list
1533 /// keyword-arg:
1592 Keyword->getName())) { in ParseExternalSourceSymbolAttribute()
1657 /// objc_bridge_related '(' related_class ',' opt-class_method ',' opt-instance_method ')'
1661 /// opt-class_method:
1664 /// opt-instance_method:
1690 // Parse class method name. It's non-optional in the sense that a trailing in ParseObjCBridgeRelatedAttribute()
1711 // Parse instance method name. Also non-optional but empty string is in ParseObjCBridgeRelatedAttribute()
1814 if (Flag->isStr("layout_compatible")) in ParseTypeTagForDatatypeAttribute()
1816 else if (Flag->isStr("must_be_null")) in ParseTypeTagForDatatypeAttribute()
1836 /// DiagnoseProhibitedCXX11Attribute - We have found the opening square brackets
1837 /// of a C++11 attribute-specifier in a location where an attribute is not
1838 /// permitted. By C++11 [dcl.attr.grammar]p6, this is ill-formed. Diagnose this
1841 /// \return \c true if we skipped an attribute-like chunk of tokens, \c false if
1842 /// this doesn't appear to actually be an attribute-specifier, and the caller
1849 // No diagnostic: we're in Obj-C++11 and this is not actually an attribute. in DiagnoseProhibitedCXX11Attribute()
1871 /// attribute-specifier in a location where an attribute is not permitted, but
1897 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in DiagnoseProhibitedAttributes()
1904 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in DiagnoseProhibitedAttributes()
1929 if (SecondLSquare && SecondLSquare->is(tok::l_square)) { in ProhibitCXX11Attributes()
1969 // class-key affects the type instead of the variable.
1970 // Also, Microsoft-style [attributes] seem to affect the type instead of the
1993 /// ParseDeclaration - Parse a full 'declaration', which consists of
1994 /// declaration-specifiers, some number of declarators, and a semicolon.
1999 /// block-declaration ->
2000 /// simple-declaration
2002 /// [C++] template-declaration
2003 /// [C++] namespace-definition
2004 /// [C++] using-directive
2005 /// [C++] using-declaration
2006 /// [C++11/C11] static_assert-declaration
2015 // Must temporarily exit the objective-c container scope for in ParseDeclaration()
2016 // parsing c none objective-c decls. in ParseDeclaration()
2067 /// simple-declaration: [C99 6.7: declaration] [C++ 7p1: dcl.dcl]
2068 /// declaration-specifiers init-declarator-list[opt] ';'
2069 /// [C++11] attribute-specifier-seq decl-specifier-seq[opt]
2070 /// init-declarator-list ';'
2071 ///[C90/C++]init-declarator-list ';' [TODO]
2072 /// [OMP] threadprivate-directive
2073 /// [OMP] allocate-directive [TODO]
2075 /// for-range-declaration: [C++11 6.5p1: stmt.ranged]
2076 /// attribute-specifier-seq[opt] type-specifier-seq declarator
2081 /// If FRI is non-null, we might be parsing a for-range-declaration instead
2082 /// of a simple-declaration. If we find that we are, we also parse the
2083 /// for-range-initializer, and place it here.
2085 /// DeclSpecStart is used when decl-specifiers are parsed before parsing
2087 /// DeclSpecStart if DeclSpecStart is non-null.
2097 // Parse the common declaration-specifiers piece. in ParseSimpleDeclaration()
2105 // If we had a free-standing type definition with a missing semicolon, we in ParseSimpleDeclaration()
2111 // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" in ParseSimpleDeclaration()
2112 // declaration-specifiers init-declarator-list[opt] ';' in ParseSimpleDeclaration()
2113 if (Tok.is(tok::semi)) { in ParseSimpleDeclaration()
2158 case tok::l_square: // Might be an attribute on an unnamed bit-field. in MightBeDeclarator()
2162 case tok::colon: // Might be a typo for '::' or an unnamed bit-field. in MightBeDeclarator()
2182 case tok::semi: in MightBeDeclarator()
2188 // this is a bit-field. in MightBeDeclarator()
2192 case tok::identifier: // Possible virt-specifier. in MightBeDeclarator()
2219 TryConsumeToken(tok::semi); in SkipMalformedDecl()
2235 case tok::semi: in SkipMalformedDecl()
2241 // a good place to pick back up parsing, except in an Objective-C in SkipMalformedDecl()
2250 // place to pick back up parsing, except in an Objective-C in SkipMalformedDecl()
2258 // @end is very much like } in Objective-C contexts. in SkipMalformedDecl()
2266 // - and + probably start new method declarations in Objective-C contexts. in SkipMalformedDecl()
2286 /// ParseDeclGroup - Having concluded that this is either a function
2315 // Bail out if the first declarator didn't seem well-formed. in ParseDeclGroup()
2327 // Save late-parsed attributes for now; they need to be parsed in the in ParseDeclGroup()
2346 Fixit &= Tok.isOneOf(tok::semi, tok::l_brace, tok::kw_try); in ParseDeclGroup()
2363 // (e.g. override) in an out-line method definition. in ParseDeclGroup()
2374 // start of a function definition in GCC-extended K&R C. in ParseDeclGroup()
2384 // used in the decl-specifier-seq of a parameter-declaration nor in in ParseDeclGroup()
2385 // the decl-specifier-seq of a function-definition. in ParseDeclGroup()
2399 // If the declarator-id is not a template-id, issue a diagnostic in ParseDeclGroup()
2439 // top-level code handle the erroneous declspec where it would in ParseDeclGroup()
2445 SkipUntil(tok::semi); in ParseDeclGroup()
2461 // C++0x [stmt.iter]p1: Check if we have a for-range-declarator. If so, we in ParseDeclGroup()
2462 // must parse and analyze the for-range-initializer before the declaration is in ParseDeclGroup()
2465 // Handle the Objective-C for-in loop variable similarly, although we in ParseDeclGroup()
2469 if (TryConsumeToken(tok::colon, FRI->ColonLoc)) { in ParseDeclGroup()
2477 // P2718R0 - Lifetime extension in range-based for loops. in ParseDeclGroup()
2486 FRI->RangeExpr = ParseBraceInitializer(); in ParseDeclGroup()
2488 FRI->RangeExpr = ParseExpression(); in ParseDeclGroup()
2497 FRI->LifetimeExtendTemps = std::move( in ParseDeclGroup()
2505 // Obj-C for loop in ParseDeclGroup()
2507 VD->setObjCForDecl(true); in ParseDeclGroup()
2530 // This comma was followed by a line-break and something which can't be in ParseDeclGroup()
2540 // In a template-declaration, explicit specialization, or explicit in ParseDeclGroup()
2541 // instantiation the init-declarator-list in the declaration shall in ParseDeclGroup()
2553 // Accept attributes in an init-declarator. In the first declarator in a in ParseDeclGroup()
2557 // short __attribute__((common)) var; -> declspec in ParseDeclGroup()
2558 // short var __attribute__((common)); -> declarator in ParseDeclGroup()
2559 // short x, __attribute__((common)) var; -> declarator in ParseDeclGroup()
2573 // init-declarator: in ParseDeclGroup()
2575 // declarator requires-clause in ParseDeclGroup()
2602 /// Parse an optional simple-asm-expr and attributes, and attach them to a
2605 // If a simple-asm-expr is present, parse it. in ParseAsmAttributesAfterDeclarator()
2610 SkipUntil(tok::semi, StopBeforeMatch); in ParseAsmAttributesAfterDeclarator()
2622 /// Parse 'declaration' after parsing 'declaration-specifiers
2627 /// init-declarator: [C99 6.7]
2630 /// [GNU] declarator simple-asm-expr[opt] attributes[opt]
2631 /// [GNU] declarator simple-asm-expr[opt] attributes[opt] '=' initializer
2635 /// [C++] '=' initializer-clause
2636 /// [C++] '(' expression-list ')'
2639 /// [C++0x] braced-init-list
2669 if (ThisDecl && !ThisDecl->isInvalidDecl()) { in ParseDeclarationAfterDeclaratorAndAttributes()
2719 // Re-direct this decl to refer to the templated decl so that we can in ParseDeclarationAfterDeclaratorAndAttributes()
2721 ThisDecl = VT->getTemplatedDecl(); in ParseDeclarationAfterDeclaratorAndAttributes()
2727 if (Tok.is(tok::semi)) { in ParseDeclarationAfterDeclaratorAndAttributes()
2731 SkipUntil(tok::semi, StopBeforeMatch); in ParseDeclarationAfterDeclaratorAndAttributes()
2740 // If the declarator-id is not a template-id, issue a diagnostic and in ParseDeclarationAfterDeclaratorAndAttributes()
2809 FRI->ColonLoc = EqualLoc; in ParseDeclarationAfterDeclaratorAndAttributes()
2811 FRI->RangeExpr = Init; in ParseDeclarationAfterDeclaratorAndAttributes()
2829 // Parse C++ direct initializer: '(' expression-list ')' in ParseDeclarationAfterDeclaratorAndAttributes()
2841 ThisVarDecl->getType()->getCanonicalTypeInternal(), in ParseDeclarationAfterDeclaratorAndAttributes()
2842 ThisDecl->getLocation(), Exprs, T.getOpenLocation(), in ParseDeclarationAfterDeclaratorAndAttributes()
2865 ThisVarDecl->getType()->getCanonicalTypeInternal(), in ParseDeclarationAfterDeclaratorAndAttributes()
2866 ThisDecl->getLocation(), Exprs, T.getOpenLocation(), in ParseDeclarationAfterDeclaratorAndAttributes()
2885 // Parse C++0x braced-init-list. in ParseDeclarationAfterDeclaratorAndAttributes()
2910 /// specifier-qualifier-list:
2911 /// type-specifier specifier-qualifier-list[opt]
2912 /// type-qualifier specifier-qualifier-list[opt]
2913 /// [GNU] attributes specifier-qualifier-list[opt]
2919 /// specifier-qualifier-list is a subset of declaration-specifiers. Just in ParseSpecifierQualifierList()
2920 /// parse declaration-specifiers and complain about extra stuff. in ParseSpecifierQualifierList()
2921 /// TODO: diagnose attribute-specifiers and alignment-specifiers. in ParseSpecifierQualifierList()
2925 // Validate declspec for type-name. in ParseSpecifierQualifierList()
2967 /// isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the
2971 /// int x [ 4]; // direct-declarator
2972 /// int x ( int y); // direct-declarator
2973 /// int(int x ) // direct-declarator
2974 /// int x ; // simple-declaration
2975 /// int x = 17; // init-declarator-list
2976 /// int x , y; // init-declarator-list
2977 /// int x __asm__ ("foo"); // init-declarator-list
2978 /// int x : 4; // struct-declarator
2985 static bool isValidAfterIdentifierInDeclarator(const Token &T) { in isValidAfterIdentifierInDeclarator()
2986 return T.isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi, in isValidAfterIdentifierInDeclarator()
2991 /// ParseImplicitInt - This method is called when we have an non-typename
3013 // As such, we try to do some look-ahead in cases where this would in ParseImplicitInt()
3014 // otherwise be an "implicit-int" case to see if this is invalid. For in ParseImplicitInt()
3015 // example: "static foo_t x = 4;" In this case, if we parsed foo_t as in ParseImplicitInt()
3024 // language doesn't "officially" support implicit int -- we support in ParseImplicitInt()
3028 // If this token is valid for implicit int, e.g. "static x = 4", then in ParseImplicitInt()
3042 // specifier in C++98 -- we'll promote it to a type specifier. in ParseImplicitInt()
3048 if (getLangOpts().CPlusPlus && (!SS || SS->isEmpty()) && in ParseImplicitInt()
3103 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type) in ParseImplicitInt()
3127 // static x(4); // 'x' is not a type in ParseImplicitInt()
3152 << FixItHint::CreateReplacement(Tok.getLocation(), II->getName()); in ParseImplicitInt()
3164 case tok::semi: in ParseImplicitInt()
3166 // probably missing. We're done parsing decl-specifiers. in ParseImplicitInt()
3168 if (getCurScope()->isFunctionPrototypeScope()) in ParseImplicitInt()
3191 // the type in the declaration specifiers, consume the would-be type in ParseImplicitInt()
3203 Tok.setKind(II->getTokenID()); in ParseImplicitInt()
3280 /// ParseAlignArgument - Parse the argument to an alignment-specifier.
3282 /// [C11] type-id
3283 /// [C11] constant-expression
3284 /// [C++0x] type-id ...[opt]
3285 /// [C++0x] assignment-expression ...[opt]
3309 /// ParseAlignmentSpecifier - Parse an alignment-specifier, and add the
3312 /// alignment-specifier:
3313 /// [C11] '_Alignas' '(' type-id ')'
3314 /// [C11] '_Alignas' '(' constant-expression ')'
3315 /// [C++11] 'alignas' '(' type-id ...[opt] ')'
3316 /// [C++11] 'alignas' '(' assignment-expression ...[opt] ')'
3320 "Not an alignment-specifier!"); in ParseAlignmentSpecifier()
3363 if (LateAttr->Decls.empty()) in DistributeCLateParsedAttrs()
3364 LateAttr->addDecl(Dcl); in DistributeCLateParsedAttrs()
3438 /// in a simple-declaration. If it can't possibly be a declarator, maybe
3469 // A declarator-id can't start with 'typename'. in DiagnoseMissingSemiAfterTagDefinition()
3472 // If we have a type expressed as a template-id, this cannot be a in DiagnoseMissingSemiAfterTagDefinition()
3473 // declarator-id (such a type cannot be redeclared in a simple-declaration). in DiagnoseMissingSemiAfterTagDefinition()
3476 if (Annot->Kind == TNK_Type_template) in DiagnoseMissingSemiAfterTagDefinition()
3481 // These tokens cannot come after the declarator-id in a in DiagnoseMissingSemiAfterTagDefinition()
3482 // simple-declaration, and are likely to come after a type-specifier. in DiagnoseMissingSemiAfterTagDefinition()
3488 // If the declarator-id has a scope specifier, it must redeclare a in DiagnoseMissingSemiAfterTagDefinition()
3489 // previously-declared entity. If that's a type (and this is not a in DiagnoseMissingSemiAfterTagDefinition()
3510 // Not a previously-declared non-type entity. in DiagnoseMissingSemiAfterTagDefinition()
3531 Diag(PP.getLocForEndOfToken(DS.getRepAsDecl()->getEndLoc()), in DiagnoseMissingSemiAfterTagDefinition()
3533 << DeclSpec::getSpecifierName(DS.getTypeSpecType(), PPol) << tok::semi; in DiagnoseMissingSemiAfterTagDefinition()
3549 /// declaration-specifiers: [C99 6.7]
3550 /// storage-class-specifier declaration-specifiers[opt]
3551 /// type-specifier declaration-specifiers[opt]
3552 /// [C99] function-specifier declaration-specifiers[opt]
3553 /// [C11] alignment-specifier declaration-specifiers[opt]
3554 /// [GNU] attributes declaration-specifiers[opt]
3555 /// [Clang] '__module_private__' declaration-specifiers[opt]
3556 /// [ObjC1] '__kindof' declaration-specifiers[opt]
3558 /// storage-class-specifier: [C99 6.7.1]
3561 /// 'static'
3568 /// function-specifier: [C99 6.7.4]
3630 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); in ParseDeclarationSpecifiers()
3688 // alignment-specifier in ParseDeclarationSpecifiers()
3725 = (getCurScope()->getFlags() & (Scope::ControlScope | in ParseDeclarationSpecifiers()
3747 else if (getCurScope()->getFnParent() || getCurScope()->getBlockParent()) in ParseDeclarationSpecifiers()
3786 if (TemplateId && TemplateId->hasInvalidName()) { in ParseDeclarationSpecifiers()
3794 if (TemplateId && TemplateId->Kind == TNK_Type_template) { in ParseDeclarationSpecifiers()
3795 // We have a qualified template-id, e.g., N::A<int> in ParseDeclarationSpecifiers()
3798 // arguments, we will reject the attempt to form an invalid type-id in ParseDeclarationSpecifiers()
3799 // referring to the injected-class-name when we annotate the token, in ParseDeclarationSpecifiers()
3806 TemplateId->Name && in ParseDeclarationSpecifiers()
3807 Actions.isCurrentClassName(*TemplateId->Name, getCurScope(), &SS) && in ParseDeclarationSpecifiers()
3811 // The user meant this to be an out-of-line constructor in ParseDeclarationSpecifiers()
3826 if (TemplateId && TemplateId->Kind == TNK_Concept_template) { in ParseDeclarationSpecifiers()
3828 // This is probably a qualified placeholder-specifier, e.g., ::C<int> in ParseDeclarationSpecifiers()
3830 // template-id as a placeholder-specifier. Let the next iteration in ParseDeclarationSpecifiers()
3852 ->Kind == TNK_Dependent_template_name) { in ParseDeclarationSpecifiers()
3878 // - `return type`. in ParseDeclarationSpecifiers()
3951 // static const bool __is_signed; in ParseDeclarationSpecifiers()
3959 // We're done with the declaration-specifiers. in ParseDeclarationSpecifiers()
3962 // typedef-name in ParseDeclarationSpecifiers()
3968 // a type-specifier. Without this check we misparse: in ParseDeclarationSpecifiers()
3978 Tok.getIdentifierInfo()->getName() == "__declspec") { in ParseDeclarationSpecifiers()
4004 // - `return type`. in ParseDeclarationSpecifiers()
4098 // Objective-C supports type arguments and protocol references in ParseDeclarationSpecifiers()
4099 // following an Objective-C object or object pointer in ParseDeclarationSpecifiers()
4117 // type-name or placeholder-specifier in ParseDeclarationSpecifiers()
4121 if (TemplateId->hasInvalidName()) { in ParseDeclarationSpecifiers()
4126 if (TemplateId->Kind == TNK_Concept_template) { in ParseDeclarationSpecifiers()
4127 // If we've already diagnosed that this type-constraint has invalid in ParseDeclarationSpecifiers()
4129 if (TemplateId->hasInvalidArgs()) in ParseDeclarationSpecifiers()
4185 if (TemplateId->Kind != TNK_Type_template && in ParseDeclarationSpecifiers()
4186 TemplateId->Kind != TNK_Undeclared_template) { in ParseDeclarationSpecifiers()
4187 // This template-id does not refer to a type name, so we're in ParseDeclarationSpecifiers()
4188 // done with the type-specifiers. in ParseDeclarationSpecifiers()
4192 // If we're in a context where the template-id could be a in ParseDeclarationSpecifiers()
4196 Actions.isCurrentClassName(*TemplateId->Name, getCurScope()) && in ParseDeclarationSpecifiers()
4202 // Turn the template-id annotation token into a type annotation in ParseDeclarationSpecifiers()
4203 // token, then try again to parse it as a type-specifier. in ParseDeclarationSpecifiers()
4271 // Objective-C 'kindof' types. in ParseDeclarationSpecifiers()
4278 // storage-class-specifier in ParseDeclarationSpecifiers()
4298 Diag(Tok, diag::ext_thread_before) << "static"; in ParseDeclarationSpecifiers()
4360 // function-specifier in ParseDeclarationSpecifiers()
4371 PrevSpec = Tok.getIdentifierInfo()->getNameStart(); in ParseDeclarationSpecifiers()
4424 CurS->setFlags(CurS->getFlags() | Scope::FriendScope); in ParseDeclarationSpecifiers()
4453 // type-specifier in ParseDeclarationSpecifiers()
4539 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4546 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4553 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4627 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); in ParseDeclarationSpecifiers()
4632 PrevSpec = Tok.getIdentifierInfo()->getNameStart(); in ParseDeclarationSpecifiers()
4651 // class-specifier: in ParseDeclarationSpecifiers()
4675 // enum-specifier: in ParseDeclarationSpecifiers()
4681 // cv-qualifier: in ParseDeclarationSpecifiers()
4695 // C++ typename-specifier: in ParseDeclarationSpecifiers()
4766 PrevSpec = Tok.getIdentifierInfo()->getNameStart(); in ParseDeclarationSpecifiers()
4850 static void DiagnoseCountAttributedTypeInUnnamedAnon(ParsingDeclSpec &DS, in DiagnoseCountAttributedTypeInUnnamedAnon()
4857 // We're only interested in unnamed, non-anonymous struct in DiagnoseCountAttributedTypeInUnnamedAnon()
4858 if (!RD || !RD->getName().empty() || RD->isAnonymousStructOrUnion()) in DiagnoseCountAttributedTypeInUnnamedAnon()
4861 for (auto *I : RD->decls()) { in DiagnoseCountAttributedTypeInUnnamedAnon()
4866 auto *CAT = VD->getType()->getAs<CountAttributedType>(); in DiagnoseCountAttributedTypeInUnnamedAnon()
4870 for (const auto &DD : CAT->dependent_decls()) { in DiagnoseCountAttributedTypeInUnnamedAnon()
4871 if (!RD->containsDecl(DD.getDecl())) { in DiagnoseCountAttributedTypeInUnnamedAnon()
4872 P.Diag(VD->getBeginLoc(), diag::err_count_attr_param_not_in_same_struct) in DiagnoseCountAttributedTypeInUnnamedAnon()
4873 << DD.getDecl() << CAT->getKind() << CAT->isArrayType(); in DiagnoseCountAttributedTypeInUnnamedAnon()
4874 P.Diag(DD.getDecl()->getBeginLoc(), in DiagnoseCountAttributedTypeInUnnamedAnon()
4882 /// ParseStructDeclaration - Parse a struct declaration without the terminating
4888 /// struct-declaration:
4889 /// [C23] attributes-specifier-seq[opt]
4890 /// specifier-qualifier-list struct-declarator-list
4891 /// [GNU] __extension__ struct-declaration
4892 /// [GNU] specifier-qualifier-list
4893 /// struct-declarator-list:
4894 /// struct-declarator
4895 /// struct-declarator-list ',' struct-declarator
4896 /// [GNU] struct-declarator-list ',' attributes[opt] struct-declarator
4897 /// struct-declarator:
4900 /// declarator[opt] ':' constant-expression
4901 /// [GNU] declarator[opt] ':' constant-expression attributes[opt]
4919 // Parse the common specifier-qualifiers-list piece. in ParseStructDeclaration()
4922 // If there are no declarators, this is a free-standing declaration in ParseStructDeclaration()
4924 if (Tok.is(tok::semi)) { in ParseStructDeclaration()
4938 // Read struct-declarators until we find the semicolon. in ParseStructDeclaration()
4954 /// struct-declarator: declarator in ParseStructDeclaration()
4955 /// struct-declarator: declarator[opt] ':' constant-expression in ParseStructDeclaration()
4971 SkipUntil(tok::semi, StopBeforeMatch); in ParseStructDeclaration()
5056 OutAttrs->takeAllFrom(Attrs); in ParseLexedCAttribute()
5061 /// struct-contents:
5062 /// struct-declaration-list
5064 /// [GNU] "struct-declaration-list" without terminating ';'
5065 /// struct-declaration-list:
5066 /// struct-declaration
5067 /// struct-declaration-list struct-declaration
5068 /// [OBC] '@' 'defs' '(' class-name ')'
5091 // Each iteration of this loop reads one struct-declaration. in ParseStructUnionBody()
5093 // Check for extraneous top-level semicolon. in ParseStructUnionBody()
5094 if (Tok.is(tok::semi)) { in ParseStructUnionBody()
5138 auto CFieldCallback = [&](ParsingFieldDeclarator &FD) -> Decl * { in ParseStructUnionBody()
5155 SkipUntil(tok::semi); in ParseStructUnionBody()
5162 SkipUntil(tok::semi); in ParseStructUnionBody()
5172 if (TryConsumeToken(tok::semi)) in ParseStructUnionBody()
5176 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list); in ParseStructUnionBody()
5180 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list); in ParseStructUnionBody()
5181 // Skip to end of block or statement to avoid ext-warning on extra ';'. in ParseStructUnionBody()
5184 TryConsumeToken(tok::semi); in ParseStructUnionBody()
5196 SmallVector<Decl *, 32> FieldDecls(TagDecl->fields()); in ParseStructUnionBody()
5205 /// enum-specifier: [C99 6.7.2.2]
5206 /// 'enum' identifier[opt] '{' enumerator-list '}'
5207 ///[C99/C++]'enum' identifier[opt] '{' enumerator-list ',' '}'
5208 /// [GNU] 'enum' attributes[opt] identifier[opt] '{' enumerator-list ',' [opt]
5210 /// [MS] 'enum' __declspec[opt] identifier[opt] '{' enumerator-list ',' [opt]
5215 /// [C++11] enum-head '{' enumerator-list[opt] '}'
5216 /// [C++11] enum-head '{' enumerator-list ',' '}'
5218 /// enum-head: [C++11]
5219 /// enum-key attribute-specifier-seq[opt] identifier[opt] enum-base[opt]
5220 /// enum-key attribute-specifier-seq[opt] nested-name-specifier
5221 /// identifier enum-base[opt]
5223 /// enum-key: [C++11]
5228 /// enum-base: [C++11]
5229 /// ':' type-specifier-seq
5231 /// [C++] elaborated-type-specifier:
5232 /// [C++] 'enum' nested-name-specifier[opt] identifier
5279 // Determine whether this declaration is permitted to have an enum-base. in ParseEnumSpecifier()
5350 getCurScope()->isClassScope() && ScopedEnumKWLoc.isInvalid() && Name; in ParseEnumSpecifier()
5354 // This might be an enum-base or part of some unrelated enclosing context. in ParseEnumSpecifier()
5358 // 1) As a defining-type-specifier, when followed by '{'. in ParseEnumSpecifier()
5359 // 2) As the sole constituent of a complete declaration -- when DS is empty in ParseEnumSpecifier()
5362 // The restriction to defining-type-specifiers is important to allow parsing in ParseEnumSpecifier()
5370 // A ':' following "enum nested-name-specifier[opt] identifier" within in ParseEnumSpecifier()
5371 // the decl-specifier-seq of a member-declaration is parsed as part of in ParseEnumSpecifier()
5372 // an enum-base. in ParseEnumSpecifier()
5376 // the tokens form a bit-field width or an enum-base. in ParseEnumSpecifier()
5379 // Outside C++11, do not interpret the tokens as an enum-base if they do in ParseEnumSpecifier()
5386 // Parse a type-specifier-seq as a type. We can't just ParseTypeName here, in ParseEnumSpecifier()
5387 // because under -fms-extensions, in ParseEnumSpecifier()
5391 // enum-base is not assumed to be a type and therefore requires the in ParseEnumSpecifier()
5425 // enum foo {..}; void bar() { enum foo; } <- new foo in bar. in ParseEnumSpecifier()
5426 // enum foo {..}; void bar() { enum foo x; } <- use of old foo. in ParseEnumSpecifier()
5437 // Discard any other definition-only pieces. in ParseEnumSpecifier()
5447 (Tok.is(tok::semi) || in ParseEnumSpecifier()
5450 // An opaque-enum-declaration is required to be standalone (no preceding or in ParseEnumSpecifier()
5454 if (Tok.isNot(tok::semi)) { in ParseEnumSpecifier()
5456 ExpectAndConsume(tok::semi, diag::err_expected_after, "enum"); in ParseEnumSpecifier()
5458 Tok.setKind(tok::semi); in ParseEnumSpecifier()
5491 TParams = MultiTemplateParamsArg(TemplateInfo.TemplateParams->data(), in ParseEnumSpecifier()
5492 TemplateInfo.TemplateParams->size()); in ParseEnumSpecifier()
5505 // An elaborated-type-specifier has a much more constrained grammar: in ParseEnumSpecifier()
5507 // 'enum' nested-name-specifier[opt] identifier in ParseEnumSpecifier()
5511 // MSVC and (for now at least) Objective-C permit a full enum-specifier in ParseEnumSpecifier()
5512 // or opaque-enum-declaration anywhere. in ParseEnumSpecifier()
5565 // This enum has a dependent nested-name-specifier. Handle it as a in ParseEnumSpecifier()
5618 /// ParseEnumBody - Parse a {} enclosed enumerator-list.
5619 /// enumerator-list:
5621 /// enumerator-list ',' enumerator
5623 /// enumeration-constant attributes[opt]
5624 /// enumeration-constant attributes[opt] '=' constant-expression
5625 /// enumeration-constant:
5636 // C does not allow an empty enumerator-list, C++ does [dcl.enum]. in ParseEnumBody()
5645 // Parse the enumerator-list. in ParseEnumBody()
5754 bool CanBeBitfield = getCurScope()->isClassScope(); in ParseEnumBody()
5756 ExpectAndConsume(tok::semi, diag::err_expected_after, "enum"); in ParseEnumBody()
5761 Tok.setKind(tok::semi); in ParseEnumBody()
5765 /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
5766 /// is definitely a type-specifier. Return false if it isn't part of a type
5771 // type-specifiers in isKnownToBeTypeSpecifier()
5807 // struct-or-union-specifier (C99) or class-specifier (C++) in isKnownToBeTypeSpecifier()
5812 // enum-specifier in isKnownToBeTypeSpecifier()
5815 // typedef-name in isKnownToBeTypeSpecifier()
5821 /// isTypeSpecifierQualifier - Return true if the current token could be the
5822 /// start of a specifier-qualifier-list.
5855 // type-specifiers in isTypeSpecifierQualifier()
5891 // struct-or-union-specifier (C99) or class-specifier (C++) in isTypeSpecifierQualifier()
5896 // enum-specifier in isTypeSpecifierQualifier()
5899 // type-qualifier in isTypeSpecifierQualifier()
5908 // typedef-name in isTypeSpecifierQualifier()
5965 // Parse a top-level-stmt. in ParseTopLevelStmtDecl()
5980 TLSD->setSemiMissing(); in ParseTopLevelStmtDecl()
5986 // Currently happens for things like -fms-extensions and use `__if_exists`. in ParseTopLevelStmtDecl()
5998 /// isDeclarationSpecifier() - Return true if the current token is part of a
6034 // If we're in Objective-C and we have an Objective-C class type followed in isDeclarationSpecifier()
6058 // storage-class-specifier in isDeclarationSpecifier()
6076 // type-specifiers in isDeclarationSpecifier()
6111 // struct-or-union-specifier (C99) or class-specifier (C++) in isDeclarationSpecifier()
6116 // enum-specifier in isDeclarationSpecifier()
6119 // type-qualifier in isDeclarationSpecifier()
6125 // function-specifier in isDeclarationSpecifier()
6131 // alignment-specifier in isDeclarationSpecifier()
6137 // static_assert-declaration in isDeclarationSpecifier()
6162 // alignas is a type-specifier-qualifier in C23, which is a kind of in isDeclarationSpecifier()
6163 // declaration-specifier. Outside of C23 mode (including in C++), it is not. in isDeclarationSpecifier()
6170 // typedef-name in isDeclarationSpecifier()
6175 // placeholder-type-specifier in isDeclarationSpecifier()
6178 if (TemplateId->hasInvalidName()) in isDeclarationSpecifier()
6191 if (TemplateId && TemplateId->hasInvalidName()) in isDeclarationSpecifier()
6250 if (TemplateInfo && TemplateInfo->TemplateParams) in isConstructorDeclarator()
6251 SS.setTemplateParamLists(*TemplateInfo->TemplateParams); in isConstructorDeclarator()
6347 // constructor with an unnamed parameter of an ill-formed type. in isConstructorDeclarator()
6353 // Skip past the right-paren and any following attributes to get to in isConstructorDeclarator()
6354 // the function body or trailing-return-type. in isConstructorDeclarator()
6359 // C(X) -> ... is a deduction guide. in isConstructorDeclarator()
6365 // C(X) : (the name of a bit-field cannot be parenthesized). in isConstructorDeclarator()
6366 // C(X) try (this is otherwise ill-formed). in isConstructorDeclarator()
6369 if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) { in isConstructorDeclarator()
6374 // ... because otherwise we would be declaring a non-static data in isConstructorDeclarator()
6375 // member that is ill-formed because it's of the same type as its in isConstructorDeclarator()
6395 /// type-qualifier-list: [C99 6.7.5]
6396 /// type-qualifier
6399 /// type-qualifier-list type-qualifier
6400 /// [vendor] type-qualifier-list attributes
6402 /// [C++0x] attribute-specifier[opt] is allowed before cv-qualifier-seq
6486 IdentifierRequired && DS.isEmpty() && NextToken().is(tok::semi)) { in ParseTypeQualifierListOpt()
6527 // Objective-C 'kindof' types. in ParseTypeQualifierListOpt()
6550 // If this is not a type-qualifier token, we're done reading type in ParseTypeQualifierListOpt()
6567 /// ParseDeclarator - Parse and verify a newly-initialized declarator.
6570 /// for well-formedness and issues diagnostics. in ParseDeclarator()
6576 static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, in isPtrOperatorToken()
6593 // But we must not parse them in conversion-type-ids and new-type-ids, since in isPtrOperatorToken()
6595 // (The same thing can in theory happen after a trailing-return-type, but in isPtrOperatorToken()
6596 // since those are a C++11 feature, there is no rejects-valid issue there.) in isPtrOperatorToken()
6605 static bool isPipeDeclarator(const Declarator &D) { in isPipeDeclarator()
6615 /// ParseDeclaratorInternal - Parse a C or C++ declarator. The direct-declarator
6616 /// is parsed by the function passed to it. Pass null, and the direct-declarator
6618 /// ptr-operator production.
6625 /// [C] pointer[opt] direct-declarator
6626 /// [C++] direct-declarator
6627 /// [C++] ptr-operator declarator
6630 /// '*' type-qualifier-list[opt]
6631 /// '*' type-qualifier-list[opt] pointer
6633 /// ptr-operator:
6634 /// '*' cv-qualifier-seq[opt]
6639 /// '::'[opt] nested-name-specifier '*' cv-qualifier-seq[opt]
6645 // C++ member pointers start with a '::' or a nested-name. in ParseDeclaratorInternal()
6662 // The scope spec really belongs to the direct-declarator. in ParseDeclaratorInternal()
6669 (this->*DirectDeclParser)(D); in ParseDeclaratorInternal()
6713 (this->*DirectDeclParser)(D); in ParseDeclaratorInternal()
6717 // Otherwise, '*' -> pointer, '^' -> block, '&' -> lvalue reference, in ParseDeclaratorInternal()
6718 // '&&' -> rvalue reference in ParseDeclaratorInternal()
6726 // GNU attributes are not allowed here in a new-type-id, but Declspec and in ParseDeclaratorInternal()
6739 // Remember that we parsed a pointer type, and remember the type-quals. in ParseDeclaratorInternal()
6746 // Remember that we parsed a Block type, and remember the type-quals. in ParseDeclaratorInternal()
6761 // GNU-style and C++11 attributes are allowed here, as is restrict. in ParseDeclaratorInternal()
6765 // C++ 8.3.2p1: cv-qualified references are ill-formed except when the in ParseDeclaratorInternal()
6766 // cv-qualifiers are introduced through the use of a typedef or of a in ParseDeclaratorInternal()
6767 // template type argument, in which case the cv-qualifiers are ignored. in ParseDeclaratorInternal()
6787 DeclaratorChunk& InnerChunk = D.getTypeObject(D.getNumTypeObjects() - 1); in ParseDeclaratorInternal()
6796 // Once we've complained about the reference-to-reference, we in ParseDeclaratorInternal()
6797 // can go ahead and build the (technically ill-formed) in ParseDeclaratorInternal()
6813 static SourceLocation getMissingDeclaratorIdLoc(Declarator &D, in getMissingDeclaratorIdLoc()
6823 /// direct-declarator: [C99 6.7.5]
6827 /// [C90] direct-declarator '[' constant-expression[opt] ']'
6828 /// [C99] direct-declarator '[' type-qual-list[opt] assignment-expr[opt] ']'
6829 /// [C99] direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
6830 /// [C99] direct-declarator '[' type-qual-list 'static' assignment-expr ']'
6831 /// [C99] direct-declarator '[' type-qual-list[opt] '*' ']'
6832 /// [C++11] direct-declarator '[' constant-expression[opt] ']'
6833 /// attribute-specifier-seq[opt]
6834 /// direct-declarator '(' parameter-type-list ')'
6835 /// direct-declarator '(' identifier-list[opt] ')'
6836 /// [GNU] direct-declarator '(' parameter-forward-declarations
6837 /// parameter-type-list[opt] ')'
6838 /// [C++] direct-declarator '(' parameter-declaration-clause ')'
6839 /// cv-qualifier-seq[opt] exception-specification[opt]
6840 /// [C++11] direct-declarator '(' parameter-declaration-clause ')'
6841 /// attribute-specifier-seq[opt] cv-qualifier-seq[opt]
6842 /// ref-qualifier[opt] exception-specification[opt]
6843 /// [C++] declarator-id
6844 /// [C++11] declarator-id attribute-specifier-seq[opt]
6846 /// declarator-id: [C++ 8]
6847 /// '...'[opt] id-expression
6848 /// '::'[opt] nested-name-specifier[opt] type-name
6850 /// id-expression: [C++ 5.1]
6851 /// unqualified-id
6852 /// qualified-id
6854 /// unqualified-id: [C++ 5.1]
6856 /// operator-function-id
6857 /// conversion-function-id
6858 /// '~' class-name
6859 /// template-id
6863 /// simple-declaration:
6864 /// <decl-spec> '[' identifier-list ']' brace-or-equal-initializer ';'
6878 // this context it is a bitfield. Also in range-based for statement colon in ParseDirectDeclarator()
6879 // may delimit for-range-declaration. in ParseDirectDeclarator()
6895 // For each non-friend redeclaration or specialization whose target scope in ParseDirectDeclarator()
6896 // is or is contained by the scope, the portion after the declarator-id, in ParseDirectDeclarator()
6897 // class-head-name, or enum-head-name is also included in the scope. in ParseDirectDeclarator()
6899 // For each non-friend redeclaration or specialization whose target scope in ParseDirectDeclarator()
6900 // is or is contained by the scope, the portion after the declarator-id, in ParseDirectDeclarator()
6901 // class-head-name, or enum-head-name is also included in the scope. in ParseDirectDeclarator()
6913 // dealing with declarations in an Objective-C container. in ParseDirectDeclarator()
6923 // parameter-declaration-clause without a preceding comma. In this case, in ParseDirectDeclarator()
6924 // the ellipsis is parsed as part of the abstract-declarator if the type in ParseDirectDeclarator()
6927 // parameter-declaration-clause. in ParseDirectDeclarator()
6953 // We found something that indicates the start of an unqualified-id. in ParseDirectDeclarator()
6954 // Parse that unqualified-id. in ParseDirectDeclarator()
6992 // Parsed the unqualified-id; update range information and move along. in ParseDirectDeclarator()
7001 // We have a scope specifier but no following unqualified-id. in ParseDirectDeclarator()
7010 "There's a C++-specific check for tok::identifier above"); in ParseDirectDeclarator()
7032 DiagnoseIdentifier = NextToken().isOneOf(tok::comma, tok::semi); in ParseDirectDeclarator()
7037 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try); in ParseDirectDeclarator()
7048 // If this might be an abstract-declarator followed by a direct-initializer, in ParseDirectDeclarator()
7061 // direct-declarator: '(' declarator ')' in ParseDirectDeclarator()
7062 // direct-declarator: '(' attributes declarator ')' in ParseDirectDeclarator()
7068 // the scope already. Re-enter the scope, if we need to. in ParseDirectDeclarator()
7081 // portion is empty), if an abstract-declarator is allowed. in ParseDirectDeclarator()
7084 // The grammar for abstract-pack-declarator does not allow grouping parens. in ParseDirectDeclarator()
7095 // Objective-C++: Detect C++ keywords and try to prevent further errors by in ParseDirectDeclarator()
7099 Tok.getIdentifierInfo()->isCPlusPlusKeyword(getLangOpts())) { in ParseDirectDeclarator()
7151 // Enter function-declaration scope, limiting any declarators to the in ParseDirectDeclarator()
7164 // A qualified-id is assumed to name a type if in ParseDirectDeclarator()
7165 // - [...] in ParseDirectDeclarator()
7166 // - it is a decl-specifier of the decl-specifier-seq of a in ParseDirectDeclarator()
7167 // - [...] in ParseDirectDeclarator()
7168 // - parameter-declaration in a member-declaration [...] in ParseDirectDeclarator()
7169 // - parameter-declaration in a declarator of a function or function in ParseDirectDeclarator()
7170 // template declaration whose declarator-id is qualified [...] in ParseDirectDeclarator()
7224 // We're already ill-formed if we got here but we'll accept it anyway. in ParseDirectDeclarator()
7303 // C++17 does not allow the identifier-list in a structured binding in ParseDecompositionDeclarator()
7317 /// ParseParenDeclarator - We parsed the declarator D up to a paren. This is
7320 /// parameter parens in an abstract-declarator, we call ParseFunctionDeclarator.
7322 /// direct-declarator:
7325 /// direct-declarator '(' parameter-type-list ')'
7326 /// direct-declarator '(' identifier-list[opt] ')'
7327 /// [GNU] direct-declarator '(' parameter-forward-declarations
7328 /// parameter-type-list[opt] ')'
7351 // We require that the argument list (if this is a non-grouping paren) be in ParseParenDeclarator()
7365 // grouping parens. However, if this could be an abstract-declarator, then in ParseParenDeclarator()
7370 // If this can't be an abstract-declarator, this *must* be a grouping in ParseParenDeclarator()
7380 // considered to be a type, not a K&R identifier-list. in ParseParenDeclarator()
7388 // direct-declarator: '(' declarator ')' in ParseParenDeclarator()
7389 // direct-declarator: '(' attributes declarator ')' in ParseParenDeclarator()
7418 // Enter function-declaration scope, limiting any declarators to the in ParseParenDeclarator()
7434 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq in InitCXXThisScopeForDeclaratorIfRelevant()
7435 // and the end of the function-definition, member-declarator, or in InitCXXThisScopeForDeclaratorIfRelevant()
7437 // FIXME: currently, "static" case isn't handled correctly. in InitCXXThisScopeForDeclaratorIfRelevant()
7445 Actions.CurContext->isRecord()); in InitCXXThisScopeForDeclaratorIfRelevant()
7470 /// ParseFunctionDeclarator - We are after the identifier and have parsed the
7474 /// If FirstArgAttrs is non-null, then the caller parsed those attributes
7475 /// immediately after the open paren - they will be applied to the DeclSpec
7481 /// For C++, after the parameter-list, it also parses the cv-qualifier-seq[opt],
7482 /// (C++11) ref-qualifier[opt], exception-specification[opt],
7483 /// (C++11) attribute-specifier-seq[opt], (C++11) trailing-return-type[opt] and
7484 /// (C++2a) the trailing requires-clause.
7486 /// [C++11] exception-specification:
7487 /// dynamic-exception-specification
7488 /// noexcept-specification
7495 assert(getCurScope()->isFunctionPrototypeScope() && in ParseFunctionDeclarator()
7501 // Otherwise, it is treated as a K&R-style function. in ParseFunctionDeclarator()
7565 // with the pure-specifier in the same way. in ParseFunctionDeclarator()
7567 // Parse cv-qualifier-seq[opt]. in ParseFunctionDeclarator()
7578 // Parse ref-qualifier[opt]. in ParseFunctionDeclarator()
7586 // A complete-class context of a class (template) is a in ParseFunctionDeclarator()
7587 // - function body, in ParseFunctionDeclarator()
7588 // - default argument, in ParseFunctionDeclarator()
7589 // - default template argument, in ParseFunctionDeclarator()
7590 // - noexcept-specifier, or in ParseFunctionDeclarator()
7591 // - default member initializer in ParseFunctionDeclarator()
7592 // within the member-specification of the class or class template. in ParseFunctionDeclarator()
7594 // Parse exception-specification[opt]. If we are in the in ParseFunctionDeclarator()
7595 // member-specification of a class or class template, this is a in ParseFunctionDeclarator()
7596 // complete-class context and parsing of the noexcept-specifier should be in ParseFunctionDeclarator()
7606 GetLookAheadToken(4).getIdentifierInfo()->isStr("swap")) { in ParseFunctionDeclarator()
7607 // HACK: We've got an exception-specification in ParseFunctionDeclarator()
7613 // whereas it expects to find a non-member swap through ADL. Turn off in ParseFunctionDeclarator()
7626 // Parse attribute-specifier-seq[opt]. Per DR 979 and DR 1297, this goes in ParseFunctionDeclarator()
7627 // after the exception-specification. in ParseFunctionDeclarator()
7630 // Parse trailing-return-type[opt]. in ParseFunctionDeclarator()
7648 // Collect non-parameter declarations from the prototype if this is a function in ParseFunctionDeclarator()
7653 if (getCurScope()->isFunctionDeclarationScope() && !getLangOpts().CPlusPlus) { in ParseFunctionDeclarator()
7654 for (Decl *D : getCurScope()->decls()) { in ParseFunctionDeclarator()
7666 return D1->getLocation().getRawEncoding() < in ParseFunctionDeclarator()
7667 D2->getLocation().getRawEncoding(); in ParseFunctionDeclarator()
7686 /// ParseRefQualifier - Parses a member function ref-qualifier. Returns
7687 /// true if a ref-qualifier is found.
7702 /// isFunctionDeclaratorIdentifierList - This parameter list may have an
7703 /// identifier list form for a K&R-style function: void foo(a,b,c)
7705 /// Note that identifier-lists are only allowed for normal declarators, not for
7706 /// abstract-declarators.
7717 // it is very common for someone to typo a type in a non-K&R style in isFunctionDeclaratorIdentifierList()
7730 /// ParseFunctionDeclaratorIdentifierList - While parsing a function declarator
7731 /// we found a K&R-style identifier list instead of a typed parameter list.
7735 /// identifier-list: [C99 6.7.5]
7737 /// identifier-list ',' identifier
7747 // an abstract-declarator, or we are in a parameter declarator which was found in ParseFunctionDeclaratorIdentifierList()
7748 // to be abstract. In abstract-declarators, identifier lists are not valid: in ParseFunctionDeclaratorIdentifierList()
7788 /// ParseParameterDeclarationClause - Parse a (possibly empty) parameter-list
7789 /// after the opening parenthesis. This function will not parse a K&R-style
7793 /// is non-null, then the caller parsed those attributes immediately after the
7794 /// open paren - they will be applied to the DeclSpec of the first parameter.
7799 /// parameter-type-list: [C99 6.7.5]
7800 /// parameter-list
7801 /// parameter-list ',' '...'
7802 /// [C++] parameter-list '...'
7804 /// parameter-list: [C99 6.7.5]
7805 /// parameter-declaration
7806 /// parameter-list ',' parameter-declaration
7808 /// parameter-declaration: [C99 6.7.5]
7809 /// declaration-specifiers declarator
7810 /// [C++] declaration-specifiers declarator '=' assignment-expression
7811 /// [C++11] initializer-clause
7812 /// [GNU] declaration-specifiers declarator attributes
7813 /// declaration-specifiers abstract-declarator[opt]
7814 /// [C++] declaration-specifiers abstract-declarator[opt]
7815 /// '=' assignment-expression
7816 /// [GNU] declaration-specifiers abstract-declarator[opt] attributes
7817 /// [C++11] attribute-specifier-seq parameter-declaration
7818 /// [C++2b] attribute-specifier-seq 'this' parameter-declaration
7828 // getFunctionPrototypeDepth() - 1. in ParseParameterDeclarationClause()
7829 if (getCurScope()->getFunctionPrototypeDepth() - 1 > in ParseParameterDeclarationClause()
7838 // A qualified-id is assumed to name a type if in ParseParameterDeclarationClause()
7839 // - [...] in ParseParameterDeclarationClause()
7840 // - it is a decl-specifier of the decl-specifier-seq of a in ParseParameterDeclarationClause()
7841 // - [...] in ParseParameterDeclarationClause()
7842 // - parameter-declaration in a member-declaration [...] in ParseParameterDeclarationClause()
7843 // - parameter-declaration in a declarator of a function or function in ParseParameterDeclarationClause()
7844 // template declaration whose declarator-id is qualified [...] in ParseParameterDeclarationClause()
7845 // - parameter-declaration in a lambda-declarator [...] in ParseParameterDeclarationClause()
7855 // FIXME: Issue a diagnostic if we parsed an attribute-specifier-seq in ParseParameterDeclarationClause()
7856 // before deciding this was a parameter-declaration-clause. in ParseParameterDeclarationClause()
7860 // Parse the declaration-specifiers. in ParseParameterDeclarationClause()
7870 // We have already started parsing the decl-specifier sequence, so don't in ParseParameterDeclarationClause()
7871 // parse any parameter-declaration pieces that precede it. in ParseParameterDeclarationClause()
7889 // An explicit-object-parameter-declaration is a parameter-declaration in ParseParameterDeclarationClause()
7890 // with a this specifier. An explicit-object-parameter-declaration in ParseParameterDeclarationClause()
7891 // shall appear only as the first parameter-declaration of a in ParseParameterDeclarationClause()
7892 // parameter-declaration-list of either: in ParseParameterDeclarationClause()
7893 // - a member-declarator that declares a member function, or in ParseParameterDeclarationClause()
7894 // - a lambda-declarator. in ParseParameterDeclarationClause()
7896 // The parameter-declaration-list of a requires-expression is not such in ParseParameterDeclarationClause()
7911 // 'declarator' or 'abstract-declarator' here. in ParseParameterDeclarationClause()
7985 Tok.getIdentifierInfo()->isKeyword(getLangOpts())) { in ParseParameterDeclarationClause()
8058 // We have ellipsis without a preceding ',', which is ill-formed in ParseParameterDeclarationClause()
8091 /// [C90] direct-declarator '[' constant-expression[opt] ']'
8092 /// [C99] direct-declarator '[' type-qual-list[opt] assignment-expr[opt] ']'
8093 /// [C99] direct-declarator '[' 'static' type-qual-list[opt] assign-expr ']'
8094 /// [C99] direct-declarator '[' type-qual-list 'static' assignment-expr ']'
8095 /// [C99] direct-declarator '[' type-qual-list[opt] '*' ']'
8096 /// [C++11] direct-declarator '[' constant-expression[opt] ']'
8097 /// attribute-specifier-seq[opt]
8105 // C array syntax has many features, but by-far the most common is [] and [4]. in ParseBracketDeclarator()
8140 // If valid, this location is the position where we read the 'static' keyword. in ParseBracketDeclarator()
8144 // If there is a type-qualifier-list, read it now. in ParseBracketDeclarator()
8149 // If we haven't already read 'static', check to see if there is one after the in ParseBracketDeclarator()
8150 // type-qualifier-list. in ParseBracketDeclarator()
8154 // Handle "direct-declarator [ type-qual-list[opt] * ]". in ParseBracketDeclarator()
8167 StaticLoc = SourceLocation(); // Drop the static. in ParseBracketDeclarator()
8171 // Note, in C89, this production uses the constant-expr production instead in ParseBracketDeclarator()
8172 // of assignment-expr. The only difference is that assignment-expr allows in ParseBracketDeclarator()
8174 // are not i-c-e's, so we don't need to distinguish between the two here. in ParseBracketDeclarator()
8176 // Parse the constant-expression or assignment-expression now (depending in ParseBracketDeclarator()
8189 StaticLoc = SourceLocation(); // Drop the static. in ParseBracketDeclarator()
8193 // If there was an error parsing the assignment-expression, recover. in ParseBracketDeclarator()
8229 if (Tok.is(tok::semi)) in ParseMisplacedBracketDeclarator()
8246 switch (D.getTypeObject(D.getNumTypeObjects() - 1).Kind) { in ParseMisplacedBracketDeclarator()
8302 /// [GNU] typeof-specifier:
8304 /// typeof ( type-name )
8305 /// [GNU/C++] typeof unary-expression
8306 /// [C23] typeof-specifier:
8307 /// typeof '(' typeof-specifier-argument ')'
8308 /// typeof_unqual '(' typeof-specifier-argument ')'
8310 /// typeof-specifier-argument:
8312 /// type-name
8320 if (getLangOpts().C23 && !II->getName().starts_with("__")) in ParseTypeofSpecifier()
8387 /// [C11] atomic-specifier:
8388 /// _Atomic ( type-name )
8422 /// TryAltiVecVectorTokenOutOfLine - Out of line body that should only be called
8508 // Consume (unexpanded) tokens up to the end-of-directive. in ParseTypeFromString()
8583 // In C23 mode, diagnose that the use is not compatible with pre-C23 modes. in DiagnoseBitIntUse()