[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)

Krzysztof Parzyszek via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 24 10:16:17 PDT 2025


================
@@ -2759,6 +2759,19 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
       OpenMPClauseKind CKind = Tok.isAnnotation()
                                    ? OMPC_unknown
                                    : getOpenMPClauseKind(PP.getSpelling(Tok));
+      // Check if the clause is unrecognized.
+      if (getLangOpts().OpenMP < 52 &&
+          (CKind == OMPC_unknown || CKind == OMPC_otherwise)) {
+        Diag(Tok, diag::err_omp_unknown_clause)
+            << PP.getSpelling(Tok) << "metadirective";
+      }
+      if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) {
+        Diag(Tok, diag::err_omp_unknown_clause)
+            << PP.getSpelling(Tok) << "metadirective";
+      }
----------------
kparzysz wrote:

Please treat OMPC_unknown and OMPC_otherwise separately: in the former case the message should be something like "expected an OpenMP clause"  (see `err_omp_unknown_directive` for reference).  The latter case should use `err_omp_unexpected_clause`.

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


More information about the cfe-commits mailing list