Lines Matching +full:semi +full:-

1 //===--- ParseStmt.cpp - Statement and Block Parser -----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
34 //===----------------------------------------------------------------------===//
36 //===----------------------------------------------------------------------===//
54 /// ParseStatementOrDeclaration - Read 'statement' or 'declaration'.
60 /// labeled-statement
61 /// compound-statement
62 /// expression-statement
63 /// selection-statement
64 /// iteration-statement
65 /// jump-statement
66 /// [C++] declaration-statement
67 /// [C++] try-block
68 /// [MS] seh-try-block
69 /// [OBC] objc-throw-statement
70 /// [OBC] objc-try-catch-statement
71 /// [OBC] objc-synchronized-statement
72 /// [GNU] asm-statement
73 /// [OMP] openmp-construct [TODO]
75 /// labeled-statement:
77 /// 'case' constant-expression ':' statement
80 /// selection-statement:
81 /// if-statement
82 /// switch-statement
84 /// iteration-statement:
85 /// while-statement
86 /// do-statement
87 /// for-statement
89 /// expression-statement:
92 /// jump-statement:
99 /// [OBC] objc-throw-statement:
151 nextTok.isOneOf(tok::l_paren, tok::semi, tok::identifier, tok::l_brace); in StatementFilterCCC()
205 if (Next.is(tok::colon)) { // C99 6.8.1: labeled-statement in ParseStatementOrDeclarationAfterAttributes()
216 // Look up the identifier, and typo-correct it to a keyword if it's not in ParseStatementOrDeclarationAfterAttributes()
226 if (Tok.is(tok::semi)) in ParseStatementOrDeclarationAfterAttributes()
231 // If the identifier was typo-corrected, try again. in ParseStatementOrDeclarationAfterAttributes()
287 << Tok.getIdentifierInfo()->getName() << 0; in ParseStatementOrDeclarationAfterAttributes()
302 case tok::kw_case: // C99 6.8.1: labeled-statement in ParseStatementOrDeclarationAfterAttributes()
304 case tok::kw_default: // C99 6.8.1: labeled-statement in ParseStatementOrDeclarationAfterAttributes()
307 case tok::l_brace: // C99 6.8.2: compound-statement in ParseStatementOrDeclarationAfterAttributes()
309 case tok::semi: { // C99 6.8.3p3: expression[opt] ';' in ParseStatementOrDeclarationAfterAttributes()
314 case tok::kw_if: // C99 6.8.4.1: if-statement in ParseStatementOrDeclarationAfterAttributes()
316 case tok::kw_switch: // C99 6.8.4.2: switch-statement in ParseStatementOrDeclarationAfterAttributes()
319 case tok::kw_while: // C99 6.8.5.1: while-statement in ParseStatementOrDeclarationAfterAttributes()
321 case tok::kw_do: // C99 6.8.5.2: do-statement in ParseStatementOrDeclarationAfterAttributes()
325 case tok::kw_for: // C99 6.8.5.3: for-statement in ParseStatementOrDeclarationAfterAttributes()
328 case tok::kw_goto: // C99 6.8.6.1: goto-statement in ParseStatementOrDeclarationAfterAttributes()
332 case tok::kw_continue: // C99 6.8.6.2: continue-statement in ParseStatementOrDeclarationAfterAttributes()
336 case tok::kw_break: // C99 6.8.6.3: break-statement in ParseStatementOrDeclarationAfterAttributes()
340 case tok::kw_return: // C99 6.8.6.4: return-statement in ParseStatementOrDeclarationAfterAttributes()
351 // Could be relaxed if asm-related regular keyword attributes are in ParseStatementOrDeclarationAfterAttributes()
376 case tok::kw_try: // C++ 15: try-block in ParseStatementOrDeclarationAfterAttributes()
534 if (!TryConsumeToken(tok::semi) && !Res.isInvalid()) { in ParseStatementOrDeclarationAfterAttributes()
538 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt, SemiError); in ParseStatementOrDeclarationAfterAttributes()
560 if (Tok.is(tok::semi)) in ParseExprStatement()
565 if (Tok.is(tok::colon) && getCurScope()->isSwitchScope() && in ParseExprStatement()
586 CurTok->setAnnotationValue(R.get()); in ParseExprStatement()
593 /// seh-try-block:
594 /// '__try' compound-statement seh-handler
596 /// seh-handler:
597 /// seh-except-block
598 /// seh-finally-block
634 /// ParseSEHExceptBlock - Handle __except
636 /// seh-except-block:
637 /// '__except' '(' seh-filter-expression ')' compound-statement
651 Ident__exception_info->setIsPoisoned(false); in ParseSEHExceptBlock()
652 Ident___exception_info->setIsPoisoned(false); in ParseSEHExceptBlock()
653 Ident_GetExceptionInfo->setIsPoisoned(false); in ParseSEHExceptBlock()
658 ParseScopeFlags FilterScope(this, getCurScope()->getFlags() | in ParseSEHExceptBlock()
664 Ident__exception_info->setIsPoisoned(true); in ParseSEHExceptBlock()
665 Ident___exception_info->setIsPoisoned(true); in ParseSEHExceptBlock()
666 Ident_GetExceptionInfo->setIsPoisoned(true); in ParseSEHExceptBlock()
686 /// ParseSEHFinallyBlock - Handle __finally
688 /// seh-finally-block:
689 /// '__finally' compound-statement
713 /// seh-leave-statement:
726 P.Diag(SubStmt->getBeginLoc(), in DiagnoseLabelFollowedByDecl()
733 /// ParseLabeledStatement - We have an identifier and a ':' after it.
739 /// labeled-statement:
747 // [OpenMP 5.1] 2.1.3: A stand-alone directive may not be used in place of a in ParseLabeledStatement()
773 if (!getLangOpts().CPlusPlus || Tok.is(tok::semi)) in ParseLabeledStatement()
811 /// labeled-statement:
812 /// 'case' constant-expression ':' statement
813 /// [GNU] 'case' constant-expression '...' constant-expression ':' statement
819 // [OpenMP 5.1] 2.1.3: A stand-alone directive may not be used in place of a in ParseCaseStatement()
838 // TopLevelCase - This is the highest level we have parsed. 'case 1' in the in ParseCaseStatement()
842 // DeepestParsedCaseStmt - This is the deepest statement we have parsed, which in ParseCaseStatement()
850 SourceLocation CaseLoc = MissingCase ? Expr.get()->getExprLoc() : in ParseCaseStatement()
869 // If constant-expression is parsed unsuccessfully, recover by skipping in ParseCaseStatement()
894 } else if (TryConsumeToken(tok::semi, ColonLoc) || in ParseCaseStatement()
912 // continue parsing the sub-stmt. in ParseCaseStatement()
931 // If we found a non-case statement, start by parsing it. in ParseCaseStatement()
943 // Install the body into the most deeply-nested case. in ParseCaseStatement()
945 // Broken sub-stmt shouldn't prevent forming the case statement properly. in ParseCaseStatement()
957 /// labeled-statement:
964 // [OpenMP 5.1] 2.1.3: A stand-alone directive may not be used in place of a in ParseDefaultStatement()
973 } else if (TryConsumeToken(tok::semi, ColonLoc)) { in ParseDefaultStatement()
997 // Broken sub-stmt shouldn't prevent forming the case statement properly. in ParseDefaultStatement()
1011 /// ParseCompoundStatement - Parse a "{}" block.
1013 /// compound-statement: [C99 6.8.2]
1014 /// { block-item-list[opt] }
1015 /// [GNU] { label-declarations block-item-list } [TODO]
1017 /// block-item-list:
1018 /// block-item
1019 /// block-item-list block-item
1021 /// block-item:
1026 /// [GNU] label-declarations:
1027 /// [GNU] label-declaration
1028 /// [GNU] label-declarations label-declaration
1030 /// [GNU] label-declaration:
1031 /// [GNU] '__label__' identifier-list ';'
1127 /// Consume any extra semi-colons resulting in null statements,
1128 /// returning true if any tok::semi were consumed.
1130 if (!Tok.is(tok::semi)) in ConsumeNullStmt()
1136 while (Tok.is(tok::semi) && !Tok.hasLeadingEmptyMacro() && in ConsumeNullStmt()
1140 // Don't just ConsumeToken() this tok::semi, do store it in AST. in ConsumeNullStmt()
1147 // Did not consume any extra semi. in ConsumeNullStmt()
1161 while (GetLookAheadToken(LookAhead).is(tok::semi)) { in handleExprStmt()
1176 /// ParseCompoundStatementBody - Parse a sequence of statements optionally
1277 SkipUntil(tok::semi); in ParseCompoundStatementBody()
1293 // Warn the user that using option `-ffp-eval-method=source` on a in ParseCompoundStatementBody()
1294 // 32-bit target and feature `sse` disabled, or using in ParseCompoundStatementBody()
1327 /// [C++1z] '(' init-statement[opt] condition ')'
1336 /// Additionally, it will assign the location of the outer-most '(' and ')',
1362 // recover by skipping ahead to a semi and bailing out. If condexp is in ParseParenExprOrCondition()
1365 SkipUntil(tok::semi); in ParseParenExprOrCondition()
1422 /// Compute the column number will aligning tabs on TabStop (-ftabstop), this
1439 // FileOffset are 0-based and Column numbers are 1-based in getVisualIndentation()
1443 unsigned VisualColumn = 0; // Stored as 0-based column, here. in getVisualIndentation()
1446 for (const char *CurPos = EndPos - (ColNo - 1); CurPos != EndPos; in getVisualIndentation()
1450 VisualColumn += (TabStop - VisualColumn % TabStop); in getVisualIndentation()
1462 Tok.isOneOf(tok::semi, tok::r_brace) || Tok.isAnnotation() || in Check()
1493 /// if-statement: [C99 6.8.4.1]
1498 /// [C++23] 'if' '!' [opt] consteval compound-statement
1499 /// [C++23] 'if' '!' [opt] consteval compound-statement 'else' statement
1532 SkipUntil(tok::semi); in ParseIfStatement()
1538 // C99 6.8.4p3 - In C99, the if statement is a block. This is not in ParseIfStatement()
1546 // Names declared in the for-init-statement, and in the condition of if, in ParseIfStatement()
1572 // C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if in ParseIfStatement()
1577 // The substatement in a selection-statement (each substatement, in the else in ParseIfStatement()
1582 // -When the 'then' scope exits, we want the condition declaration to still be in ParseIfStatement()
1584 // -Sema will detect name clashes by considering declarations of a in ParseIfStatement()
1586 // -If we wanted the condition and substatement to be in the same scope, we in ParseIfStatement()
1632 // C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if in ParseIfStatement()
1638 // The substatement in a selection-statement (each substatement, in the else in ParseIfStatement()
1679 // Both invalid, or one is invalid and other is non-present: return error. in ParseIfStatement()
1686 S = Outer->getSubStmt(); in ParseIfStatement()
1720 /// switch-statement:
1729 SkipUntil(tok::semi); in ParseSwitchStatement()
1735 // C99 6.8.4p3 - In C99, the switch statement is a block. This is in ParseSwitchStatement()
1743 // Names declared in the for-init-statement, and in the condition of if, in ParseSwitchStatement()
1773 SkipUntil(tok::semi); in ParseSwitchStatement()
1777 // C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if in ParseSwitchStatement()
1782 // The substatement in a selection-statement (each substatement, in the else in ParseSwitchStatement()
1788 getCurScope()->AddFlags(Scope::BreakScope); in ParseSwitchStatement()
1794 getCurScope()->decrementMSManglingNumber(); in ParseSwitchStatement()
1807 /// while-statement: [C99 6.8.5.1]
1817 SkipUntil(tok::semi); in ParseWhileStatement()
1823 // C99 6.8.5p5 - In C99, the while statement is a block. This is not in ParseWhileStatement()
1831 // Names declared in the for-init-statement, and in the condition of if, in ParseWhileStatement()
1851 // C99 6.8.5p5 - In C99, the body of the while statement is a scope, even if in ParseWhileStatement()
1856 // The substatement in an iteration-statement implicitly defines a local scope in ParseWhileStatement()
1882 /// do-statement: [C99 6.8.5.2]
1889 // C99 6.8.5p5 - In C99, the do statement is a block. This is not in ParseDoStatement()
1899 // C99 6.8.5p5 - In C99, the body of the do statement is a scope, even if in ParseDoStatement()
1904 // The substatement in an iteration-statement implicitly defines a local scope in ParseDoStatement()
1920 SkipUntil(tok::semi, StopBeforeMatch); in ParseDoStatement()
1928 SkipUntil(tok::semi, StopBeforeMatch); in ParseDoStatement()
1936 // A do-while expression is not a condition, so can't have attributes. in ParseDoStatement()
1947 SkipUntil(tok::semi); in ParseDoStatement()
1982 /// for-statement: [C99 6.8.5.3]
1985 /// [C++] 'for' '(' for-init-statement condition[opt] ';' expression[opt] ')'
1989 /// '(' for-range-declaration ':' for-range-initializer ')'
1994 /// [C++] for-init-statement:
1995 /// [C++] expression-statement
1996 /// [C++] simple-declaration
1997 /// [C++23] alias-declaration
1999 /// [C++0x] for-range-declaration:
2000 /// [C++0x] attribute-specifier-seq[opt] type-specifier-seq declarator
2001 /// [C++0x] for-range-initializer:
2003 /// [C++0x] braced-init-list [TODO]
2014 SkipUntil(tok::semi); in ParseForStatement()
2021 // C99 6.8.5p5 - In C99, the for statement is a block. This is not in ParseForStatement()
2029 // Names declared in the for-init-statement, and in the condition of if, in ParseForStatement()
2033 // Names declared in the for-init-statement are in the same declarative-region in ParseForStatement()
2068 if (Tok.is(tok::semi)) { // for (; in ParseForStatement()
2099 if (!C99orCXXorObjC) { // Use of C99-style for loops in C90 mode? in ParseForStatement()
2124 } else if (Tok.is(tok::semi)) { // for (int x = 4; in ParseForStatement()
2153 // We already know this is not an init-statement within a for loop, so in ParseForStatement()
2154 // if we are parsing a C++11 range-based for loop, we should treat this in ParseForStatement()
2164 if (Tok.is(tok::semi)) { in ParseForStatement()
2177 // User tried to write the reasonable, but ill-formed, for-range-statement in ParseForStatement()
2180 << FirstPart.get()->getSourceRange(); in ParseForStatement()
2189 if (Tok.is(tok::semi)) in ParseForStatement()
2199 if (Tok.is(tok::semi)) { // for (...;; in ParseForStatement()
2205 // C++2a: We've parsed an init-statement; we might have a in ParseForStatement()
2206 // for-range-declaration next. in ParseForStatement()
2213 // FIXME: recovery if we don't see another semi! in ParseForStatement()
2218 Diag(FirstPart.get() ? FirstPart.get()->getBeginLoc() in ParseForStatement()
2223 << (FirstPart.get() ? FirstPart.get()->getSourceRange() in ParseForStatement()
2227 << /*for-loop*/ 2 in ParseForStatement()
2246 getCurScope()->AddFlags(Scope::BreakScope | Scope::ContinueScope); in ParseForStatement()
2261 if (!getCurScope()->isContinueScope()) in ParseForStatement()
2262 getCurScope()->AddFlags(Scope::BreakScope | Scope::ContinueScope); in ParseForStatement()
2266 if (Tok.isNot(tok::semi)) { in ParseForStatement()
2272 if (Tok.is(tok::semi)) { in ParseForStatement()
2279 // discarded-value expression, but it clearly should be. in ParseForStatement()
2287 // 'co_await' can only be used for a range-based for statement. in ParseForStatement()
2296 // We need to perform most of the semantic analysis for a C++0x for-range in ParseForStatement()
2298 // of an auto-typed loop variable. in ParseForStatement()
2311 // Similarly, we need to do the semantic analysis for a for-range in ParseForStatement()
2323 // C99 6.8.5p5 - In C99, the body of the for statement is a scope, even if in ParseForStatement()
2328 // The substatement in an iteration-statement implicitly defines a local scope in ParseForStatement()
2332 // for-init-statement/condition and a new scope for substatement in C++. in ParseForStatement()
2338 // for-init-statement. in ParseForStatement()
2342 getCurScope()->decrementMSManglingNumber(); in ParseForStatement()
2355 // Leave the for-scope. in ParseForStatement()
2374 /// jump-statement:
2396 SkipUntil(tok::semi, StopBeforeMatch); in ParseGotoStatement()
2409 /// jump-statement:
2420 /// jump-statement:
2431 /// jump-statement:
2433 /// 'return' braced-init-list ';'
2435 /// 'co_return' braced-init-list ';'
2443 if (Tok.isNot(tok::semi)) { in ParseReturnStatement()
2457 Diag(R.get()->getBeginLoc(), in ParseReturnStatement()
2461 << R.get()->getSourceRange(); in ParseReturnStatement()
2491 TempAttrs.addNew(Hint.PragmaNameLoc->Ident, Hint.Range, nullptr, in ParsePragmaLoopHint()
2492 Hint.PragmaNameLoc->Loc, ArgHints, 4, in ParsePragmaLoopHint()
2542 /// ParseFunctionTryBlock - Parse a C++ function-try-block.
2544 /// function-try-block:
2545 /// 'try' ctor-initializer[opt] compound-statement handler-seq
2568 // If we failed to parse the try-catch, we just give the function an empty in ParseFunctionTryBlock()
2588 // We're in code-completion mode. Skip parsing for all function bodies unless in trySkippingFunctionBody()
2589 // the body contains the code-completion point. in trySkippingFunctionBody()
2620 /// ParseCXXTryBlock - Parse a C++ try-block.
2622 /// try-block:
2623 /// 'try' compound-statement handler-seq
2632 /// ParseCXXTryBlockCommon - Parse the common part of try-block and
2633 /// function-try-block.
2635 /// try-block:
2636 /// 'try' compound-statement handler-seq
2638 /// function-try-block:
2639 /// 'try' ctor-initializer[opt] compound-statement handler-seq
2641 /// handler-seq:
2642 /// handler handler-seq[opt]
2644 /// [Borland] try-block:
2645 /// 'try' compound-statement seh-except-block
2646 /// 'try' compound-statement seh-finally-block
2659 // Borland allows SEH-handlers with 'try' in ParseCXXTryBlockCommon()
2686 // statement-like. in ParseCXXTryBlockCommon()
2705 /// ParseCXXCatchBlock - Parse a C++ catch block, called handler in the standard
2708 /// 'catch' '(' exception-declaration ')' compound-statement
2710 /// exception-declaration:
2711 /// attribute-specifier-seq[opt] type-specifier-seq declarator
2712 /// attribute-specifier-seq[opt] type-specifier-seq abstract-declarator[opt]
2725 // The name in a catch exception-declaration is local to the handler and in ParseCXXCatchBlock()
2731 // exception-declaration is equivalent to '...' or a parameter-declaration in ParseCXXCatchBlock()
2756 // FIXME: Possible draft standard bug: attribute-specifier should be allowed? in ParseCXXCatchBlock()