aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2023-09-27 18:41:11 +0200
committerSam McCall <sam.mccall@gmail.com>2023-09-27 18:58:01 +0200
commit880fa7faa97bad63e403c924263b01fb81783227 (patch)
tree70461a46a2b16bb67041cb5509029672dfc2317a /clang/lib/Parse/ParseStmt.cpp
parent6a34b12727280cfdd75be66c34a1235136c62e43 (diff)
downloadllvm-880fa7faa97bad63e403c924263b01fb81783227.zip
llvm-880fa7faa97bad63e403c924263b01fb81783227.tar.gz
llvm-880fa7faa97bad63e403c924263b01fb81783227.tar.bz2
Revert "[clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated"
This reverts commit 491b2810fb7fe5f080fa9c4f5945ed0a6909dc92. This change broke valid code and generated incorrect diagnostics, see https://reviews.llvm.org/D155064
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 75c689f2..2531147 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1293,17 +1293,18 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
/// errors in the condition.
/// Additionally, it will assign the location of the outer-most '(' and ')',
/// to LParenLoc and RParenLoc, respectively.
-bool Parser::ParseParenExprOrCondition(
- StmtResult *InitStmt, Sema::ConditionResult &Cond, SourceLocation Loc,
- Sema::ConditionKind CK, SourceLocation &LParenLoc,
- SourceLocation &RParenLoc, SourceLocation ConstexprLoc) {
+bool Parser::ParseParenExprOrCondition(StmtResult *InitStmt,
+ Sema::ConditionResult &Cond,
+ SourceLocation Loc,
+ Sema::ConditionKind CK,
+ SourceLocation &LParenLoc,
+ SourceLocation &RParenLoc) {
BalancedDelimiterTracker T(*this, tok::l_paren);
T.consumeOpen();
SourceLocation Start = Tok.getLocation();
if (getLangOpts().CPlusPlus) {
- Cond = ParseCXXCondition(InitStmt, Loc, CK, false, nullptr, false,
- ConstexprLoc);
+ Cond = ParseCXXCondition(InitStmt, Loc, CK, false);
} else {
ExprResult CondExpr = ParseExpression();
@@ -1463,13 +1464,12 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
bool IsConsteval = false;
SourceLocation NotLocation;
SourceLocation ConstevalLoc;
- SourceLocation ConstexprLoc;
if (Tok.is(tok::kw_constexpr)) {
Diag(Tok, getLangOpts().CPlusPlus17 ? diag::warn_cxx14_compat_constexpr_if
: diag::ext_constexpr_if);
IsConstexpr = true;
- ConstexprLoc = ConsumeToken();
+ ConsumeToken();
} else {
if (Tok.is(tok::exclaim)) {
NotLocation = ConsumeToken();
@@ -1515,7 +1515,7 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
if (ParseParenExprOrCondition(&InitStmt, Cond, IfLoc,
IsConstexpr ? Sema::ConditionKind::ConstexprIf
: Sema::ConditionKind::Boolean,
- LParen, RParen, ConstexprLoc))
+ LParen, RParen))
return StmtError();
if (IsConstexpr)
@@ -1558,16 +1558,11 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
if (NotLocation.isInvalid() && IsConsteval) {
Context = Sema::ExpressionEvaluationContext::ImmediateFunctionContext;
ShouldEnter = true;
- } else if (NotLocation.isValid() && IsConsteval) {
- Context = Actions.ExprEvalContexts.back().Context;
- ShouldEnter = true;
}
EnterExpressionEvaluationContext PotentiallyDiscarded(
Actions, Context, nullptr,
Sema::ExpressionEvaluationContextRecord::EK_Other, ShouldEnter);
- if (NotLocation.isValid() && IsConsteval)
- Actions.ExprEvalContexts.back().IsRuntimeEvaluated = true;
ThenStmt = ParseStatement(&InnerStatementTrailingElseLoc);
}
@@ -1608,16 +1603,11 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
if (NotLocation.isValid() && IsConsteval) {
Context = Sema::ExpressionEvaluationContext::ImmediateFunctionContext;
ShouldEnter = true;
- } else if (NotLocation.isInvalid() && IsConsteval) {
- Context = Actions.ExprEvalContexts.back().Context;
- ShouldEnter = true;
}
EnterExpressionEvaluationContext PotentiallyDiscarded(
Actions, Context, nullptr,
Sema::ExpressionEvaluationContextRecord::EK_Other, ShouldEnter);
- if (NotLocation.isInvalid() && IsConsteval)
- Actions.ExprEvalContexts.back().IsRuntimeEvaluated = true;
ElseStmt = ParseStatement();
if (ElseStmt.isUsable())