[clang] [OpenACC] Implement compound construct parsing (PR #72692)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 07:32:20 PST 2023


================
@@ -45,11 +47,36 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
   P.ConsumeToken();
   std::string FirstTokSpelling = P.getPreprocessor().getSpelling(FirstTok);
 
-  OpenACCDirectiveKind DirKind = GetOpenACCDirectiveKind(FirstTokSpelling);
+  OpenACCDirectiveKind DirKind = getOpenACCDirectiveKind(FirstTokSpelling);
 
   if (DirKind == OpenACCDirectiveKind::Invalid)
     P.Diag(FirstTok, diag::err_acc_invalid_directive) << FirstTokSpelling;
 
+  // Combined Constructs allows parallel loop, serial loop, or kernels loop. Any
+  // other attempt at a combined construct will be diagnosed as an invalid
+  // clause.
+  Token SecondTok = P.getCurToken();
+  if (!SecondTok.isAnnotation() &&
+      P.getPreprocessor().getSpelling(SecondTok) == "loop") {
----------------
alexey-bataev wrote:

The better to add a function isOpenACCDirectiveKind(OpenACCDirectiveKind Kind, StringRef Tok)
```
switch (Kind) {
case OpenACCDirectiveKind::Loop:
  return Tok == "loop";
case OpenACCDirectiveKind::Parallel:
  return Tok == "parallel";
...
}
```

https://github.com/llvm/llvm-project/pull/72692


More information about the cfe-commits mailing list