[clang] [OpenACC] Implement enter data/exit data construct parsing (PR #72916)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 06:40:20 PST 2023


================
@@ -91,10 +140,19 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
   P.ConsumeToken();
   std::string FirstTokSpelling = P.getPreprocessor().getSpelling(FirstTok);
 
-  OpenACCDirectiveKind DirKind = getOpenACCDirectiveKind(FirstTokSpelling);
+  OpenACCDirectiveKindEx ExDirKind = getOpenACCDirectiveKind(FirstTokSpelling);
+
+  switch (ExDirKind) {
+  case OpenACCDirectiveKindEx::Invalid:
+    P.Diag(FirstTok, diag::err_acc_invalid_directive) << 0 << FirstTokSpelling;
+    return OpenACCDirectiveKind::Invalid;
+  case OpenACCDirectiveKindEx::Enter:
+  case OpenACCDirectiveKindEx::Exit:
+    return ParseOpenACCEnterExitDataDirective(P, FirstTok, FirstTokSpelling,
+                                              ExDirKind);
+  }
----------------
erichkeane wrote:

The switch doesn't actually cover all values, the intent is that `OpenACCDirectiveKindEx` can contain an `OpenACCDirectiveKind`, OR one of the extended values.

So `ExDirKind` can be a bunch of other values, so if the kind is any one of the others (like parallel), it will go through this switch and fall to the below ones.

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


More information about the cfe-commits mailing list