diff options
author | Urvi Rav <94829943+ravurvi20@users.noreply.github.com> | 2025-02-21 15:41:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-21 15:41:04 +0530 |
commit | 73ad78cc57e10b932bddaa9034237f59bb566e6b (patch) | |
tree | b5cc777668e2d2255b1950dc68b707c41523f8bb /clang/lib/Parse/ParseOpenMP.cpp | |
parent | 6d5ba79c6604a6f66400d573b8aabc34cb75d0b5 (diff) | |
download | llvm-73ad78cc57e10b932bddaa9034237f59bb566e6b.zip llvm-73ad78cc57e10b932bddaa9034237f59bb566e6b.tar.gz llvm-73ad78cc57e10b932bddaa9034237f59bb566e6b.tar.bz2 |
default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (#125648)
This PR replaces the `default` clause with the `otherwise` clause for
the `metadirective` in OpenMP. The `otherwise` clause serves as a
fallback condition when no directive from the `when` clauses is
selected. In the `when` clause, context selectors define traits
evaluated to determine the directive to be applied.
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 42e6aac..3b86847 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -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"; + } + if (CKind == OMPC_default && getLangOpts().OpenMP >= 52) { + Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2785,6 +2798,13 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { + // Check for 'otherwise' keyword. + if (Tok.is(tok::identifier) && + Tok.getIdentifierInfo()->getName() == "otherwise") { + ConsumeToken(); // Consume 'otherwise' + } + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { |