@@ -11078,26 +11078,27 @@ StmtResult SemaOpenMP::ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses,
1107811078 return StmtError();
1107911079 }
1108011080
11081- const OMPSeverityClause *SeverityC =
11082- OMPExecutableDirective::getSingleClause<OMPSeverityClause>(Clauses);
11083- const OMPMessageClause *MessageC =
11084- OMPExecutableDirective::getSingleClause<OMPMessageClause>(Clauses);
11085-
1108611081 if (!AtC || AtC->getAtKind() == OMPC_AT_compilation) {
11087- StringLiteral *SL = MessageC ? MessageC->getAsStringLiteral() : nullptr;
11082+ const OMPSeverityClause *SeverityC =
11083+ OMPExecutableDirective::getSingleClause<OMPSeverityClause>(Clauses);
11084+ const OMPMessageClause *MessageC =
11085+ OMPExecutableDirective::getSingleClause<OMPMessageClause>(Clauses);
11086+ std::optional<std::string> SL =
11087+ MessageC ? MessageC->tryEvaluateString(getASTContext()) : std::nullopt;
11088+
1108811089 if (MessageC && !SL)
1108911090 Diag(MessageC->getMessageString()->getBeginLoc(),
1109011091 diag::warn_clause_expected_string_literal)
1109111092 << getOpenMPClauseNameForDiag(OMPC_message);
1109211093 if (SeverityC && SeverityC->getSeverityKind() == OMPC_SEVERITY_warning)
1109311094 Diag(SeverityC->getSeverityKindKwLoc(), diag::warn_diagnose_if_succeeded)
11094- << (SL ? SL->getString() : "WARNING");
11095+ << SL.value_or( "WARNING");
1109511096 else
11096- Diag(StartLoc, diag::err_diagnose_if_succeeded)
11097- << (SL ? SL->getString() : "ERROR");
11097+ Diag(StartLoc, diag::err_diagnose_if_succeeded) << SL.value_or("ERROR");
1109811098 if (!SeverityC || SeverityC->getSeverityKind() != OMPC_SEVERITY_warning)
1109911099 return StmtError();
1110011100 }
11101+
1110111102 return OMPErrorDirective::Create(getASTContext(), StartLoc, EndLoc, Clauses);
1110211103}
1110311104
@@ -16457,20 +16458,12 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
1645716458 return nullptr;
1645816459 }
1645916460
16460- // If the string is a string literal, save it in case it is later needed
16461- // during compile time. Also consider a const char pointer to a string
16462- // literal. This is necessary for template instantiations where the string
16463- // literal is not passed directly and we only get a const char pointer to it.
16464- StringLiteral *SL = dyn_cast<StringLiteral>(
16465- isa<ImplicitCastExpr>(ME) ? cast<ImplicitCastExpr>(ME)->getSubExpr()
16466- : ME);
16467-
1646816461 // Convert array type to pointer type if needed.
1646916462 if (Type->isArrayType())
1647016463 ME = SemaRef.DefaultFunctionArrayConversion(ME).get();
1647116464
1647216465 return new (getASTContext())
16473- OMPMessageClause(ME, StartLoc, LParenLoc, EndLoc, SL );
16466+ OMPMessageClause(ME, StartLoc, LParenLoc, EndLoc);
1647416467}
1647516468
1647616469OMPClause *SemaOpenMP::ActOnOpenMPOrderClause(
0 commit comments