[flang-commits] [clang] [flang] [llvm] [CLANG][OpenMP] Add support for OpenMP6.0 transparent clause (PR #166810)
Zahira Ammarguellat via flang-commits
flang-commits at lists.llvm.org
Tue Dec 30 11:51:35 PST 2025
================
@@ -17424,6 +17437,52 @@ OMPClause *SemaOpenMP::ActOnOpenMPThreadsetClause(OpenMPThreadsetKind Kind,
OMPThreadsetClause(Kind, KindLoc, StartLoc, LParenLoc, EndLoc);
}
+static OMPClause *CreateTransparentClause(Sema &SemaRef, ASTContext &Ctx,
+ Expr *ImpexTypeArg,
+ SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ ExprResult ER = SemaRef.DefaultLvalueConversion(ImpexTypeArg);
+ if (ER.isInvalid())
+ return nullptr;
+
+ return new (Ctx) OMPTransparentClause(ER.get(), StartLoc, LParenLoc, EndLoc);
+}
+
+OMPClause *SemaOpenMP::ActOnOpenMPTransparentClause(Expr *ImpexTypeArg,
+ SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc) {
+ QualType Ty = ImpexTypeArg->getType();
+
+ if (const auto *TT = Ty->getAs<TypedefType>()) {
+ const TypedefNameDecl *TypedefDecl = TT->getDecl();
+ llvm::StringRef TypedefName = TypedefDecl->getName();
+ IdentifierInfo &II = SemaRef.PP.getIdentifierTable().get(TypedefName);
+ ParsedType ImpexTy =
+ SemaRef.getTypeName(II, StartLoc, SemaRef.getCurScope());
+ if (!ImpexTy.getAsOpaquePtr() || ImpexTy.get().isNull()) {
+ SemaRef.Diag(StartLoc, diag::err_omp_implied_type_not_found)
+ << TypedefName;
+ return nullptr;
+ }
+ return CreateTransparentClause(SemaRef, getASTContext(), ImpexTypeArg,
+ StartLoc, LParenLoc, EndLoc);
+ }
+
+ if (Ty->isEnumeralType())
----------------
zahiraam wrote:
Case A would produce this error:
error: 'expected-error' diagnostics seen but not expected:
File D:\iusers\zahiraam\my-llvm\llvm-project\clang\test\OpenMP\a.cpp Line 8: expression is not an integral constant expression
error: 'expected-note' diagnostics seen but not expected:
File D:\iusers\zahiraam\my-llvm\llvm-project\clang\test\OpenMP\a.cpp Line 8: read of non-const variable 'a' is not allowed in a constant expression
File D:\iusers\zahiraam\my-llvm\llvm-project\clang\test\OpenMP\a.cpp Line 7: declared here
4 errors generated.
and case B is production this error:
error: 'expected-error' diagnostics seen but not expected:
File D:\iusers\zahiraam\my-llvm\llvm-project\clang\test\OpenMP\a.cpp Line 8: invalid value for transparent clause, expected one of: omp_not_impex, omp_import, omp_export, omp_impex
2 errors generated.
https://github.com/llvm/llvm-project/pull/166810
More information about the flang-commits
mailing list