Skip to content

[OpenACC] Add 'clause' parsing infrastructure plus a few clauses #75052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2023

Conversation

erichkeane
Copy link
Collaborator

As we've now finished parsing the constructs, we're moving onto implementing 'clause' parsing. While some are complicated and require their own patch, the handful added here are simple to parse (that is,
they are a single identifier).

This patch adds the infrastructure to parse these and a clause-list in its entirety. This adds some complication to how we are diagnosing parsing errors elsewhere, so a few changes were made to better recover from errors.

As we've now finished parsing the constructs, we're moving onto
implementing 'clause' parsing.  While some are complicated and require
their own patch, the handful added here are simple to parse (that is,
    they are a single identifier).

This patch adds the infrastructure to parse these and a clause-list in
its entirety. This adds some complication to how we are diagnosing
parsing errors elsewhere, so a few changes were made to better recover
from errors.
@erichkeane erichkeane added the clang:openacc Clang OpenACC Implementation label Dec 11, 2023
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Dec 11, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 11, 2023

@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)

Changes

As we've now finished parsing the constructs, we're moving onto implementing 'clause' parsing. While some are complicated and require their own patch, the handful added here are simple to parse (that is,
they are a single identifier).

This patch adds the infrastructure to parse these and a clause-list in its entirety. This adds some complication to how we are diagnosing parsing errors elsewhere, so a few changes were made to better recover from errors.


Patch is 28.06 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/75052.diff

9 Files Affected:

  • (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+1-3)
  • (modified) clang/include/clang/Basic/OpenACCKinds.h (+13)
  • (modified) clang/lib/Parse/ParseOpenACC.cpp (+78-8)
  • (modified) clang/test/ParserOpenACC/parse-cache-construct.c (+2-2)
  • (added) clang/test/ParserOpenACC/parse-clauses.c (+64)
  • (modified) clang/test/ParserOpenACC/parse-constructs.c (+32-36)
  • (modified) clang/test/ParserOpenACC/parse-wait-construct.c (+12-12)
  • (modified) clang/test/ParserOpenACC/unimplemented.c (+3-3)
  • (modified) clang/test/ParserOpenACC/unimplemented.cpp (+3-3)
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e4b1069cde1850 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1358,11 +1358,9 @@ def err_acc_unexpected_directive
 def warn_pragma_acc_unimplemented
     : Warning<"OpenACC directives not yet implemented, pragma ignored">,
       InGroup<SourceUsesOpenACC>;
-def warn_pragma_acc_unimplemented_clause_parsing
-    : Warning<"OpenACC clause parsing not yet implemented">,
-      InGroup<SourceUsesOpenACC>;
 def err_acc_invalid_directive
     : Error<"invalid OpenACC directive %select{%1|'%1 %2'}0">;
+def err_acc_invalid_clause : Error<"invalid OpenACC clause %0">;
 def err_acc_missing_directive : Error<"expected OpenACC directive">;
 def err_acc_invalid_open_paren
     : Error<"expected clause-list or newline in OpenACC directive">;
diff --git a/clang/include/clang/Basic/OpenACCKinds.h b/clang/include/clang/Basic/OpenACCKinds.h
index 62c0a4c1a9dea4..e907c192ed6d29 100644
--- a/clang/include/clang/Basic/OpenACCKinds.h
+++ b/clang/include/clang/Basic/OpenACCKinds.h
@@ -69,6 +69,19 @@ enum class OpenACCAtomicKind {
   Capture,
   Invalid,
 };
+
+// Represents the kind of an OpenACC clause.
+enum class OpenACCClauseKind {
+  Finalize,
+  IfPresent,
+  Seq,
+  Independent,
+  Auto,
+  Worker,
+  Vector,
+  NoHost,
+  Invalid,
+};
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_OPENACCKINDS_H
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index f7f096762e91a6..2ad296e23e8f00 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -69,6 +69,29 @@ OpenACCDirectiveKindEx getOpenACCDirectiveKind(Token Tok) {
       .Default(OpenACCDirectiveKindEx::Invalid);
 }
 
+// Translate single-token string representations to the OpenCC Clause Kind.
+OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
+  // auto is a keyword in some language modes, so make sure we parse it
+  // correctly.
+  if (Tok.is(tok::kw_auto))
+    return OpenACCClauseKind::Auto;
+
+  if (!Tok.is(tok::identifier))
+    return OpenACCClauseKind::Invalid;
+
+  return llvm::StringSwitch<OpenACCClauseKind>(
+      Tok.getIdentifierInfo()->getName())
+    .Case("finalize", OpenACCClauseKind::Finalize)
+    .Case("if_present", OpenACCClauseKind::IfPresent)
+    .Case("seq", OpenACCClauseKind::Seq)
+    .Case("independent", OpenACCClauseKind::Independent)
+    .Case("auto", OpenACCClauseKind::Auto)
+    .Case("worker", OpenACCClauseKind::Worker)
+    .Case("vector", OpenACCClauseKind::Vector)
+    .Case("nohost", OpenACCClauseKind::NoHost)
+    .Default(OpenACCClauseKind::Invalid);
+}
+
 // Since 'atomic' is effectively a compound directive, this will decode the
 // second part of the directive.
 OpenACCAtomicKind getOpenACCAtomicKind(Token Tok) {
@@ -164,6 +187,10 @@ ParseOpenACCEnterExitDataDirective(Parser &P, Token FirstTok,
     return OpenACCDirectiveKind::Invalid;
   }
 
+  // Consume the second name anyway, this way we can continue on without making
+  // this oddly look like a clause.
+  P.ConsumeAnyToken();
+
   if (!isOpenACCDirectiveKind(OpenACCDirectiveKind::Data, SecondTok)) {
     if (!SecondTok.is(tok::identifier))
       P.Diag(SecondTok, diag::err_expected) << tok::identifier;
@@ -174,8 +201,6 @@ ParseOpenACCEnterExitDataDirective(Parser &P, Token FirstTok,
     return OpenACCDirectiveKind::Invalid;
   }
 
-  P.ConsumeToken();
-
   return ExtDirKind == OpenACCDirectiveKindEx::Enter
              ? OpenACCDirectiveKind::EnterData
              : OpenACCDirectiveKind::ExitData;
@@ -208,6 +233,10 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
   // introspect on the spelling before then.
   if (FirstTok.isNot(tok::identifier)) {
     P.Diag(FirstTok, diag::err_acc_missing_directive);
+
+    if (!FirstTok.isAnnotation())
+      P.ConsumeAnyToken();
+
     return OpenACCDirectiveKind::Invalid;
   }
 
@@ -262,12 +291,51 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
   return DirKind;
 }
 
+bool ParseOpenACCClause(Parser &P) {
+  if (!P.getCurToken().isOneOf(tok::identifier, tok::kw_auto))
+    return P.Diag(P.getCurToken(), diag::err_expected) << tok::identifier;
+
+  OpenACCClauseKind Kind = getOpenACCClauseKind(P.getCurToken());
+
+  if (Kind == OpenACCClauseKind::Invalid)
+    return P.Diag(P.getCurToken(), diag::err_acc_invalid_clause)
+           << P.getCurToken().getIdentifierInfo();
+
+  // Consume the clause name.
+  P.ConsumeToken();
+
+  // FIXME: For future clauses, we need to handle parens/etc below.
+  return false;
+}
+
+// Skip until we see the end of pragma token, but don't consume it. This is us
+// just giving up on the rest of the pragma so we can continue executing. We
+// have to do this because 'SkipUntil' considers paren balancing, which isn't
+// what we want.
+void SkipUntilEndOfDirective(Parser &P) {
+  while(P.getCurToken().isNot(tok::annot_pragma_openacc_end))
+    P.ConsumeAnyToken();
+}
+
+// OpenACC 3.3, section 1.7:
+// To simplify the specification and convey appropriate constraint information,
+// a pqr-list is a comma-separated list of pdr items. The one exception is a
+// clause-list, which is a list of one or more clauses optionally separated by
+// commas.
 void ParseOpenACCClauseList(Parser &P) {
-  // FIXME: In the future, we'll start parsing the clauses here, but for now we
-  // haven't implemented that, so just emit the unimplemented diagnostic and
-  // fail reasonably.
-  if (P.getCurToken().isNot(tok::annot_pragma_openacc_end))
-    P.Diag(P.getCurToken(), diag::warn_pragma_acc_unimplemented_clause_parsing);
+  bool FirstClause = true;
+  while (P.getCurToken().isNot(tok::annot_pragma_openacc_end)) {
+    // Comma is optional in a clause-list.
+    if (!FirstClause && P.getCurToken().is(tok::comma))
+      P.ConsumeToken();
+    FirstClause = false;
+
+    // Recovering from a bad clause is really difficult, so we just give up on error.
+    if (ParseOpenACCClause(P)) {
+      SkipUntilEndOfDirective(P);
+      return;
+    }
+  }
 }
 
 } // namespace
@@ -499,7 +567,9 @@ void Parser::ParseOpenACCDirective() {
   ParseOpenACCClauseList(*this);
 
   Diag(getCurToken(), diag::warn_pragma_acc_unimplemented);
-  SkipUntil(tok::annot_pragma_openacc_end);
+  assert(Tok.is(tok::annot_pragma_openacc_end) &&
+         "Didn't parse all OpenACC Clauses");
+  ConsumeAnnotationToken();
 }
 
 // Parse OpenACC directive on a declaration.
diff --git a/clang/test/ParserOpenACC/parse-cache-construct.c b/clang/test/ParserOpenACC/parse-cache-construct.c
index 10976627ca95ce..560f45423bc2b9 100644
--- a/clang/test/ParserOpenACC/parse-cache-construct.c
+++ b/clang/test/ParserOpenACC/parse-cache-construct.c
@@ -14,7 +14,7 @@ void func() {
 
   for (int i = 0; i < 10; ++i) {
     // expected-error@+3{{expected '('}}
-    // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+    // expected-error@+2{{invalid OpenACC clause 'clause'}}
     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
     #pragma acc cache clause list
   }
@@ -25,7 +25,7 @@ void func() {
   }
 
   for (int i = 0; i < 10; ++i) {
-    // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+    // expected-error@+2{{invalid OpenACC clause 'clause'}}
     // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
     #pragma acc cache() clause-list
   }
diff --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c
new file mode 100644
index 00000000000000..1e05d82906aedc
--- /dev/null
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 %s -verify -fopenacc -std=c99
+// RUNX: %clang_cc1 %s -verify -fopenacc
+// RUNX: %clang_cc1 %s -verify -fopenacc -x c++
+
+void func() {
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc enter data finalize
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc enter data finalize finalize
+
+  // expected-error@+2{{invalid OpenACC clause 'invalid'}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc enter data finalize invalid
+
+  // expected-error@+2{{invalid OpenACC clause 'invalid'}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc enter data finalize invalid invalid finalize
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc enter data seq finalize
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc host_data if_present
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc host_data if_present, if_present
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc loop seq independent auto
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc loop seq, independent auto
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc loop seq independent, auto
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc kernels loop seq independent auto
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc serial loop seq, independent auto
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel loop seq independent, auto
+
+
+  // expected-error@+2{{expected identifier}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc loop , seq
+
+  // expected-error@+2{{expected identifier}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc loop seq,
+
+}
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc routine worker, vector, seq, nohost
+void bar();
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc routine(bar) worker, vector, seq, nohost
diff --git a/clang/test/ParserOpenACC/parse-constructs.c b/clang/test/ParserOpenACC/parse-constructs.c
index 83d9bd6070d41d..0bb33269bbe98f 100644
--- a/clang/test/ParserOpenACC/parse-constructs.c
+++ b/clang/test/ParserOpenACC/parse-constructs.c
@@ -7,14 +7,13 @@ void func() {
 #pragma acc
   for(;;){}
 
-  // expected-error@+4{{expected OpenACC directive}}
-  // expected-error@+3{{expected clause-list or newline in OpenACC directive}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+3{{expected OpenACC directive}}
+  // expected-error@+2{{invalid OpenACC clause 'whatever'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc(whatever) routine
 
   // expected-error@+3{{expected OpenACC directive}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'routine'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc) routine
 
@@ -23,12 +22,12 @@ void func() {
 #pragma acc invalid
   for(;;){}
 
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel clause list
   for(;;){}
   // expected-error@+3{{expected clause-list or newline in OpenACC directive}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel() clause list
   for(;;){}
@@ -38,33 +37,31 @@ void func() {
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel( clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc serial clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc kernels clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc data clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc enter data clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc exit data clause list
   for(;;){}
-  // expected-error@+3{{invalid OpenACC directive 'enter invalid'}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC directive 'enter invalid'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc enter invalid
   for(;;){}
-  // expected-error@+3{{invalid OpenACC directive 'exit invalid'}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC directive 'exit invalid'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc exit invalid
   for(;;){}
@@ -72,24 +69,23 @@ void func() {
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc enter
   for(;;){}
-  // expected-error@+3{{expected identifier}}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{expected identifier}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc exit }
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc host_data clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc loop clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'invalid'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel invalid clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel loop clause list
   for(;;){}
@@ -97,14 +93,14 @@ void func() {
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc parallel loop
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc serial loop clause list
   for(;;){}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc serial loop
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc kernels loop clause list
   for(;;){}
@@ -116,48 +112,48 @@ void func() {
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic
   i = j;
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'garbage'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic garbage
   i = j;
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'garbage'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic garbage clause list
   i = j;
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic read
   i = j;
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic write clause list
   i = i + j;
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic update clause list
   i++;
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc atomic capture clause list
   i = j++;
 
 
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc declare clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc init clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc shutdown clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc set clause list
   for(;;){}
-  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-error@+2{{invalid OpenACC clause 'clause'}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc update clause list
   for(;;){}
@@ -166,7 +162,7 @@ void func() {
 // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc routine
 void routine_func();
-// expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+// expected-error@+2{{invalid OpenACC clause 'clause'}}
 // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc routine clause list
 void routine_func();
@@ -175,13 +171,13 @@ void routine_func();
 // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc routine (func_name)
 // expected-error@+3{{use of undeclared identifier 'func_name'}}
-// expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+// expected-error@+2{{invalid OpenACC clause 'clause'}}
 // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc routine (func_name) clause list
 
 // expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
 #pragma acc routine (routine_func)
-// expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+// expected-error@+2{{inva...
[truncated]

Copy link

github-actions bot commented Dec 11, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Comment on lines 83 to 93
Tok.getIdentifierInfo()->getName())
.Case("finalize", OpenACCClauseKind::Finalize)
.Case("if_present", OpenACCClauseKind::IfPresent)
.Case("seq", OpenACCClauseKind::Seq)
.Case("independent", OpenACCClauseKind::Independent)
.Case("auto", OpenACCClauseKind::Auto)
.Case("worker", OpenACCClauseKind::Worker)
.Case("vector", OpenACCClauseKind::Vector)
.Case("nohost", OpenACCClauseKind::NoHost)
.Default(OpenACCClauseKind::Invalid);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sort alphabetically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Done.

Comment on lines 237 to 238
if (!FirstTok.isAnnotation())
P.ConsumeAnyToken();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that's for the end of pragma annotation. Shouldn't the test be more specific?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -69,6 +69,19 @@ enum class OpenACCAtomicKind {
Capture,
Invalid,
};

// Represents the kind of an OpenACC clause.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use '///' kind of comment here


// Represents the kind of an OpenACC clause.
enum class OpenACCClauseKind {
Finalize,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the comments with the description of each clause kind?

@alexey-bataev
Copy link
Member

LG with nits

@erichkeane erichkeane merged commit fdee0a3 into llvm:main Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openacc Clang OpenACC Implementation clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants