aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2025-01-10 19:22:46 +0900
committerNAKAMURA Takumi <geek4civic@gmail.com>2025-01-10 19:22:46 +0900
commit8b02a27fc607ebc54c5a811188b3cea5063564e7 (patch)
treec1ca7d4acca553301204ebb83383aa87cb59311a /clang/lib/Sema/SemaStmt.cpp
parent694a772457b2999b7bd68625a16bf0755e95dcdb (diff)
parent397ac44f623f891d8f05d6673a95984ac0a26671 (diff)
downloadllvm-users/chapuni/cov/merge/mcdcsort.zip
llvm-users/chapuni/cov/merge/mcdcsort.tar.gz
llvm-users/chapuni/cov/merge/mcdcsort.tar.bz2
Merge branch 'main' into users/chapuni/cov/merge/mcdcsortusers/chapuni/cov/merge/mcdcsort
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index d9149f7..25a07d0 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -625,6 +625,15 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl,
if (getCurScope()->isInOpenACCComputeConstructScope())
setFunctionHasBranchProtectedScope();
+ // OpenACC3.3 2.14.4:
+ // The update directive is executable. It must not appear in place of the
+ // statement following an 'if', 'while', 'do', 'switch', or 'label' in C or
+ // C++.
+ if (isa<OpenACCUpdateConstruct>(SubStmt)) {
+ Diag(SubStmt->getBeginLoc(), diag::err_acc_update_as_body) << /*Label*/ 4;
+ SubStmt = new (Context) NullStmt(SubStmt->getBeginLoc());
+ }
+
// Otherwise, things are good. Fill in the declaration and return it.
LabelStmt *LS = new (Context) LabelStmt(IdentLoc, TheDecl, SubStmt);
TheDecl->setStmt(LS);
@@ -1019,6 +1028,15 @@ StmtResult Sema::ActOnIfStmt(SourceLocation IfLoc,
Diags.Report(IfLoc, diag::warn_consteval_if_always_true) << Immediate;
}
+ // OpenACC3.3 2.14.4:
+ // The update directive is executable. It must not appear in place of the
+ // statement following an 'if', 'while', 'do', 'switch', or 'label' in C or
+ // C++.
+ if (isa<OpenACCUpdateConstruct>(thenStmt)) {
+ Diag(thenStmt->getBeginLoc(), diag::err_acc_update_as_body) << /*if*/ 0;
+ thenStmt = new (Context) NullStmt(thenStmt->getBeginLoc());
+ }
+
return BuildIfStmt(IfLoc, StatementKind, LParenLoc, InitStmt, Cond, RParenLoc,
thenStmt, ElseLoc, elseStmt);
}
@@ -1297,6 +1315,16 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
getCurFunction()->SwitchStack.pop_back();
if (!BodyStmt) return StmtError();
+
+ // OpenACC3.3 2.14.4:
+ // The update directive is executable. It must not appear in place of the
+ // statement following an 'if', 'while', 'do', 'switch', or 'label' in C or
+ // C++.
+ if (isa<OpenACCUpdateConstruct>(BodyStmt)) {
+ Diag(BodyStmt->getBeginLoc(), diag::err_acc_update_as_body) << /*switch*/ 3;
+ BodyStmt = new (Context) NullStmt(BodyStmt->getBeginLoc());
+ }
+
SS->setBody(BodyStmt, SwitchLoc);
Expr *CondExpr = SS->getCond();
@@ -1774,6 +1802,15 @@ StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc,
!Diags.isIgnored(diag::warn_comma_operator, CondVal.second->getExprLoc()))
CommaVisitor(*this).Visit(CondVal.second);
+ // OpenACC3.3 2.14.4:
+ // The update directive is executable. It must not appear in place of the
+ // statement following an 'if', 'while', 'do', 'switch', or 'label' in C or
+ // C++.
+ if (isa<OpenACCUpdateConstruct>(Body)) {
+ Diag(Body->getBeginLoc(), diag::err_acc_update_as_body) << /*while*/ 1;
+ Body = new (Context) NullStmt(Body->getBeginLoc());
+ }
+
if (isa<NullStmt>(Body))
getCurCompoundScope().setHasEmptyLoopBodies();
@@ -1803,6 +1840,15 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
!Diags.isIgnored(diag::warn_comma_operator, Cond->getExprLoc()))
CommaVisitor(*this).Visit(Cond);
+ // OpenACC3.3 2.14.4:
+ // The update directive is executable. It must not appear in place of the
+ // statement following an 'if', 'while', 'do', 'switch', or 'label' in C or
+ // C++.
+ if (isa<OpenACCUpdateConstruct>(Body)) {
+ Diag(Body->getBeginLoc(), diag::err_acc_update_as_body) << /*do*/ 2;
+ Body = new (Context) NullStmt(Body->getBeginLoc());
+ }
+
return new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);
}