Lines Matching +full:semi +full:-

1 //===--- ParseDeclCXX.cpp - C++ Declaration Parsing -------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
37 /// ParseNamespace - We know that the current token is a namespace keyword. This
38 /// may either be a top level namespace or a block-level namespace alias. If
41 /// namespace-definition: [C++: namespace.def]
42 /// named-namespace-definition
43 /// unnamed-namespace-definition
44 /// nested-namespace-definition
46 /// named-namespace-definition:
48 /// namespace-body '}'
50 /// unnamed-namespace-definition:
51 /// 'inline'[opt] 'namespace' attributes[opt] '{' namespace-body '}'
53 /// nested-namespace-definition:
54 /// 'namespace' enclosing-namespace-specifier '::' 'inline'[opt]
55 /// identifier '{' namespace-body '}'
57 /// enclosing-namespace-specifier:
59 /// enclosing-namespace-specifier '::' 'inline'[opt] identifier
61 /// namespace-alias-definition: [C++ 7.3.2: namespace.alias]
62 /// 'namespace' identifier '=' qualified-namespace-specifier ';'
141 SkipUntil(tok::semi); in ParseNamespace()
149 SkipUntil(tok::semi); in ParseNamespace()
170 if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() || in ParseNamespace()
171 getCurScope()->isInObjcMethodScope() || getCurScope()->getBlockParent() || in ParseNamespace()
172 getCurScope()->getFnParent()) { in ParseNamespace()
179 // Normal namespace definition, not a nested-namespace-definition. in ParseNamespace()
210 NamespaceFix += ExtraNS.Ident->getName(); in ParseNamespace()
230 // If we're still good, complain about inline namespaces in non-C++0x now. in ParseNamespace()
261 /// ParseInnerNamespace - Parse the contents of a namespace.
275 // The caller is what called check -- we are simply calling in ParseInnerNamespace()
300 /// ParseNamespaceAlias - Parse the part after the '=' in a namespace
318 // Parse (optional) nested-name-specifier. in ParseNamespaceAlias()
330 SkipUntil(tok::semi); in ParseNamespaceAlias()
337 SkipUntil(tok::semi); in ParseNamespaceAlias()
347 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name)) in ParseNamespaceAlias()
348 SkipUntil(tok::semi); in ParseNamespaceAlias()
354 /// ParseLinkage - We know that the current token is a string_literal
357 /// linkage-specification: [C++ 7.5p2: dcl.link]
358 /// 'extern' string-literal '{' declaration-seq[opt] '}'
359 /// 'extern' string-literal declaration
411 --NestedModules; in ParseLinkage()
442 /// Parse a standard C++ Modules export-declaration.
444 /// export-declaration:
446 /// 'export' '{' declaration-seq[opt] '}'
450 /// export-function-declaration:
451 /// 'export' function-declaration
453 /// export-declaration-group:
454 /// 'export' '{' function-declaration-seq[opt] '}'
491 /// ParseUsingDirectiveOrDeclaration - Parse C++ using using-declaration or
492 /// using-directive. Assumes that current token is 'using'.
515 // 'using namespace' means this is a using-directive. in ParseUsingDirectiveOrDeclaration()
528 // Otherwise, it must be a using-declaration or an alias-declaration. in ParseUsingDirectiveOrDeclaration()
533 /// ParseUsingDirective - Parse C++ using-directive, assumes
536 /// using-directive: [C++ 7.3.p4: namespace.udir]
537 /// 'using' 'namespace' ::[opt] nested-name-specifier[opt]
538 /// namespace-name ;
539 /// [GNU] using-directive:
540 /// 'using' 'namespace' ::[opt] nested-name-specifier[opt]
541 /// namespace-name attributes[opt] ;
559 // Parse (optional) nested-name-specifier. in ParseUsingDirective()
571 // Parse namespace-name. in ParseUsingDirective()
575 SkipUntil(tok::semi); in ParseUsingDirective()
583 SkipUntil(tok::semi); in ParseUsingDirective()
591 // Parse (optional) attributes (most likely GNU strong-using extension). in ParseUsingDirective()
600 if (ExpectAndConsume(tok::semi, in ParseUsingDirective()
603 SkipUntil(tok::semi); in ParseUsingDirective()
609 /// Parse a using-declarator (or the identifier in a C++11 alias-declaration).
611 /// using-declarator:
612 /// 'typename'[opt] nested-name-specifier unqualified-id
619 // FIXME: This is wrong; we should parse this as a typename-specifier. in ParseUsingDeclarator()
627 // Parse nested-name-specifier. in ParseUsingDeclarator()
642 // Parse the unqualified-id. We allow parsing of both constructor and in ParseUsingDeclarator()
647 // [...] in a using-declaration that is a member-declaration, if the name in ParseUsingDeclarator()
648 // specified after the nested-name-specifier is the same as the identifier in ParseUsingDeclarator()
649 // or the simple-template-id's template-name in the last component of the in ParseUsingDeclarator()
650 // nested-name-specifier, the name is [...] considered to name the in ParseUsingDeclarator()
654 (NextToken().is(tok::semi) || NextToken().is(tok::comma) || in ParseUsingDeclarator()
659 !D.SS.getScopeRep()->getAsNamespace() && in ParseUsingDeclarator()
660 !D.SS.getScopeRep()->getAsNamespaceAlias()) { in ParseUsingDeclarator()
684 /// ParseUsingDeclaration - Parse C++ using-declaration or alias-declaration.
687 /// using-declaration: [C++ 7.3.p3: namespace.udecl]
688 /// 'using' using-declarator-list[opt] ;
690 /// using-declarator-list: [C++1z]
691 /// using-declarator '...'[opt]
692 /// using-declarator-list ',' using-declarator '...'[opt]
694 /// using-declarator-list: [C++98-14]
695 /// using-declarator
697 /// alias-declaration: C++11 [dcl.dcl]p1
698 /// 'using' identifier attribute-specifier-seq[opt] = type-id ;
700 /// using-enum-declaration: [C++20, dcl.enum]
701 /// 'using' elaborated-enum-specifier ;
702 /// The terminal name of the elaborated-enum-specifier undergoes
703 /// type-only lookup
705 /// elaborated-enum-specifier:
706 /// 'enum' nested-name-specifier[opt] identifier
716 // C++20 using-enum in ParseUsingDeclaration()
727 SkipUntil(tok::semi); in ParseUsingDeclaration()
739 SkipUntil(tok::semi); in ParseUsingDeclaration()
768 if (TemplateId->mightBeType()) { in ParseUsingDeclaration()
772 assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); in ParseUsingDeclaration()
778 UELoc, Loc, *TemplateId->Name, in ParseUsingDeclaration()
782 << TemplateId->Name->getName() in ParseUsingDeclaration()
783 << SourceRange(TemplateId->TemplateNameLoc, TemplateId->RAngleLoc); in ParseUsingDeclaration()
788 SkipUntil(tok::semi); in ParseUsingDeclaration()
793 SkipUntil(tok::semi); in ParseUsingDeclaration()
798 if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseUsingDeclaration()
799 "using-enum declaration")) in ParseUsingDeclaration()
800 SkipUntil(tok::semi); in ParseUsingDeclaration()
806 // alias-declaration. in ParseUsingDeclaration()
825 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in ParseUsingDeclaration()
834 // Maybe this is an alias-declaration. in ParseUsingDeclaration()
837 SkipUntil(tok::semi); in ParseUsingDeclaration()
846 CurScope->setFlags(Scope::ScopeFlags::TypeAliasScope | in ParseUsingDeclaration()
847 CurScope->getFlags()); in ParseUsingDeclaration()
856 // Diagnose an attempt to declare a templated using-declaration. in ParseUsingDeclaration()
857 // In C++11, alias-declarations can be templates: in ParseUsingDeclaration()
878 SkipUntil(tok::comma, tok::semi, StopBeforeMatch); in ParseUsingDeclaration()
901 // Parse another using-declarator. in ParseUsingDeclaration()
914 if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseUsingDeclaration()
916 : UELoc.isValid() ? "using-enum declaration" in ParseUsingDeclaration()
918 SkipUntil(tok::semi); in ParseUsingDeclaration()
928 SkipUntil(tok::semi); in ParseAliasDeclarationAfterDeclarator()
937 int SpecKind = -1; in ParseAliasDeclarationAfterDeclarator()
945 if (SpecKind != -1) { in ParseAliasDeclarationAfterDeclarator()
948 Range = SourceRange(D.Name.TemplateId->LAngleLoc, in ParseAliasDeclarationAfterDeclarator()
949 D.Name.TemplateId->RAngleLoc); in ParseAliasDeclarationAfterDeclarator()
954 SkipUntil(tok::semi); in ParseAliasDeclarationAfterDeclarator()
962 SkipUntil(tok::semi); in ParseAliasDeclarationAfterDeclarator()
987 if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseAliasDeclarationAfterDeclarator()
990 SkipUntil(tok::semi); in ParseAliasDeclarationAfterDeclarator()
994 TemplateParams ? TemplateParams->data() : nullptr, in ParseAliasDeclarationAfterDeclarator()
995 TemplateParams ? TemplateParams->size() : 0); in ParseAliasDeclarationAfterDeclarator()
1004 if (BO->getOpcode() == BO_LAnd && in getStaticAssertNoMessageFixIt()
1005 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts())) in getStaticAssertNoMessageFixIt()
1006 return FixItHint::CreateReplacement(BO->getOperatorLoc(), ","); in getStaticAssertNoMessageFixIt()
1011 /// ParseStaticAssertDeclaration - Parse C++0x or C11 static_assert-declaration.
1013 /// [C++0x] static_assert-declaration:
1014 /// static_assert ( constant-expression , string-literal ) ;
1016 /// [C11] static_assert-declaration:
1017 /// _Static_assert ( constant-expression , string-literal ) ;
1071 SkipUntil(tok::semi); in ParseStaticAssertDeclaration()
1115 /// ParseDecltypeSpecifier - Parse a C++11 decltype specifier.
1140 if (Tok.getIdentifierInfo()->isStr("decltype")) in ParseDecltypeSpecifier()
1155 // the typename-specifier in a function-style cast expression may in ParseDecltypeSpecifier()
1173 [](Expr *E) { return E->hasPlaceholderType() ? ExprError() : E; }); in ParseDecltypeSpecifier()
1179 if (PP.isBacktrackEnabled() && Tok.is(tok::semi)) { in ParseDecltypeSpecifier()
1180 // Backtrack to get the location of the last token before the semi. in ParseDecltypeSpecifier()
1182 ConsumeToken(); // the semi. in ParseDecltypeSpecifier()
1184 assert(Tok.is(tok::semi)); in ParseDecltypeSpecifier()
1236 // the tokens in the backtracking cache - that we likely had to skip over in AnnotateExistingDecltypeSpecifier()
1238 // semi-colon. in AnnotateExistingDecltypeSpecifier()
1326 // the tokens in the backtracking cache - that we likely had to skip over in AnnotateExistingIndexedTypeNamePack()
1328 // semi-colon. in AnnotateExistingIndexedTypeNamePack()
1348 llvm_unreachable("passed in an unhandled type transformation built-in"); in TypeTransformTokToDeclSpec()
1385 /// ParseBaseTypeSpecifier - Parse a C++ base-type-specifier which is either a
1386 /// class name or decltype-specifier. Note that we only check that the result
1391 /// base-type-specifier: [C++11 class.derived]
1392 /// class-or-decltype
1393 /// class-or-decltype: [C++11 class.derived]
1394 /// nested-name-specifier[opt] class-name
1395 /// decltype-specifier
1396 /// class-name: [C++ class.name]
1398 /// simple-template-id
1400 /// In C++98, instead of base-type-specifier, we have:
1402 /// ::[opt] nested-name-specifier[opt] class-name
1412 // Parse optional nested-name-specifier in ParseBaseTypeSpecifier()
1421 // Parse decltype-specifier in ParseBaseTypeSpecifier()
1446 // Check whether we have a template-id that names a type. in ParseBaseTypeSpecifier()
1451 if (TemplateId->mightBeType()) { in ParseBaseTypeSpecifier()
1455 assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); in ParseBaseTypeSpecifier()
1474 // It looks the user intended to write a template-id here, but the in ParseBaseTypeSpecifier()
1475 // template-name was wrong. Try to fix that. in ParseBaseTypeSpecifier()
1489 // Parse the full template-id, then turn it into a type. in ParseBaseTypeSpecifier()
1494 takeTemplateIdAnnotation(Tok)->mightBeType()) in ParseBaseTypeSpecifier()
1563 /// Determine whether the following tokens are valid after a type-specifier
1565 /// true if there's any doubt, and is appropriate for insert-';' fixits.
1567 // This switch enumerates the valid "follow" set for type-specifiers. in isValidAfterTypeSpecifier()
1573 case tok::semi: // struct foo {...} ; in isValidAfterTypeSpecifier()
1610 // We will diagnose these calling-convention specifiers on non-function in isValidAfterTypeSpecifier()
1625 // Storage-class specifiers in isValidAfterTypeSpecifier()
1639 // it is much more likely that someone missed a semi colon and the in isValidAfterTypeSpecifier()
1650 // otherwise invalid, so we can produce the expected semi error. in isValidAfterTypeSpecifier()
1666 /// ParseClassSpecifier - Parse a C++ class-specifier [C++ class] or
1667 /// elaborated-type-specifier [C++ dcl.type.elab]; we can't tell which
1671 /// class-specifier: [C++ class]
1672 /// class-head '{' member-specification[opt] '}'
1673 /// class-head '{' member-specification[opt] '}' attributes[opt]
1674 /// class-head:
1675 /// class-key identifier[opt] base-clause[opt]
1676 /// class-key nested-name-specifier identifier base-clause[opt]
1677 /// class-key nested-name-specifier[opt] simple-template-id
1678 /// base-clause[opt]
1679 /// [GNU] class-key attributes[opt] identifier[opt] base-clause[opt]
1680 /// [GNU] class-key attributes[opt] nested-name-specifier
1681 /// identifier base-clause[opt]
1682 /// [GNU] class-key attributes[opt] nested-name-specifier[opt]
1683 /// simple-template-id base-clause[opt]
1684 /// class-key:
1689 /// elaborated-type-specifier: [C++ dcl.type.elab]
1690 /// class-key ::[opt] nested-name-specifier[opt] identifier
1691 /// class-key ::[opt] nested-name-specifier[opt] 'template'[opt]
1692 /// simple-template-id
1694 /// Note that the C++ class-specifier and elaborated-type-specifier,
1695 /// together, subsume the C99 struct-or-union-specifier:
1697 /// struct-or-union-specifier: [C99 6.7.2.1]
1698 /// struct-or-union identifier[opt] '{' struct-contents '}'
1699 /// struct-or-union identifier
1700 /// [GNU] struct-or-union attributes[opt] identifier[opt] '{' struct-contents
1702 /// [GNU] struct-or-union attributes[opt] identifier
1703 /// struct-or-union:
1732 // The usual access checking rules do not apply to non-dependent names in ParseClassSpecifier()
1733 // used to specify template arguments of the simple-template-id of the in ParseClassSpecifier()
1842 AtomicII->revertTokenIDToIdentifier(); in ParseClassSpecifier()
1848 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic); in ParseClassSpecifier()
1864 // Parse the (optional) nested-name-specifier. in ParseClassSpecifier()
1868 // is a base-specifier-list. in ParseClassSpecifier()
1904 if (TemplateParams->size() > 1) { in ParseClassSpecifier()
1905 TemplateParams->pop_back(); in ParseClassSpecifier()
1919 // Parse the (optional) class name or simple-template-id. in ParseClassSpecifier()
1947 if (TemplateId->Kind == TNK_Undeclared_template) { in ParseClassSpecifier()
1950 getCurScope(), TemplateId->Template, TemplateId->Kind, NameLoc, Name); in ParseClassSpecifier()
1951 if (TemplateId->Kind == TNK_Undeclared_template) { in ParseClassSpecifier()
1954 SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc), true); in ParseClassSpecifier()
1959 if (TemplateId && !TemplateId->mightBeType()) { in ParseClassSpecifier()
1960 // The template-name in the simple-template-id refers to in ParseClassSpecifier()
1968 Diag(TemplateId->LAngleLoc, diag::err_template_spec_syntax_non_template) in ParseClassSpecifier()
1969 << TemplateId->Name << static_cast<int>(TemplateId->Kind) << Range; in ParseClassSpecifier()
1972 SkipUntil(tok::semi, StopBeforeMatch); in ParseClassSpecifier()
1978 // - If we are in a trailing return type, this is always just a reference, in ParseClassSpecifier()
1980 // [] () -> struct S { }; in ParseClassSpecifier()
1982 // - If we have 'struct foo {...', 'struct foo :...', in ParseClassSpecifier()
1984 // - If we have 'struct foo;', then this is either a forward declaration in ParseClassSpecifier()
1986 // - Otherwise we have something like 'struct foo xyz', a reference. in ParseClassSpecifier()
1990 // - attributes follow class name: in ParseClassSpecifier()
1992 // - attributes appear before or after 'final': in ParseClassSpecifier()
1995 // However, in type-specifier-seq's, things look like declarations but are in ParseClassSpecifier()
2025 SkipUntil(tok::semi, StopBeforeMatch); in ParseClassSpecifier()
2076 (Tok.is(tok::semi) || in ParseClassSpecifier()
2079 if (Tok.isNot(tok::semi)) { in ParseClassSpecifier()
2082 ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseClassSpecifier()
2085 Tok.setKind(tok::semi); in ParseClassSpecifier()
2095 // is between class-key and class-name. If there are in ParseClassSpecifier()
2096 // any attributes after class-name, we try a fixit to move in ParseClassSpecifier()
2102 (FirstAttr && FirstAttr->isRegularKeywordAttribute() in ParseClassSpecifier()
2125 // If we are parsing a definition and stop at a base-clause, continue on in ParseClassSpecifier()
2129 SkipUntil(tok::semi, StopBeforeMatch); in ParseClassSpecifier()
2144 ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(), in ParseClassSpecifier()
2145 TemplateId->NumArgs); in ParseClassSpecifier()
2146 if (TemplateId->isInvalid()) { in ParseClassSpecifier()
2157 TagType, StartLoc, SS, TemplateId->Template, in ParseClassSpecifier()
2158 TemplateId->TemplateNameLoc, TemplateId->LAngleLoc, TemplateArgsPtr, in ParseClassSpecifier()
2159 TemplateId->RAngleLoc, attrs); in ParseClassSpecifier()
2161 // Friend template-ids are treated as references unless in ParseClassSpecifier()
2162 // they have template headers, in which case they're ill-formed in ParseClassSpecifier()
2172 TUK, TagType, StartLoc, SS, TemplateId->TemplateKWLoc, in ParseClassSpecifier()
2173 TemplateId->Template, TemplateId->TemplateNameLoc, in ParseClassSpecifier()
2174 TemplateId->LAngleLoc, TemplateArgsPtr, TemplateId->RAngleLoc); in ParseClassSpecifier()
2200 Diag(TemplateId->TemplateNameLoc, in ParseClassSpecifier()
2221 TemplateParams ? TemplateParams->size() : 0), in ParseClassSpecifier()
2246 TemplateParams ? TemplateParams->size() : 0)); in ParseClassSpecifier()
2255 // If the declarator-id is not a template-id, issue a diagnostic and in ParseClassSpecifier()
2270 MultiTemplateParamsArg(&(*TemplateParams)[0], TemplateParams->size()); in ParseClassSpecifier()
2350 // At this point, we've successfully parsed a class-specifier in 'definition' in ParseClassSpecifier()
2357 // In a template-declaration which defines a class, no declarator in ParseClassSpecifier()
2360 // After a type-specifier, we don't expect a semicolon. This only happens in in ParseClassSpecifier()
2365 if (Tok.isNot(tok::semi)) { in ParseClassSpecifier()
2367 ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseClassSpecifier()
2373 Tok.setKind(tok::semi); in ParseClassSpecifier()
2378 /// ParseBaseClause - Parse the base-clause of a C++ class [C++ class.derived].
2380 /// base-clause : [C++ class.derived]
2381 /// ':' base-specifier-list
2382 /// base-specifier-list:
2383 /// base-specifier '...'[opt]
2384 /// base-specifier-list ',' base-specifier '...'[opt]
2393 // Parse a base-specifier. in ParseBaseClause()
2405 // base-specifiers. in ParseBaseClause()
2414 /// ParseBaseSpecifier - Parse a C++ base-specifier. A base-specifier is
2417 /// 'public bar' and 'virtual private baz' are each base-specifiers.
2419 /// base-specifier: [C++ class.derived]
2420 /// attribute-specifier-seq[opt] base-type-specifier
2421 /// attribute-specifier-seq[opt] 'virtual' access-specifier[opt]
2422 /// base-type-specifier
2423 /// attribute-specifier-seq[opt] access-specifier 'virtual'[opt]
2424 /// base-type-specifier
2463 // Parse the class-name. in ParseBaseSpecifier()
2468 // parsing the class-name for a base specifier. in ParseBaseSpecifier()
2480 // actually part of the base-specifier-list grammar productions, but we in ParseBaseSpecifier()
2485 // Find the complete source range for the base-specifier. in ParseBaseSpecifier()
2489 // base-specifier. in ParseBaseSpecifier()
2495 /// getAccessSpecifierIfPresent - Determine whether the next token is
2496 /// a C++ access-specifier.
2498 /// access-specifier: [C++ class.derived]
2516 /// delayed, e.g., default arguments or an exception-specification, create a
2517 /// late-parsed method declaration record to handle the parsing at the end of
2522 // If there was a late-parsed exception-specification, we'll need a in HandleMemberFunctionDeclDelays()
2530 if (Param->hasUnparsedDefaultArg()) { in HandleMemberFunctionDeclDelays()
2538 // Push this method onto the stack of late-parsed method in HandleMemberFunctionDeclDelays()
2546 LateMethod->DefaultArgs.reserve(FTI.NumParams); in HandleMemberFunctionDeclDelays()
2548 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument( in HandleMemberFunctionDeclDelays()
2552 // Stash the exception-specification tokens in the late-pased method. in HandleMemberFunctionDeclDelays()
2554 LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens; in HandleMemberFunctionDeclDelays()
2560 /// isCXX11VirtSpecifier - Determine whether the given token is a C++11
2561 /// virt-specifier.
2563 /// virt-specifier:
2603 /// ParseOptionalCXX11VirtSpecifierSeq - Parse a virt-specifier-seq.
2605 /// virt-specifier-seq:
2606 /// virt-specifier
2607 /// virt-specifier-seq virt-specifier
2626 // A virt-specifier-seq shall contain at most one of each virt-specifier. in ParseOptionalCXX11VirtSpecifierSeq()
2653 /// isCXX11FinalKeyword - Determine whether the next token is a C++11
2662 /// isClassCompatibleKeyword - Determine whether the next token is a C++11
2672 /// Parse a C++ member-declarator up to, but not including, the optional
2673 /// brace-or-equal-initializer or pure-specifier.
2677 // member-declarator: in ParseCXXMemberDeclaratorBeforeInitializer()
2678 // declarator virt-specifier-seq[opt] pure-specifier[opt] in ParseCXXMemberDeclaratorBeforeInitializer()
2679 // declarator requires-clause in ParseCXXMemberDeclaratorBeforeInitializer()
2680 // declarator brace-or-equal-initializer[opt] in ParseCXXMemberDeclaratorBeforeInitializer()
2681 // identifier attribute-specifier-seq[opt] ':' constant-expression in ParseCXXMemberDeclaratorBeforeInitializer()
2682 // brace-or-equal-initializer[opt] in ParseCXXMemberDeclaratorBeforeInitializer()
2683 // ':' constant-expression in ParseCXXMemberDeclaratorBeforeInitializer()
2713 // If a simple-asm-expr is present, parse it. in ParseCXXMemberDeclaratorBeforeInitializer()
2732 // virt-specifier *after* the GNU attributes. in ParseCXXMemberDeclaratorBeforeInitializer()
2738 // If we saw any GNU-style attributes that are known to GCC followed by a in ParseCXXMemberDeclaratorBeforeInitializer()
2739 // virt-specifier, issue a GCC-compat warning. in ParseCXXMemberDeclaratorBeforeInitializer()
2750 // wrong. Skip until the semi-colon or }. in ParseCXXMemberDeclaratorBeforeInitializer()
2752 // If so, skip until the semi-colon or a }. in ParseCXXMemberDeclaratorBeforeInitializer()
2760 /// virt-specifier-seq and diagnose them.
2765 // GNU-style and C++11 attributes are not allowed here, but they will be in MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq()
2795 // Parse ref-qualifiers. in MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq()
2814 /// ParseCXXClassMemberDeclaration - Parse a C++ class member declaration.
2816 /// member-declaration:
2817 /// decl-specifier-seq[opt] member-declarator-list[opt] ';'
2818 /// function-definition ';'[opt]
2819 /// ::[opt] nested-name-specifier template[opt] unqualified-id ';'[TODO]
2820 /// using-declaration [TODO]
2821 /// [C++0x] static_assert-declaration
2822 /// template-declaration
2823 /// [GNU] '__extension__' member-declaration
2825 /// member-declarator-list:
2826 /// member-declarator
2827 /// member-declarator-list ',' member-declarator
2829 /// member-declarator:
2830 /// declarator virt-specifier-seq[opt] pure-specifier[opt]
2831 /// [C++2a] declarator requires-clause
2832 /// declarator constant-initializer[opt]
2833 /// [C++11] declarator brace-or-equal-initializer[opt]
2834 /// identifier[opt] ':' constant-expression
2836 /// virt-specifier-seq:
2837 /// virt-specifier
2838 /// virt-specifier-seq virt-specifier
2840 /// virt-specifier:
2845 /// pure-specifier:
2848 /// constant-initializer:
2849 /// '=' constant-expression
2886 isAccessDecl = GetLookAheadToken(2).is(tok::semi); in ParseCXXClassMemberDeclaration()
2898 SkipUntil(tok::semi); in ParseCXXClassMemberDeclaration()
2902 // Try to parse an unqualified-id. in ParseCXXClassMemberDeclaration()
2908 SkipUntil(tok::semi); in ParseCXXClassMemberDeclaration()
2912 // TODO: recover from mistakenly-qualified operator declarations. in ParseCXXClassMemberDeclaration()
2913 if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseCXXClassMemberDeclaration()
2915 SkipUntil(tok::semi); in ParseCXXClassMemberDeclaration()
2928 // static_assert-declaration. A templated static_assert declaration is in ParseCXXClassMemberDeclaration()
2946 // Handle: member-declaration ::= '__extension__' member-declaration in ParseCXXClassMemberDeclaration()
2956 // Optional C++11 attribute-specifier in ParseCXXClassMemberDeclaration()
2978 SkipUntil(tok::semi, StopBeforeMatch); in ParseCXXClassMemberDeclaration()
2982 // Otherwise, it must be a using-declaration or an alias-declaration. in ParseCXXClassMemberDeclaration()
2990 // Hold late-parsed attributes so we can attach a Decl to them later. in ParseCXXClassMemberDeclaration()
2993 // decl-specifier-seq: in ParseCXXClassMemberDeclaration()
2994 // Parse the common declaration-specifiers piece. in ParseCXXClassMemberDeclaration()
3020 // If we had a free-standing type definition with a missing semicolon, we in ParseCXXClassMemberDeclaration()
3029 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data() in ParseCXXClassMemberDeclaration()
3031 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0); in ParseCXXClassMemberDeclaration()
3033 if (TryConsumeToken(tok::semi)) { in ParseCXXClassMemberDeclaration()
3058 // Hold late-parsed attributes so we can attach a Decl to them later. in ParseCXXClassMemberDeclaration()
3075 if (!After.isOneOf(tok::semi, tok::comma) && in ParseCXXClassMemberDeclaration()
3098 TryConsumeToken(tok::semi); in ParseCXXClassMemberDeclaration()
3113 // function-definition: in ParseCXXClassMemberDeclaration()
3115 // In C++11, a non-function declarator followed by an open brace is a in ParseCXXClassMemberDeclaration()
3116 // braced-init-list for an in-class member initialization, not an in ParseCXXClassMemberDeclaration()
3139 // C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains in ParseCXXClassMemberDeclaration()
3156 TryConsumeToken(tok::semi); in ParseCXXClassMemberDeclaration()
3174 CommonLateParsedAttrs[i]->addDecl(FunDecl); in ParseCXXClassMemberDeclaration()
3177 LateParsedAttrs[i]->addDecl(FunDecl); in ParseCXXClassMemberDeclaration()
3182 // Consume the ';' - it's optional unless we have a delete or default in ParseCXXClassMemberDeclaration()
3183 if (Tok.is(tok::semi)) in ParseCXXClassMemberDeclaration()
3190 // member-declarator-list: in ParseCXXClassMemberDeclaration()
3191 // member-declarator in ParseCXXClassMemberDeclaration()
3192 // member-declarator-list ',' member-declarator in ParseCXXClassMemberDeclaration()
3198 // DRXXXX: Anonymous bit-fields cannot have a brace-or-equal-initializer. in ParseCXXClassMemberDeclaration()
3200 // Diagnose the error and pretend there is no in-class initializer. in ParseCXXClassMemberDeclaration()
3204 // It's a pure-specifier. in ParseCXXClassMemberDeclaration()
3231 // C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains in ParseCXXClassMemberDeclaration()
3254 // Re-direct this decl to refer to the templated decl so that we can in ParseCXXClassMemberDeclaration()
3256 ThisDecl = VT->getTemplatedDecl(); in ParseCXXClassMemberDeclaration()
3262 // Error recovery might have converted a non-static member into a static in ParseCXXClassMemberDeclaration()
3290 // A brace-or-equal-initializer for a member-declarator is not an in ParseCXXClassMemberDeclaration()
3291 // initializer in the grammar, so this is ill-formed. in ParseCXXClassMemberDeclaration()
3297 ThisDecl->setInvalidDecl(); in ParseCXXClassMemberDeclaration()
3317 if (!ThisDecl->isInvalidDecl()) { in ParseCXXClassMemberDeclaration()
3320 CommonLateParsedAttrs[i]->addDecl(ThisDecl); in ParseCXXClassMemberDeclaration()
3323 LateParsedAttrs[i]->addDecl(ThisDecl); in ParseCXXClassMemberDeclaration()
3345 // This comma was followed by a line-break and something which can't be in ParseCXXClassMemberDeclaration()
3355 // In a template-declaration, explicit specialization, or explicit in ParseCXXClassMemberDeclaration()
3356 // instantiation the init-declarator-list in the declaration shall in ParseCXXClassMemberDeclaration()
3384 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) { in ParseCXXClassMemberDeclaration()
3388 TryConsumeToken(tok::semi); in ParseCXXClassMemberDeclaration()
3395 /// ParseCXXMemberInitializer - Parse the brace-or-equal-initializer.
3399 /// This does not check for a pure-specifier; that's handled elsewhere.
3401 /// brace-or-equal-initializer:
3402 /// '=' initializer-expression
3403 /// braced-init-list
3405 /// initializer-clause:
3406 /// assignment-expression
3407 /// braced-init-list
3409 /// defaulted/deleted function-definition:
3413 /// Prior to C++0x, the assignment-expression in an initializer-clause must
3414 /// be a constant-expression.
3438 // never type-check. It's better to diagnose it as an ill-formed in ParseCXXMemberInitializer()
3439 // expression than as an ill-formed deleted non-function member. An in ParseCXXMemberInitializer()
3441 // top-level comma always ends the initializer expression. in ParseCXXMemberInitializer()
3443 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) { in ParseCXXMemberInitializer()
3483 // we only get called if there is a colon or left-brace after the in SkipCXXMemberSpecification()
3536 case tok::semi: in ParseCXXClassMemberDeclarationWithPragmas()
3537 // Check for extraneous top-level semicolon. in ParseCXXClassMemberDeclarationWithPragmas()
3593 } else if (TryConsumeToken(tok::semi, EndLoc)) { in ParseCXXClassMemberDeclarationWithPragmas()
3602 // The Microsoft extension __interface does not permit non-public in ParseCXXClassMemberDeclarationWithPragmas()
3636 /// ParseCXXMemberSpecification - Parse the class definition.
3638 /// member-specification:
3639 /// member-declaration member-specification[opt]
3640 /// access-specifier ':' member-specification[opt]
3653 return TD->getQualifiedNameAsString(); in ParseCXXMemberSpecification()
3660 // Determine whether this is a non-nested class. Note that local in ParseCXXMemberSpecification()
3664 for (const Scope *S = getCurScope(); S; S = S->getParent()) { in ParseCXXMemberSpecification()
3665 if (S->isClassScope()) { in ParseCXXMemberSpecification()
3674 ? cast<NamedDecl>(TagDecl)->getQualifiedNameAsString() in ParseCXXMemberSpecification()
3680 if (S->isFunctionScope()) in ParseCXXMemberSpecification()
3690 // Note that we are parsing a new (potentially-nested) class definition. in ParseCXXMemberSpecification()
3749 // to the class would be between class-key and class-name. in ParseCXXMemberSpecification()
3767 ParseScope InheritanceScope(this, getCurScope()->getFlags() | in ParseCXXMemberSpecification()
3784 // base-clause can have simple-template-id; 'template' can't be there in ParseCXXMemberSpecification()
3800 // Try recovering from missing { after base-clause. in ParseCXXMemberSpecification()
3832 // While we still have something to read, read the member-declarations. in ParseCXXMemberSpecification()
3835 // Each iteration of this loop reads one member-declaration. in ParseCXXMemberSpecification()
3855 // Within the class member-specification, the class is regarded as complete in ParseCXXMemberSpecification()
3856 // within function bodies, default arguments, exception-specifications, and in ParseCXXMemberSpecification()
3857 // brace-or-equal-initializers for non-static data members (including such in ParseCXXMemberSpecification()
3895 Diag(D->getLocation(), diag::err_missing_end_of_definition) << D; in DiagnoseUnexpectedNamespace()
3903 Tok.setKind(tok::semi); in DiagnoseUnexpectedNamespace()
3909 /// ParseConstructorInitializer - Parse a C++ constructor initializer,
3924 /// [C++] ctor-initializer:
3925 /// ':' mem-initializer-list
3927 /// [C++] mem-initializer-list:
3928 /// mem-initializer ...[opt]
3929 /// mem-initializer ...[opt] , mem-initializer-list
3981 /// ParseMemInitializer - Parse a C++ member initializer, which is
3986 /// [C++] mem-initializer:
3987 /// mem-initializer-id '(' expression-list[opt] ')'
3988 /// [C++0x] mem-initializer-id braced-init-list
3990 /// [C++] mem-initializer-id:
3991 /// '::'[opt] nested-name-specifier[opt] class-name
3994 // parse '::'[opt] nested-name-specifier[opt] in ParseMemInitializer()
4028 if (TemplateId && TemplateId->mightBeType()) { in ParseMemInitializer()
4031 assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); in ParseMemInitializer()
4061 // Parse the optional expression-list. in ParseMemInitializer()
4104 /// Parse a C++ exception-specification if present (C++0x [except.spec]).
4106 /// exception-specification:
4107 /// dynamic-exception-specification
4108 /// noexcept-specification
4110 /// noexcept-specification:
4112 /// 'noexcept' '(' constant-expression ')'
4121 // Handle delayed parsing of exception-specifications. in tryParseExceptionSpecification()
4144 // Cache the tokens for the exception-specification. in tryParseExceptionSpecification()
4146 ExceptionSpecTokens->push_back(StartTok); // 'throw' or 'noexcept' in tryParseExceptionSpecification()
4147 ExceptionSpecTokens->push_back(Tok); // '(' in tryParseExceptionSpecification()
4153 SpecificationRange.setEnd(ExceptionSpecTokens->back().getLocation()); in tryParseExceptionSpecification()
4232 /// ParseDynamicExceptionSpecification - Parse a C++
4233 /// dynamic-exception-specification (C++ [except.spec]).
4235 /// dynamic-exception-specification:
4236 /// 'throw' '(' type-id-list [opt] ')'
4239 /// type-id-list:
4240 /// type-id ... [opt]
4241 /// type-id-list ',' type-id ... [opt]
4268 // Parse the sequence of type-ids. in ParseDynamicExceptionSpecification()
4275 // - In a dynamic-exception-specification (15.4); the pattern is a in ParseDynamicExceptionSpecification()
4276 // type-id. in ParseDynamicExceptionSpecification()
4299 /// ParseTrailingReturnType - Parse a trailing return type on a new-style
4312 /// Parse a requires-clause as part of a function declaration.
4319 // For each non-friend redeclaration or specialization whose target scope in ParseTrailingRequiresClause()
4320 // is or is contained by the scope, the portion after the declarator-id, in ParseTrailingRequiresClause()
4321 // class-head-name, or enum-head-name is also included in the scope. in ParseTrailingRequiresClause()
4323 // For each non-friend redeclaration or specialization whose target scope in ParseTrailingRequiresClause()
4324 // is or is contained by the scope, the portion after the declarator-id, in ParseTrailingRequiresClause()
4325 // class-head-name, or enum-head-name is also included in the scope. in ParseTrailingRequiresClause()
4401 for (unsigned I = 0, N = Class->LateParsedDeclarations.size(); I != N; ++I) in DeallocateParsedClasses()
4402 delete Class->LateParsedDeclarations[I]; in DeallocateParsedClasses()
4419 if (Victim->TopLevelClass) { in PopParsingClass()
4425 assert(!ClassStack.empty() && "Missing top-level class?"); in PopParsingClass()
4427 if (Victim->LateParsedDeclarations.empty()) { in PopParsingClass()
4437 // after the top-level class is completely defined. Therefore, add in PopParsingClass()
4439 assert(getCurScope()->isClassScope() && in PopParsingClass()
4441 ClassStack.top()->LateParsedDeclarations.push_back( in PopParsingClass()
4445 /// Try to parse an 'identifier' which appears within an attribute-token.
4448 /// attribute-token.
4452 /// requirements of an identifier is contained in an attribute-token,
4532 if (AttrName->isStr("directive")) { in ParseOpenMPAttributeArgs()
4550 assert(AttrName->isStr("sequence") && in ParseOpenMPAttributeArgs()
4564 if (Ident && Ident->isStr("omp") && !ExpectAndConsume(tok::coloncolon)) in ParseOpenMPAttributeArgs()
4569 if (!Ident || (!Ident->isStr("directive") && !Ident->isStr("sequence"))) { in ParseOpenMPAttributeArgs()
4599 return !ScopeName && AttrName->getName() == "nodiscard"; in IsBuiltInOrStandardCXX11Attribute()
4601 return !ScopeName && AttrName->getName() == "maybe_unused"; in IsBuiltInOrStandardCXX11Attribute()
4639 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr) in ParseCXXAssumeAttributeArg()
4640 << AttrName << FixItHint::CreateInsertion(E->getBeginLoc(), "(") in ParseCXXAssumeAttributeArg()
4641 << FixItHint::CreateInsertion(PP.getLocForEndOfToken(E->getEndLoc()), in ParseCXXAssumeAttributeArg()
4643 << E->getSourceRange(); in ParseCXXAssumeAttributeArg()
4663 /// ParseCXX11AttributeArgs -- Parse a C++11 attribute-argument-clause.
4665 /// [C++11] attribute-argument-clause:
4666 /// '(' balanced-token-seq ')'
4668 /// [C++11] balanced-token-seq:
4669 /// balanced-token
4670 /// balanced-token-seq balanced-token
4672 /// [C++11] balanced-token:
4673 /// '(' balanced-token-seq ')'
4674 /// '[' balanced-token-seq ']'
4675 /// '{' balanced-token-seq '}'
4706 if (ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"))) { in ParseCXX11AttributeArgs()
4707 // GNU-scoped attributes have some special cases to handle GNU-specific in ParseCXX11AttributeArgs()
4715 if (ScopeName && ScopeName->isStr("omp") && in ParseCXX11AttributeArgs()
4716 (AttrName->isStr("directive") || AttrName->isStr("sequence"))) { in ParseCXX11AttributeArgs()
4729 // Some Clang-scoped attributes have some special parsing behavior. in ParseCXX11AttributeArgs()
4730 if (ScopeName && (ScopeName->isStr("clang") || ScopeName->isStr("_Clang"))) in ParseCXX11AttributeArgs()
4734 else if (!ScopeName && AttrName->isStr("assume")) { in ParseCXX11AttributeArgs()
4753 // If the attribute is a standard or built-in attribute and we are in ParseCXX11AttributeArgs()
4764 // arguments. It doesn't matter whether any were provided -- the in ParseCXX11AttributeArgs()
4775 /// Parse a C++11 or C23 attribute-specifier.
4777 /// [C++11] attribute-specifier:
4778 /// '[' '[' attribute-list ']' ']'
4779 /// alignment-specifier
4781 /// [C++11] attribute-list:
4783 /// attribute-list ',' attribute[opt]
4785 /// attribute-list ',' attribute '...'
4788 /// attribute-token attribute-argument-clause[opt]
4790 /// [C++11] attribute-token:
4792 /// attribute-scoped-token
4794 /// [C++11] attribute-scoped-token:
4795 /// attribute-namespace '::' identifier
4797 /// [C++11] attribute-namespace:
4803 // alignas is a valid token in C23 but it is not an attribute, it's a type- in ParseCXX11AttributeSpecifierInternal()
4804 // specifier-qualifier, which means it has different parsing behavior. We in ParseCXX11AttributeSpecifierInternal()
4866 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) { in ParseCXX11AttributeSpecifierInternal()
4937 if (Tok.is(tok::semi)) { in ParseCXX11AttributeSpecifierInternal()
4953 /// ParseCXX11Attributes - Parse a C++11 or C23 attribute-specifier-seq.
4955 /// attribute-specifier-seq:
4956 /// attribute-specifier-seq[opt] attribute-specifier
5017 assert(UuidIdent->getName() == "uuid" && "Not a Microsoft attribute list"); in ParseMicrosoftUuidAttributeArgs()
5031 // Easy case: uuid("...") -- quoted string. in ParseMicrosoftUuidAttributeArgs()
5037 // something like uuid({000000A0-0000-0000-C000-000000000049}) -- no in ParseMicrosoftUuidAttributeArgs()
5044 // Since none of C++'s keywords match [a-f]+, accepting just tok::l_brace, in ParseMicrosoftUuidAttributeArgs()
5098 /// ParseMicrosoftAttributes - Parse Microsoft attributes [Attr]
5100 /// [MS] ms-attribute:
5101 /// '[' token-seq ']'
5103 /// [MS] ms-attribute-seq:
5104 /// ms-attribute[opt]
5105 /// ms-attribute ms-attribute-seq
5130 if (Tok.getIdentifierInfo()->getName() == "uuid") in ParseMicrosoftAttributes()
5200 // Check for extraneous top-level semicolon. in ParseMicrosoftIfExistsClassDeclaration()
5201 if (Tok.is(tok::semi)) { in ParseMicrosoftIfExistsClassDeclaration()