================ @@ -0,0 +1,132 @@ +//===--- SemaOpenACC.cpp - Semantic Analysis for OpenACC constructs -------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// \file +/// This file implements semantic analysis for OpenACC constructs and +/// clauses. +/// +//===----------------------------------------------------------------------===// + +#include "clang/Basic/DiagnosticSema.h" +#include "clang/Basic/OpenACCKinds.h" +#include "clang/Sema/Sema.h" + +using namespace clang; + +namespace { +bool DiagnoseConstructAppertainment(Sema &S, OpenACCDirectiveKind K, + SourceLocation StartLoc, bool IsStmt) { + switch (K) { + default: + case OpenACCDirectiveKind::Invalid: + // Nothing to do here, both invalid and unimplemented don't really need to + // do anything. + break; + case OpenACCDirectiveKind::Parallel: + if (!IsStmt) + return S.Diag(StartLoc, diag::err_acc_construct_appertainment) << K; + break; + } + return false; +} +} // namespace + +bool Sema::ActOnOpenACCClause(OpenACCClauseKind ClauseKind, + SourceLocation StartLoc) { + // TODO OpenACC: this will probably want to take the Directive Kind as well to + // help with legalization. + if (ClauseKind == OpenACCClauseKind::Invalid) + return false; + // For now just diagnose that it is unsupported and leave the parsing to do + // whatever it can do. This function will eventually need to start returning + // some sort of Clause AST type, but for now just return true/false based on + // success. + return Diag(StartLoc, diag::warn_acc_clause_unimplemented) << ClauseKind; +} + +void Sema::ActOnOpenACCConstruct(OpenACCDirectiveKind K, + SourceLocation StartLoc) { + switch (K) { + case OpenACCDirectiveKind::Invalid: + // Nothing to do here, an invalid kind has nothing we can check here. We + // want to continue parsing clauses as far as we can, so we will just + // ensure that we can still work and don't check any construct-specific + // rules anywhere. + break; + case OpenACCDirectiveKind::Parallel: + // Nothing to do here, there is no real legalization that needs to happen + // here as these constructs do not take any arguments. + break; + default: + Diag(StartLoc, diag::warn_acc_construct_unimplemented) << K; + break; + } +} + +void Sema::ActOnStartOpenACCDeclDirective(OpenACCDirectiveKind K, + SourceLocation StartLoc, + SourceLocation EndLoc) { + // TODO OpenACC: This should likely return something with the modified + // declaration. At the moment, only handle appertainment. + DiagnoseConstructAppertainment(*this, K, StartLoc, /*IsStmt=*/false); +} + +void Sema::ActOnEndOpenACCDeclDirective() { + // TODO OpenACC: Should diagnose anything having to do with the associated + // statement, or any clause diagnostics that can only be done at the 'end' of + // the directive. We should also close any 'block' marking now that the decl + // parsing is complete. +} ---------------- erichkeane wrote:
Ah, I think I see what you mean. I'll submit a patch that adds just the sema functions and calls them properly, then can add the "change the warnings" as a separate patch, then the "implement parallel" as a patch. https://github.com/llvm/llvm-project/pull/81659 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits