[clang] [OpenACC][Sema] Implement warning for non-effective 'private' (PR #149004)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 16 06:12:28 PDT 2025
================
@@ -624,6 +624,66 @@ void SemaOpenACC::CheckDeclReference(SourceLocation Loc, Expr *E, Decl *D) {
// loop (or we aren't in a loop!) so skip the diagnostic.
}
+namespace {
+// Check whether the type of the thing we are referencing is OK for things like
+// private, firstprivate, and reduction, which require certain operators to be
+// available.
+ExprResult CheckVarType(SemaOpenACC &S, OpenACCClauseKind CK, Expr *VarExpr,
+ Expr *InnerExpr) {
+ // There is nothing to do here, only these three have these sorts of
+ // restrictions.
+ if (CK != OpenACCClauseKind::Private &&
+ CK != OpenACCClauseKind::FirstPrivate &&
+ CK != OpenACCClauseKind::Reduction)
+ return VarExpr;
+
+ // We can't test this if it isn't here, or if the type isn't clear yet.
+ if (!InnerExpr || InnerExpr->isTypeDependent())
+ return VarExpr;
+
+ const auto *RD = InnerExpr->getType()->getAsCXXRecordDecl();
+
+ // if this isn't a C++ record decl, we can create/copy/destroy this thing at
+ // will without problem, so this is a success.
+ if (!RD)
+ return VarExpr;
+
+ // TODO: OpenACC:
+ // Private must have default ctor + dtor in InnerExpr
+ // FirstPrivate must have copyctor + dtor in InnerExpr
+ // Reduction must have copyctor + dtor + operation in InnerExpr
----------------
erichkeane wrote:
It would still need a 'default' constructor though to start its lifetime, right?
https://github.com/llvm/llvm-project/pull/149004
More information about the cfe-commits
mailing list