[clang] [OpenACC] Implement Atomic construct variants (PR #73015)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 21 10:04:12 PST 2023
================
@@ -143,26 +139,25 @@ ParseOpenACCEnterExitDataDirective(Parser &P, Token FirstTok,
: OpenACCDirectiveKind::ExitData;
}
-OpenACCDirectiveKind ParseOpenACCAtomicDirective(Parser &P) {
+OpenACCAtomicKind ParseOpenACCAtomicKind(Parser &P) {
Token AtomicClauseToken = P.getCurToken();
- if (AtomicClauseToken.isAnnotation()) {
- P.Diag(AtomicClauseToken, diag::err_acc_invalid_atomic_clause) << 0;
- return OpenACCDirectiveKind::Invalid;
- }
+ // #pragma acc atomic is equivilent to update:
+ if (AtomicClauseToken.isAnnotation())
+ return OpenACCAtomicKind::Update;
std::string AtomicClauseSpelling =
P.getPreprocessor().getSpelling(AtomicClauseToken);
+ OpenACCAtomicKind AtomicKind = getOpenACCAtomicKind(AtomicClauseSpelling);
- OpenACCDirectiveKind DirKind =
- getOpenACCAtomicDirectiveKind(AtomicClauseSpelling);
-
- if (DirKind == OpenACCDirectiveKind::Invalid)
- P.Diag(AtomicClauseToken, diag::err_acc_invalid_atomic_clause)
- << 1 << AtomicClauseSpelling;
+ // If we don't know what this is, treat it as 'nothing', and treat the rest of
+ // this as a clause list, which, despite being invalid, is likely what the
+ // user was trying to do.
+ if (AtomicKind == OpenACCAtomicKind::Invalid)
+ return OpenACCAtomicKind::Update;
----------------
alexey-bataev wrote:
Shall you consume token here before return?
https://github.com/llvm/llvm-project/pull/73015
More information about the cfe-commits
mailing list