@@ -11097,26 +11097,27 @@ StmtResult SemaOpenMP::ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses,
1109711097 return StmtError();
1109811098 }
1109911099
11100- const OMPSeverityClause *SeverityC =
11101- OMPExecutableDirective::getSingleClause<OMPSeverityClause>(Clauses);
11102- const OMPMessageClause *MessageC =
11103- OMPExecutableDirective::getSingleClause<OMPMessageClause>(Clauses);
11104-
1110511100 if (!AtC || AtC->getAtKind() == OMPC_AT_compilation) {
11106- StringLiteral *SL = MessageC ? MessageC->getAsStringLiteral() : nullptr;
11101+ const OMPSeverityClause *SeverityC =
11102+ OMPExecutableDirective::getSingleClause<OMPSeverityClause>(Clauses);
11103+ const OMPMessageClause *MessageC =
11104+ OMPExecutableDirective::getSingleClause<OMPMessageClause>(Clauses);
11105+ std::optional<std::string> SL =
11106+ MessageC ? MessageC->tryEvaluateString(getASTContext()) : std::nullopt;
11107+
1110711108 if (MessageC && !SL)
1110811109 Diag(MessageC->getMessageString()->getBeginLoc(),
1110911110 diag::warn_clause_expected_string_literal)
1111011111 << getOpenMPClauseNameForDiag(OMPC_message);
1111111112 if (SeverityC && SeverityC->getSeverityKind() == OMPC_SEVERITY_warning)
1111211113 Diag(SeverityC->getSeverityKindKwLoc(), diag::warn_diagnose_if_succeeded)
11113- << (SL ? SL->getString() : "WARNING");
11114+ << SL.value_or( "WARNING");
1111411115 else
11115- Diag(StartLoc, diag::err_diagnose_if_succeeded)
11116- << (SL ? SL->getString() : "ERROR");
11116+ Diag(StartLoc, diag::err_diagnose_if_succeeded) << SL.value_or("ERROR");
1111711117 if (!SeverityC || SeverityC->getSeverityKind() != OMPC_SEVERITY_warning)
1111811118 return StmtError();
1111911119 }
11120+
1112011121 return OMPErrorDirective::Create(getASTContext(), StartLoc, EndLoc, Clauses);
1112111122}
1112211123
@@ -16476,20 +16477,12 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
1647616477 return nullptr;
1647716478 }
1647816479
16479- // If the string is a string literal, save it in case it is later needed
16480- // during compile time. Also consider a const char pointer to a string
16481- // literal. This is necessary for template instantiations where the string
16482- // literal is not passed directly and we only get a const char pointer to it.
16483- StringLiteral *SL = dyn_cast<StringLiteral>(
16484- isa<ImplicitCastExpr>(ME) ? cast<ImplicitCastExpr>(ME)->getSubExpr()
16485- : ME);
16486-
1648716480 // Convert array type to pointer type if needed.
1648816481 if (Type->isArrayType())
1648916482 ME = SemaRef.DefaultFunctionArrayConversion(ME).get();
1649016483
1649116484 return new (getASTContext())
16492- OMPMessageClause(ME, StartLoc, LParenLoc, EndLoc, SL );
16485+ OMPMessageClause(ME, StartLoc, LParenLoc, EndLoc);
1649316486}
1649416487
1649516488OMPClause *SemaOpenMP::ActOnOpenMPOrderClause(
0 commit comments