Lines Matching +full:diag +full:- +full:version

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()
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()
202 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, in ParseGNUAttributes()
207 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, "(")) { 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()
449 Diag(Tok.getLocation(), diag::err_expected_string_literal) in ParseUnevaluatedStringInAttribute()
466 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); in ParseAttributeArgumentList()
636 Diag(Tok.getLocation(), in ParseAttributeArgsCommon()
637 diag::err_attribute_argument_parm_pack_not_supported) in ParseAttributeArgsCommon()
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()
798 T.expectAndConsume(diag::err_expected_lparen_after, in ParseMicrosoftDeclSpecArgs()
799 AttrName->getNameStart(), tok::r_paren); in ParseMicrosoftDeclSpecArgs()
802 AK_Invalid = -1, in ParseMicrosoftDeclSpecArgs()
817 Diag(AttrNameLoc, diag::err_ms_property_no_getter_or_putter); in ParseMicrosoftDeclSpecArgs()
821 Diag(Tok.getLocation(), diag::err_ms_property_unknown_accessor); in ParseMicrosoftDeclSpecArgs()
827 StringRef KindStr = Tok.getIdentifierInfo()->getName(); in ParseMicrosoftDeclSpecArgs()
835 Diag(KindLoc, diag::err_ms_property_has_set_accessor) in ParseMicrosoftDeclSpecArgs()
842 Diag(KindLoc, diag::err_ms_property_missing_accessor_kind); in ParseMicrosoftDeclSpecArgs()
849 Diag(KindLoc, diag::err_ms_property_unknown_accessor); in ParseMicrosoftDeclSpecArgs()
863 Diag(Tok.getLocation(), diag::err_ms_property_expected_equal) in ParseMicrosoftDeclSpecArgs()
870 Diag(Tok.getLocation(), diag::err_ms_property_expected_accessor_name); in ParseMicrosoftDeclSpecArgs()
878 Diag(KindLoc, diag::err_ms_property_duplicate_accessor) << KindStr; in ParseMicrosoftDeclSpecArgs()
893 Diag(Tok.getLocation(), diag::err_ms_property_expected_comma_or_rparen); in ParseMicrosoftDeclSpecArgs()
897 // Only add the property attribute if it was well-formed. in ParseMicrosoftDeclSpecArgs()
913 Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName; 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
935 if (T.expectAndConsume(diag::err_expected_lparen_after, "__declspec", in ParseMicrosoftDeclSpecs()
953 // We expect either a well-known identifier or a generic string. Anything in ParseMicrosoftDeclSpecs()
958 Diag(Tok, diag::err_ms_declspec_type); in ParseMicrosoftDeclSpecs()
985 else if (AttrName->getName() == "property") in ParseMicrosoftDeclSpecs()
987 Diag(Tok.getLocation(), diag::err_expected_lparen_after) in ParseMicrosoftDeclSpecs()
988 << AttrName->getName(); in ParseMicrosoftDeclSpecs()
1034 Diag(StartLoc, diag::err_wasm_funcref_not_wasm); in ParseWebAssemblyFuncrefTypeAttribute()
1051 Diag(StartLoc, diag::warn_microsoft_qualifiers_ignored) << Range; in DiagnoseAndSkipExtendedMicrosoftTypeAttributes()
1140 Diag(AttrNameLoc, diag::ext_nullability) in ParseNullabilityTypeSpecifiers()
1156 /// Parse a version number.
1158 /// version:
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
1168 Diag(Tok, diag::err_expected_version); in ParseVersionTuple()
1188 // Parse the major version. in ParseVersionTuple()
1192 Major = Major * 10 + ThisTokBegin[AfterMajor] - '0'; in ParseVersionTuple()
1197 Diag(Tok, diag::err_expected_version); in ParseVersionTuple()
1206 // We only had a single version component. in ParseVersionTuple()
1208 Diag(Tok, diag::err_zero_version); in ParseVersionTuple()
1218 Diag(Tok, diag::err_expected_version); in ParseVersionTuple()
1224 // Parse the minor version. in ParseVersionTuple()
1228 Minor = Minor * 10 + ThisTokBegin[AfterMinor] - '0'; in ParseVersionTuple()
1237 Diag(Tok, diag::err_zero_version); in ParseVersionTuple()
1247 Diag(Tok, diag::err_expected_version); in ParseVersionTuple()
1255 Diag(Tok, diag::warn_expected_consistent_version_separator); in ParseVersionTuple()
1257 // Parse the subminor version. in ParseVersionTuple()
1261 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] - '0'; in ParseVersionTuple()
1266 Diag(Tok, diag::err_expected_version); 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:
1292 /// 'introduced' '=' version
1293 /// 'deprecated' '=' version
1294 /// 'obsoleted' = version
1296 /// opt-replacement:
1298 /// opt-message:
1312 Diag(Tok, diag::err_expected) << tok::l_paren; in ParseAvailabilityAttribute()
1318 Diag(Tok, diag::err_availability_expected_platform); in ParseAvailabilityAttribute()
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()
1363 Diag(Tok, diag::err_availability_expected_change); in ParseAvailabilityAttribute()
1372 Diag(KeywordLoc, diag::err_availability_redundant) in ParseAvailabilityAttribute()
1381 Diag(KeywordLoc, diag::err_availability_redundant) in ParseAvailabilityAttribute()
1388 if (Keyword == Ident_deprecated && Platform->Ident && in ParseAvailabilityAttribute()
1389 Platform->Ident->isStr("swift")) { in ParseAvailabilityAttribute()
1392 Diag(KeywordLoc, diag::err_availability_redundant) in ParseAvailabilityAttribute()
1398 // Use a fake version here. in ParseAvailabilityAttribute()
1399 Changes[Deprecated].Version = VersionTuple(1); in ParseAvailabilityAttribute()
1405 Diag(KeywordLoc, diag::err_availability_redundant) in ParseAvailabilityAttribute()
1406 << Keyword << SourceRange(EnvironmentLoc->Loc); in ParseAvailabilityAttribute()
1411 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal; in ParseAvailabilityAttribute()
1418 Diag(Tok, diag::err_expected_string_literal) in ParseAvailabilityAttribute()
1433 Diag(Tok, diag::err_availability_expected_environment); in ParseAvailabilityAttribute()
1446 if (NA->getName() == "NA") { in ParseAvailabilityAttribute()
1455 VersionTuple Version = ParseVersionTuple(VersionRange); in ParseAvailabilityAttribute() local
1457 if (Version.empty()) { in ParseAvailabilityAttribute()
1474 Diag(KeywordLoc, diag::err_availability_redundant) in ParseAvailabilityAttribute()
1481 Changes[Index].Version = Version; in ParseAvailabilityAttribute()
1484 Diag(KeywordLoc, diag::err_availability_unknown_change) in ParseAvailabilityAttribute()
1504 Diag(UnavailableLoc, diag::warn_availability_and_unavailable) 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:
1566 Diag(Tok, diag::err_external_source_symbol_expected_keyword); in ParseExternalSourceSymbolAttribute()
1575 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword; in ParseExternalSourceSymbolAttribute()
1585 Diag(Tok, diag::err_external_source_symbol_expected_keyword); in ParseExternalSourceSymbolAttribute()
1591 if (ExpectAndConsume(tok::equal, diag::err_expected_after, in ParseExternalSourceSymbolAttribute()
1592 Keyword->getName())) { in ParseExternalSourceSymbolAttribute()
1607 Diag(Tok, diag::err_expected_string_literal) in ParseExternalSourceSymbolAttribute()
1618 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause) in ParseExternalSourceSymbolAttribute()
1626 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause) in ParseExternalSourceSymbolAttribute()
1635 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause) in ParseExternalSourceSymbolAttribute()
1657 /// objc_bridge_related '(' related_class ',' opt-class_method ',' opt-instance_method ')'
1661 /// opt-class_method:
1664 /// opt-instance_method:
1674 Diag(Tok, diag::err_expected) << tok::l_paren; in ParseObjCBridgeRelatedAttribute()
1680 Diag(Tok, diag::err_objcbridge_related_expected_related_class); in ParseObjCBridgeRelatedAttribute()
1690 // Parse class method name. It's non-optional in the sense that a trailing in ParseObjCBridgeRelatedAttribute()
1697 Diag(Tok, diag::err_objcbridge_related_selector_name); in ParseObjCBridgeRelatedAttribute()
1704 Diag(Tok, diag::err_objcbridge_related_selector_name); in ParseObjCBridgeRelatedAttribute()
1706 Diag(Tok, diag::err_expected) << tok::comma; in ParseObjCBridgeRelatedAttribute()
1711 // Parse instance method name. Also non-optional but empty string is in ParseObjCBridgeRelatedAttribute()
1717 Diag(Tok, diag::err_expected) << tok::r_paren; in ParseObjCBridgeRelatedAttribute()
1744 Diag(Tok, diag::err_expected) << tok::l_paren; in ParseSwiftNewTypeAttribute()
1749 Diag(Tok.getLocation(), diag::err_argument_required_after_attribute); in ParseSwiftNewTypeAttribute()
1754 Diag(Tok, diag::warn_attribute_type_not_supported) in ParseSwiftNewTypeAttribute()
1787 Diag(Tok, diag::err_expected) << tok::identifier; in ParseTypeTagForDatatypeAttribute()
1809 Diag(Tok, diag::err_expected) << tok::identifier; in ParseTypeTagForDatatypeAttribute()
1814 if (Flag->isStr("layout_compatible")) in ParseTypeTagForDatatypeAttribute()
1816 else if (Flag->isStr("must_be_null")) in ParseTypeTagForDatatypeAttribute()
1819 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag; 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()
1853 Diag(Tok.getLocation(), diag::err_l_square_l_square_not_attribute); in DiagnoseProhibitedCXX11Attribute()
1863 Diag(BeginLoc, diag::err_attributes_not_allowed) in DiagnoseProhibitedCXX11Attribute()
1871 /// attribute-specifier in a location where an attribute is not permitted, but
1886 (Keyword ? Diag(Loc, diag::err_keyword_not_allowed) << Keyword in DiagnoseMisplacedCXX11Attribute()
1887 : Diag(Loc, diag::err_attributes_not_allowed)) in DiagnoseMisplacedCXX11Attribute()
1897 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in DiagnoseProhibitedAttributes()
1898 ? Diag(CorrectLocation, diag::err_keyword_misplaced) << FirstAttr in DiagnoseProhibitedAttributes()
1899 : Diag(CorrectLocation, diag::err_attributes_misplaced)) in DiagnoseProhibitedAttributes()
1904 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in DiagnoseProhibitedAttributes()
1905 ? Diag(Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr in DiagnoseProhibitedAttributes()
1906 : Diag(Range.getBegin(), diag::err_attributes_not_allowed)) in DiagnoseProhibitedAttributes()
1929 if (SecondLSquare && SecondLSquare->is(tok::l_square)) { in ProhibitCXX11Attributes()
1933 Diag(Attrs.Range.getBegin(), AttrDiagID) << Attrs.Range; in ProhibitCXX11Attributes()
1941 Diag(AL.getLoc(), KeywordDiagID) << AL; in ProhibitCXX11Attributes()
1949 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) in ProhibitCXX11Attributes()
1952 Diag(AL.getLoc(), AttrDiagID) << AL; in ProhibitCXX11Attributes()
1961 Diag(PA.getLoc(), diag::ext_cxx11_attr_placement) in DiagnoseCXX11AttributeExtension()
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()
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()
2188 // this is a bit-field. in MightBeDeclarator()
2192 case tok::identifier: // Possible virt-specifier. in MightBeDeclarator()
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()
2348 Diag(Loc, diag::err_c11_noreturn_misplaced) in ParseDeclGroup()
2363 // (e.g. override) in an out-line method definition. in ParseDeclGroup()
2367 Diag(Tok, diag::err_virt_specifier_outside_class) 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()
2390 Diag(DS.getStorageClassSpecLoc(), in ParseDeclGroup()
2391 diag::err_function_declared_typedef) in ParseDeclGroup()
2399 // If the declarator-id is not a template-id, issue a diagnostic in ParseDeclGroup()
2401 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0; in ParseDeclGroup()
2407 Diag(D.getIdentifierLoc(), in ParseDeclGroup()
2408 diag::err_explicit_instantiation_with_definition) in ParseDeclGroup()
2439 // top-level code handle the erroneous declspec where it would in ParseDeclGroup()
2444 Diag(Tok, diag::err_expected_fn_body); in ParseDeclGroup()
2450 Diag(Tok, diag::err_function_definition_not_allowed); 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()
2533 Diag(CommaLoc, diag::err_expected_semi_declaration) 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()
2545 Diag(CommaLoc, diag::err_multiple_template_declarators) 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()
2590 ? diag::err_invalid_token_after_toplevel_declarator in ParseDeclGroup()
2591 : diag::err_expected_semi_declaration)) { 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()
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()
2740 // If the declarator-id is not a template-id, issue a diagnostic and in ParseDeclarationAfterDeclaratorAndAttributes()
2742 Diag(Tok, diag::err_template_defn_explicit_instantiation) in ParseDeclarationAfterDeclaratorAndAttributes()
2748 Diag(D.getIdentifierLoc(), in ParseDeclarationAfterDeclaratorAndAttributes()
2749 diag::err_explicit_instantiation_with_definition) in ParseDeclarationAfterDeclaratorAndAttributes()
2776 Diag(ConsumeToken(), diag::err_default_delete_in_multiple_declaration) in ParseDeclarationAfterDeclaratorAndAttributes()
2779 Diag(ConsumeToken(), diag::err_deleted_non_function); in ParseDeclarationAfterDeclaratorAndAttributes()
2783 Diag(ConsumeToken(), diag::err_default_delete_in_multiple_declaration) in ParseDeclarationAfterDeclaratorAndAttributes()
2786 Diag(ConsumeToken(), diag::err_default_special_members) in ParseDeclarationAfterDeclaratorAndAttributes()
2805 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range) 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()
2886 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); 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()
2928 Diag(Tok, diag::err_expected_type); in ParseSpecifierQualifierList()
2931 Diag(Tok, diag::err_typename_requires_specqual); in ParseSpecifierQualifierList()
2939 Diag(DS.getStorageClassSpecLoc(),diag::err_typename_invalid_storageclass); in ParseSpecifierQualifierList()
2941 Diag(DS.getThreadStorageClassSpecLoc(), in ParseSpecifierQualifierList()
2942 diag::err_typename_invalid_storageclass); in ParseSpecifierQualifierList()
2949 Diag(DS.getInlineSpecLoc(), diag::err_typename_invalid_functionspec); in ParseSpecifierQualifierList()
2951 Diag(DS.getVirtualSpecLoc(), diag::err_typename_invalid_functionspec); in ParseSpecifierQualifierList()
2953 Diag(DS.getExplicitSpecLoc(), diag::err_typename_invalid_functionspec); in ParseSpecifierQualifierList()
2955 Diag(DS.getNoreturnSpecLoc(), diag::err_typename_invalid_functionspec); in ParseSpecifierQualifierList()
2961 Diag(DS.getConstexprSpecLoc(), diag::err_typename_invalid_constexpr) 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
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()
3024 // language doesn't "officially" support implicit int -- we support 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()
3096 Diag(Loc, diag::err_use_of_tag_name_without_tag) in ParseImplicitInt()
3103 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type) in ParseImplicitInt()
3150 Diag(Loc, diag::err_constructor_bad_name) in ParseImplicitInt()
3152 << FixItHint::CreateReplacement(Tok.getLocation(), II->getName()); 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()
3383 Diag(Tok.getLocation(), diag::err_argument_required_after_attribute); in ParseBoundsAttribute()
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()
3532 diag::err_expected_after) 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]
3568 /// function-specifier: [C99 6.7.4]
3630 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); in ParseDeclarationSpecifiers()
3665 Diag(PA.getLoc(), diag::warn_attribute_ignored) << PA; in ParseDeclarationSpecifiers()
3675 Diag(PA.getLoc(), diag::err_attribute_not_type_attr) in ParseDeclarationSpecifiers()
3688 // alignment-specifier in ParseDeclarationSpecifiers()
3699 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName(); 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()
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()
3979 Diag(Loc, diag::err_ms_attributes_not_enabled); 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()
4140 Diag(Loc, diag::err_placeholder_expected_auto_or_decltype_auto) in ParseDeclarationSpecifiers()
4159 Diag(Tok, diag::err_expected) << tok::l_paren; in ParseDeclarationSpecifiers()
4164 Diag(Tok, diag::err_placeholder_expected_auto_or_decltype_auto) 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()
4286 Diag(Tok, diag::ext_thread_before) << "extern"; in ParseDeclarationSpecifiers()
4298 Diag(Tok, diag::ext_thread_before) << "static"; in ParseDeclarationSpecifiers()
4309 Diag(Tok, diag::ext_auto_storage_class) in ParseDeclarationSpecifiers()
4320 Diag(Tok, diag::ext_auto_type); in ParseDeclarationSpecifiers()
4341 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName(); in ParseDeclarationSpecifiers()
4360 // function-specifier in ParseDeclarationSpecifiers()
4370 DiagID = diag::err_openclcxx_virtual_function; in ParseDeclarationSpecifiers()
4371 PrevSpec = Tok.getIdentifierInfo()->getNameStart(); in ParseDeclarationSpecifiers()
4385 Diag(Tok.getLocation(), getLangOpts().CPlusPlus20 in ParseDeclarationSpecifiers()
4386 ? diag::warn_cxx17_compat_explicit_bool in ParseDeclarationSpecifiers()
4387 : diag::ext_explicit_bool); in ParseDeclarationSpecifiers()
4406 Diag(Tok.getLocation(), diag::warn_cxx20_compat_explicit_bool); in ParseDeclarationSpecifiers()
4424 CurS->setFlags(CurS->getFlags() | Scope::FriendScope); in ParseDeclarationSpecifiers()
4427 DiagID = diag::err_friend_invalid_in_context; in ParseDeclarationSpecifiers()
4440 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName(); in ParseDeclarationSpecifiers()
4453 // type-specifier in ParseDeclarationSpecifiers()
4480 Diag(Tok, diag::ext_c99_feature) << Tok.getName(); in ParseDeclarationSpecifiers()
4486 Diag(Tok, diag::ext_c99_feature) << Tok.getName(); in ParseDeclarationSpecifiers()
4539 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4546 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4553 "with `-ffixed-point`"); in ParseDeclarationSpecifiers()
4582 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName(); in ParseDeclarationSpecifiers()
4586 Diag(Tok, diag::ext_c99_feature) << Tok.getName(); in ParseDeclarationSpecifiers()
4592 DiagID = diag::err_bool_redeclaration; in ParseDeclarationSpecifiers()
4627 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); in ParseDeclarationSpecifiers()
4631 DiagID = diag::err_opencl_unknown_type_specifier; 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()
4765 DiagID = diag::err_opencl_unknown_type_specifier; in ParseDeclarationSpecifiers()
4766 PrevSpec = Tok.getIdentifierInfo()->getNameStart(); in ParseDeclarationSpecifiers()
4810 Diag(StartLoc, DiagID) << PrevSpec; in ParseDeclarationSpecifiers()
4829 if (DiagID == diag::ext_duplicate_declspec || in ParseDeclarationSpecifiers()
4830 DiagID == diag::ext_warn_duplicate_declspec || in ParseDeclarationSpecifiers()
4831 DiagID == diag::err_duplicate_declspec) in ParseDeclarationSpecifiers()
4832 Diag(Loc, DiagID) << PrevSpec in ParseDeclarationSpecifiers()
4835 else if (DiagID == diag::err_opencl_unknown_type_specifier) { in ParseDeclarationSpecifiers()
4836 Diag(Loc, DiagID) << getLangOpts().getOpenCLVersionString() << PrevSpec in ParseDeclarationSpecifiers()
4839 Diag(Loc, DiagID) << PrevSpec; in ParseDeclarationSpecifiers()
4842 if (DiagID != diag::err_bool_redeclaration && ConsumedEnd.isInvalid()) in ParseDeclarationSpecifiers()
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()
4875 diag::note_flexible_array_counted_by_attr_field) 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()
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()
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()
5130 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl) in ParseStructUnionBody()
5138 auto CFieldCallback = [&](ParsingFieldDeclarator &FD) -> Decl * { in ParseStructUnionBody()
5154 Diag(Tok, diag::err_unexpected_at); in ParseStructUnionBody()
5161 Diag(Tok, diag::err_expected) << tok::identifier; 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()
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
5255 Diag(Tok, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_scoped_enum in ParseEnumSpecifier()
5256 : diag::ext_scoped_enum); in ParseEnumSpecifier()
5279 // Determine whether this declaration is permitted to have an enum-base. in ParseEnumSpecifier()
5301 Diag(Tok, diag::err_expected) << tok::identifier; in ParseEnumSpecifier()
5317 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace; in ParseEnumSpecifier()
5336 Diag(Tok, diag::err_scoped_enum_missing_identifier); 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()
5382 Diag(Tok.getLocation(), diag::err_anonymous_enum_bitfield); 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()
5403 Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type) in ParseEnumSpecifier()
5406 Diag(ColonLoc, diag::ext_cxx11_enum_fixed_underlying_type) in ParseEnumSpecifier()
5409 Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type) in ParseEnumSpecifier()
5412 Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type) 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()
5433 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type) in ParseEnumSpecifier()
5437 // Discard any other definition-only pieces. in ParseEnumSpecifier()
5450 // An opaque-enum-declaration is required to be standalone (no preceding or in ParseEnumSpecifier()
5456 ExpectAndConsume(tok::semi, diag::err_expected_after, "enum"); in ParseEnumSpecifier()
5478 Diag(Tok, diag::err_enum_template); in ParseEnumSpecifier()
5486 Diag(StartLoc, diag::err_explicit_instantiation_enum); in ParseEnumSpecifier()
5491 TParams = MultiTemplateParamsArg(TemplateInfo.TemplateParams->data(), in ParseEnumSpecifier()
5492 TemplateInfo.TemplateParams->size()); in ParseEnumSpecifier()
5497 Diag(Tok, diag::err_enumerator_unnamed_no_def); 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()
5515 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, in ParseEnumSpecifier()
5516 diag::err_keyword_not_allowed, in ParseEnumSpecifier()
5519 Diag(BaseRange.getBegin(), diag::ext_enum_base_in_type_specifier) in ParseEnumSpecifier()
5522 Diag(ScopedEnumKWLoc, diag::ext_elaborated_enum_class) in ParseEnumSpecifier()
5560 Diag(StartLoc, DiagID) << PrevSpec; in ParseEnumSpecifier()
5565 // This enum has a dependent nested-name-specifier. Handle it as a in ParseEnumSpecifier()
5569 Diag(Tok, diag::err_expected_type_name_after_typename); in ParseEnumSpecifier()
5584 Diag(StartLoc, DiagID) << PrevSpec; in ParseEnumSpecifier()
5615 Diag(StartLoc, DiagID) << PrevSpec; 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()
5638 Diag(Tok, diag::err_empty_enum); in ParseEnumBody()
5645 // Parse the enumerator-list. in ParseEnumBody()
5650 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier; in ParseEnumBody()
5664 Diag(Tok.getLocation(), getLangOpts().CPlusPlus17 in ParseEnumBody()
5665 ? diag::warn_cxx14_compat_ns_enum_attribute in ParseEnumBody()
5666 : diag::ext_ns_enum_attribute) in ParseEnumBody()
5695 Diag(Loc, diag::err_enumerator_list_missing_comma) in ParseEnumBody()
5705 Diag(Tok.getLocation(), diag::err_expected_either) << tok::r_brace in ParseEnumBody()
5708 Diag(Tok.getLocation(), diag::err_expected_end_of_enumerator); in ParseEnumBody()
5720 Diag(CommaLoc, getLangOpts().CPlusPlus ? in ParseEnumBody()
5721 diag::ext_enumerator_list_comma_cxx : in ParseEnumBody()
5722 diag::ext_enumerator_list_comma_c) in ParseEnumBody()
5725 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma) in ParseEnumBody()
5754 bool CanBeBitfield = getCurScope()->isClassScope(); in ParseEnumBody()
5756 ExpectAndConsume(tok::semi, diag::err_expected_after, "enum"); 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()
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
6527 // Objective-C 'kindof' types. in ParseTypeQualifierListOpt()
6537 Diag(Tok, diag::err_attributes_not_allowed); in ParseTypeQualifierListOpt()
6550 // If this is not a type-qualifier token, we're done reading type in ParseTypeQualifierListOpt()
6561 Diag(Tok, DiagID) << PrevSpec; in ParseTypeQualifierListOpt()
6567 /// ParseDeclarator - Parse and verify a newly-initialized declarator.
6570 /// for well-formedness and issues diagnostics. in ParseDeclarator()
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()
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()
6757 Diag(Loc, getLangOpts().CPlusPlus11 ? in ParseDeclaratorInternal()
6758 diag::warn_cxx98_compat_rvalue_reference : in ParseDeclaratorInternal()
6759 diag::ext_rvalue_reference); 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()
6770 Diag(DS.getConstSpecLoc(), in ParseDeclaratorInternal()
6771 diag::err_invalid_reference_qualifier_application) << "const"; in ParseDeclaratorInternal()
6773 Diag(DS.getVolatileSpecLoc(), in ParseDeclaratorInternal()
6774 diag::err_invalid_reference_qualifier_application) << "volatile"; in ParseDeclaratorInternal()
6777 Diag(DS.getAtomicSpecLoc(), in ParseDeclaratorInternal()
6778 diag::err_invalid_reference_qualifier_application) << "_Atomic"; in ParseDeclaratorInternal()
6787 DeclaratorChunk& InnerChunk = D.getTypeObject(D.getNumTypeObjects() - 1); in ParseDeclaratorInternal()
6790 Diag(InnerChunk.Loc, diag::err_illegal_decl_reference_to_reference) in ParseDeclaratorInternal()
6793 Diag(InnerChunk.Loc, diag::err_illegal_decl_reference_to_reference) 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()
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()
7002 Diag(PP.getLocForEndOfToken(D.getCXXScopeSpec().getEndLoc()), in ParseDirectDeclarator()
7003 diag::err_expected_unqualified_id) in ParseDirectDeclarator()
7010 "There's a C++-specific check for tok::identifier above"); in ParseDirectDeclarator()
7039 Diag(Tok.getLocation(), diag::err_unexpected_unqualified_id) 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()
7087 Diag(PP.getLocForEndOfToken(D.getEllipsisLoc()), in ParseDirectDeclarator()
7088 diag::ext_abstract_pack_declarator_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()
7100 Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()), in ParseDirectDeclarator()
7101 diag::err_expected_member_name_or_semi_objcxx_keyword) in ParseDirectDeclarator()
7110 Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()), in ParseDirectDeclarator()
7111 diag::err_expected_member_name_or_semi) in ParseDirectDeclarator()
7116 Diag(Tok, diag::err_while_loop_outside_of_a_function); in ParseDirectDeclarator()
7119 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow); in ParseDirectDeclarator()
7123 Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id) in ParseDirectDeclarator()
7126 Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()), in ParseDirectDeclarator()
7127 diag::err_expected_unqualified_id) in ParseDirectDeclarator()
7131 Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()), in ParseDirectDeclarator()
7132 diag::err_expected_either) 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()
7202 Diag(Tok, diag::err_keyword_not_allowed) << Tok.getIdentifierInfo(); in ParseDirectDeclarator()
7218 Diag(Tok, diag::err_requires_clause_inside_parens); in ParseDirectDeclarator()
7224 // We're already ill-formed if we got here but we'll accept it anyway. in ParseDirectDeclarator()
7261 Diag(EndLoc, diag::err_expected) in ParseDecompositionDeclarator()
7264 Diag(Tok, diag::err_expected_comma_or_rsquare); in ParseDecompositionDeclarator()
7280 Diag(Tok, diag::err_expected) << tok::identifier; in ParseDecompositionDeclarator()
7290 Diag(Tok, getLangOpts().CPlusPlus26 in ParseDecompositionDeclarator()
7291 ? diag::warn_cxx23_compat_decl_attrs_on_binding in ParseDecompositionDeclarator()
7292 : diag::ext_decl_attrs_on_binding); in ParseDecompositionDeclarator()
7303 // C++17 does not allow the identifier-list in a structured binding in ParseDecompositionDeclarator()
7306 Diag(Tok.getLocation(), diag::ext_decomp_decl_empty); 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()
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()
7531 Diag(Tok, diag::err_argument_required_after_attribute); in ParseFunctionDeclarator()
7548 Diag(Tok, diag::err_argument_required_after_attribute); 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()
7633 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type); 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.
7691 Diag(Tok, getLangOpts().CPlusPlus11 ? in ParseRefQualifier()
7692 diag::warn_cxx98_compat_ref_qualifier : in ParseRefQualifier()
7693 diag::ext_ref_qualifier); in ParseRefQualifier()
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()
7751 Diag(Tok, diag::ext_ident_list_in_param); in ParseFunctionDeclaratorIdentifierList()
7759 Diag(Tok, diag::err_expected) << tok::identifier; in ParseFunctionDeclaratorIdentifierList()
7770 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII; in ParseFunctionDeclaratorIdentifierList()
7774 Diag(Tok, diag::err_param_redefinition) << ParmII; 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()
7831 Diag(Tok.getLocation(), diag::err_function_scope_depth_exceeded) 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()
7899 Diag(ThisLoc, diag::err_requires_expr_explicit_object_parameter); in ParseParameterDeclarationClause()
7911 // 'declarator' or 'abstract-declarator' here. in ParseParameterDeclarationClause()
7932 Diag(Tok, in ParseParameterDeclarationClause()
7933 diag::err_requires_clause_on_declarator_not_declaring_a_function); in ParseParameterDeclarationClause()
7951 Diag(DSStart, diag::err_missing_param); in ParseParameterDeclarationClause()
7985 Tok.getIdentifierInfo()->isKeyword(getLangOpts())) { in ParseParameterDeclarationClause()
7986 Diag(Tok, diag::err_keyword_as_parameter) << PP.getSpelling(Tok); in ParseParameterDeclarationClause()
8025 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); in ParseParameterDeclarationClause()
8029 Diag(Tok, diag::err_stmt_expr_in_default_arg) << 0; in ParseParameterDeclarationClause()
8058 // We have ellipsis without a preceding ',', which is ill-formed in ParseParameterDeclarationClause()
8060 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis) in ParseParameterDeclarationClause()
8067 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg) in ParseParameterDeclarationClause()
8070 Diag(ParmEllipsis, in ParseParameterDeclarationClause()
8071 diag::note_misplaced_ellipsis_vararg_existing_ellipsis); in ParseParameterDeclarationClause()
8073 Diag(ParmDeclarator.getIdentifierLoc(), in ParseParameterDeclarationClause()
8074 diag::note_misplaced_ellipsis_vararg_add_ellipsis) in ParseParameterDeclarationClause()
8079 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma) 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()
8144 // If there is a type-qualifier-list, read it now. in ParseBracketDeclarator()
8150 // type-qualifier-list. in ParseBracketDeclarator()
8154 // Handle "direct-declarator [ type-qual-list[opt] * ]". in ParseBracketDeclarator()
8166 Diag(StaticLoc, diag::err_unspecified_vla_size_with_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()
8188 Diag(StaticLoc, diag::err_unspecified_size_with_static); in ParseBracketDeclarator()
8193 // If there was an error parsing the assignment-expression, recover. in ParseBracketDeclarator()
8246 switch (D.getTypeObject(D.getNumTypeObjects() - 1).Kind) { in ParseMisplacedBracketDeclarator()
8286 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id) in ParseMisplacedBracketDeclarator()
8294 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id) 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()
8321 Diag(Tok.getLocation(), diag::warn_c23_compat_keyword) << Tok.getName(); in ParseTypeofSpecifier()
8359 Diag(StartLoc, DiagID) << PrevSpec; in ParseTypeofSpecifier()
8384 Diag(StartLoc, DiagID) << PrevSpec; in ParseTypeofSpecifier()
8387 /// [C11] atomic-specifier:
8388 /// _Atomic ( type-name )
8419 Diag(StartLoc, DiagID) << PrevSpec; in ParseAtomicSpecifier()
8422 /// TryAltiVecVectorTokenOutOfLine - Out of line body that should only be called
8508 // Consume (unexpanded) tokens up to the end-of-directive. in ParseTypeFromString()
8557 Diag(Tok.getLocation(), diag::err_type_unparsed); in ParseTypeFromString()
8580 Diag(Loc, diag::warn_ext_int_deprecated) in DiagnoseBitIntUse()
8583 // In C23 mode, diagnose that the use is not compatible with pre-C23 modes. in DiagnoseBitIntUse()
8586 Diag(Loc, diag::warn_c23_compat_keyword) << Tok.getName(); in DiagnoseBitIntUse()
8588 Diag(Loc, diag::ext_bit_int) << getLangOpts().CPlusPlus; in DiagnoseBitIntUse()