[clang] 003eb5e - [OpenACC] Implement 'finalize' clause sema

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 13 10:41:12 PST 2024


Author: erichkeane
Date: 2024-12-13T10:41:02-08:00
New Revision: 003eb5e80d8c970c2ae7fcbaaebd52b32a61648d

URL: https://github.com/llvm/llvm-project/commit/003eb5e80d8c970c2ae7fcbaaebd52b32a61648d
DIFF: https://github.com/llvm/llvm-project/commit/003eb5e80d8c970c2ae7fcbaaebd52b32a61648d.diff

LOG: [OpenACC] Implement 'finalize' clause sema

This is a very simple clause as far as sema is concerned.  It is only
valid on 'exit data', and doesn't have any rules involving it, so it is
simply applied and passed onto the MLIR.

Added: 
    clang/test/SemaOpenACC/data-construct-finalize-ast.cpp
    clang/test/SemaOpenACC/data-construct-finalize-clause.c

Modified: 
    clang/include/clang/AST/OpenACCClause.h
    clang/include/clang/Basic/OpenACCClauses.def
    clang/lib/AST/OpenACCClause.cpp
    clang/lib/AST/StmtProfile.cpp
    clang/lib/AST/TextNodeDumper.cpp
    clang/lib/Sema/SemaOpenACC.cpp
    clang/lib/Sema/TreeTransform.h
    clang/lib/Serialization/ASTReader.cpp
    clang/lib/Serialization/ASTWriter.cpp
    clang/test/AST/ast-print-openacc-data-construct.cpp
    clang/test/ParserOpenACC/parse-clauses.c
    clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c
    clang/test/SemaOpenACC/combined-construct-device_type-clause.c
    clang/test/SemaOpenACC/compute-construct-device_type-clause.c
    clang/test/SemaOpenACC/data-construct.cpp
    clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c
    clang/test/SemaOpenACC/loop-construct-device_type-clause.c
    clang/tools/libclang/CIndex.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index 2588c3f645c02b..767ad1270ffbd9 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -38,7 +38,7 @@ class OpenACCClause {
   SourceLocation getBeginLoc() const { return Location.getBegin(); }
   SourceLocation getEndLoc() const { return Location.getEnd(); }
 
-  static bool classof(const OpenACCClause *) { return false; }
+  static bool classof(const OpenACCClause *) { return true; }
 
   using child_iterator = StmtIterator;
   using const_child_iterator = ConstStmtIterator;
@@ -76,6 +76,28 @@ class OpenACCAutoClause : public OpenACCClause {
   }
 };
 
+// Represents the 'finalize' clause.
+class OpenACCFinalizeClause : public OpenACCClause {
+protected:
+  OpenACCFinalizeClause(SourceLocation BeginLoc, SourceLocation EndLoc)
+      : OpenACCClause(OpenACCClauseKind::Finalize, BeginLoc, EndLoc) {}
+
+public:
+  static bool classof(const OpenACCClause *C) {
+    return C->getClauseKind() == OpenACCClauseKind::Finalize;
+  }
+
+  static OpenACCFinalizeClause *
+  Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
+
+  child_range children() {
+    return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range children() const {
+    return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+};
+
 // Represents the 'independent' clause.
 class OpenACCIndependentClause : public OpenACCClause {
 protected:

diff  --git a/clang/include/clang/Basic/OpenACCClauses.def b/clang/include/clang/Basic/OpenACCClauses.def
index c65ebed751cf14..c3d536c33bc5b1 100644
--- a/clang/include/clang/Basic/OpenACCClauses.def
+++ b/clang/include/clang/Basic/OpenACCClauses.def
@@ -41,6 +41,7 @@ VISIT_CLAUSE(Default)
 VISIT_CLAUSE(DevicePtr)
 VISIT_CLAUSE(DeviceType)
 CLAUSE_ALIAS(DType, DeviceType, false)
+VISIT_CLAUSE(Finalize)
 VISIT_CLAUSE(FirstPrivate)
 VISIT_CLAUSE(Gang)
 VISIT_CLAUSE(If)

diff  --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp
index 1299e4f807ceb1..770f95f60b7b79 100644
--- a/clang/lib/AST/OpenACCClause.cpp
+++ b/clang/lib/AST/OpenACCClause.cpp
@@ -444,6 +444,14 @@ OpenACCVectorClause *OpenACCVectorClause::Create(const ASTContext &C,
   return new (Mem) OpenACCVectorClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
 }
 
+OpenACCFinalizeClause *OpenACCFinalizeClause::Create(const ASTContext &C,
+                                                     SourceLocation BeginLoc,
+                                                     SourceLocation EndLoc) {
+  void *Mem =
+      C.Allocate(sizeof(OpenACCFinalizeClause), alignof(OpenACCFinalizeClause));
+  return new (Mem) OpenACCFinalizeClause(BeginLoc, EndLoc);
+}
+
 //===----------------------------------------------------------------------===//
 //  OpenACC clauses printing methods
 //===----------------------------------------------------------------------===//
@@ -685,3 +693,7 @@ void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause &C) {
     OS << ")";
   }
 }
+
+void OpenACCClausePrinter::VisitFinalizeClause(const OpenACCFinalizeClause &C) {
+  OS << "finalize";
+}

diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index e9ff674097c8fa..50418cf2d30e72 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2558,6 +2558,9 @@ void OpenACCClauseProfiler::VisitSelfClause(const OpenACCSelfClause &Clause) {
     Profiler.VisitStmt(Clause.getConditionExpr());
 }
 
+void OpenACCClauseProfiler::VisitFinalizeClause(
+    const OpenACCFinalizeClause &Clause) {}
+
 void OpenACCClauseProfiler::VisitNumGangsClause(
     const OpenACCNumGangsClause &Clause) {
   for (auto *E : Clause.getIntExprs())

diff  --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 209ad3a5f10ac4..32e4569501d91f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -411,6 +411,7 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
     case OpenACCClauseKind::If:
     case OpenACCClauseKind::Independent:
     case OpenACCClauseKind::DevicePtr:
+    case OpenACCClauseKind::Finalize:
     case OpenACCClauseKind::FirstPrivate:
     case OpenACCClauseKind::NoCreate:
     case OpenACCClauseKind::NumGangs:

diff  --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 476b7fc3c3dc87..8a002a17c1834c 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -408,6 +408,14 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
       return false;
     }
   }
+  case OpenACCClauseKind::Finalize: {
+    switch (DirectiveKind) {
+    case OpenACCDirectiveKind::ExitData:
+      return true;
+    default:
+      return false;
+    }
+  }
   }
 
   default:
@@ -1604,6 +1612,14 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitGangClause(
                                  GangKinds, IntExprs, Clause.getEndLoc());
 }
 
+OpenACCClause *SemaOpenACCClauseVisitor::VisitFinalizeClause(
+    SemaOpenACC::OpenACCParsedClause &Clause) {
+  // There isn't anything to do here, this is only valid on one construct, and
+  // has no associated rules.
+  return OpenACCFinalizeClause::Create(Ctx, Clause.getBeginLoc(),
+                                       Clause.getEndLoc());
+}
+
 OpenACCClause *SemaOpenACCClauseVisitor::VisitSeqClause(
     SemaOpenACC::OpenACCParsedClause &Clause) {
   // Restrictions only properly implemented on 'loop' constructs and combined ,

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index f2dbf4086a13da..8ceebc398ab767 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11978,6 +11978,13 @@ void OpenACCClauseTransform<Derived>::VisitSeqClause(
                                        ParsedClause.getBeginLoc(),
                                        ParsedClause.getEndLoc());
 }
+template <typename Derived>
+void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
+    const OpenACCFinalizeClause &C) {
+  NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
+                                            ParsedClause.getBeginLoc(),
+                                            ParsedClause.getEndLoc());
+}
 
 template <typename Derived>
 void OpenACCClauseTransform<Derived>::VisitReductionClause(

diff  --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 490c690189c8ac..fd2dd1809fb1ae 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -12534,6 +12534,8 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() {
   }
   case OpenACCClauseKind::Seq:
     return OpenACCSeqClause::Create(getContext(), BeginLoc, EndLoc);
+  case OpenACCClauseKind::Finalize:
+    return OpenACCFinalizeClause::Create(getContext(), BeginLoc, EndLoc);
   case OpenACCClauseKind::Independent:
     return OpenACCIndependentClause::Create(getContext(), BeginLoc, EndLoc);
   case OpenACCClauseKind::Auto:
@@ -12579,7 +12581,6 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() {
                                        VectorExpr, EndLoc);
   }
 
-  case OpenACCClauseKind::Finalize:
   case OpenACCClauseKind::IfPresent:
   case OpenACCClauseKind::NoHost:
   case OpenACCClauseKind::UseDevice:

diff  --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 820da588a75f5a..e11f2ac1f1191c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -8451,6 +8451,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
   case OpenACCClauseKind::Seq:
   case OpenACCClauseKind::Independent:
   case OpenACCClauseKind::Auto:
+  case OpenACCClauseKind::Finalize:
     // Nothing to do here, there is no additional information beyond the
     // begin/end loc and clause kind.
     return;
@@ -8496,7 +8497,6 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
     return;
   }
 
-  case OpenACCClauseKind::Finalize:
   case OpenACCClauseKind::IfPresent:
   case OpenACCClauseKind::NoHost:
   case OpenACCClauseKind::UseDevice:

diff  --git a/clang/test/AST/ast-print-openacc-data-construct.cpp b/clang/test/AST/ast-print-openacc-data-construct.cpp
index d3acc9f4a3a314..b1cd5f6b6fb96c 100644
--- a/clang/test/AST/ast-print-openacc-data-construct.cpp
+++ b/clang/test/AST/ast-print-openacc-data-construct.cpp
@@ -110,4 +110,7 @@ void foo() {
 // CHECK: #pragma acc data default(none) attach(iPtr, arrayPtr[0])
 #pragma acc data default(none) attach(iPtr, arrayPtr[0])
   ;
+
+// CHECK: #pragma acc exit data copyout(i) finalize
+#pragma acc exit data copyout(i) finalize
 }

diff  --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c
index 558e61d666fd2f..3a08ef83385255 100644
--- a/clang/test/ParserOpenACC/parse-clauses.c
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -4,23 +4,17 @@
 
 void func() {
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
-#pragma acc enter data finalize
+#pragma acc exit data finalize
 
-  // expected-warning at +2{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
-#pragma acc enter data finalize finalize
+#pragma acc exit data finalize finalize
 
-  // expected-warning at +2{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
   // expected-error at +1{{invalid OpenACC clause 'invalid'}}
-#pragma acc enter data finalize invalid
+#pragma acc exit data finalize invalid
 
-  // expected-warning at +2{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
   // expected-error at +1{{invalid OpenACC clause 'invalid'}}
-#pragma acc enter data finalize invalid invalid finalize
+#pragma acc exit data finalize invalid invalid finalize
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented, clause ignored}}
-#pragma acc enter data wait finalize
+#pragma acc exit data wait finalize
 
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented, clause ignored}}
 #pragma acc host_data if_present

diff  --git a/clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c b/clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c
index 16bdcc177bfde3..dfd8152b814d49 100644
--- a/clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c
+++ b/clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c
@@ -37,7 +37,7 @@ void uses() {
   int *VarPtr;
 
   // 'auto' can combine with any other clause.
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop auto finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -154,7 +154,7 @@ void uses() {
 #pragma acc parallel loop auto wait
   for(unsigned i = 0; i < 5; ++i);
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop finalize auto
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -272,7 +272,7 @@ void uses() {
   for(unsigned i = 0; i < 5; ++i);
 
   // 'independent' can also be combined with any clauses
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop independent finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -389,7 +389,7 @@ void uses() {
 #pragma acc parallel loop independent wait
   for(unsigned i = 0; i < 5; ++i);
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop finalize independent
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -519,7 +519,7 @@ void uses() {
   // expected-note at +1{{previous clause is here}}
 #pragma acc parallel loop seq vector
   for(unsigned i = 0; i < 5; ++i);
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop seq finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -642,7 +642,7 @@ void uses() {
   // expected-note at +1{{previous clause is here}}
 #pragma acc parallel loop vector seq
   for(unsigned i = 0; i < 5; ++i);
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'parallel loop' directive}}
 #pragma acc parallel loop finalize seq
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}

diff  --git a/clang/test/SemaOpenACC/combined-construct-device_type-clause.c b/clang/test/SemaOpenACC/combined-construct-device_type-clause.c
index 11bb342a2f638c..ce6b8b8a4ea6d3 100644
--- a/clang/test/SemaOpenACC/combined-construct-device_type-clause.c
+++ b/clang/test/SemaOpenACC/combined-construct-device_type-clause.c
@@ -42,8 +42,7 @@ void uses() {
 #pragma acc parallel loop device_type(*) vector
   for(int i = 0; i < 5; ++i);
 
-  // expected-error at +2{{OpenACC clause 'finalize' may not follow a 'device_type' clause in a 'serial loop' construct}}
-  // expected-note at +1{{previous clause is here}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'serial loop' directive}}
 #pragma acc serial loop device_type(*) finalize
   for(int i = 0; i < 5; ++i);
   // expected-error at +2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'kernels loop' construct}}

diff  --git a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
index 2f4a037529b500..e2326336b748fa 100644
--- a/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
+++ b/clang/test/SemaOpenACC/compute-construct-device_type-clause.c
@@ -42,8 +42,7 @@ void uses() {
 
   // Only 'async', 'wait', num_gangs', 'num_workers', 'vector_length' allowed after 'device_type'.
 
-  // expected-error at +2{{OpenACC clause 'finalize' may not follow a 'device_type' clause in a 'kernels' construct}}
-  // expected-note at +1{{previous clause is here}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'kernels' directive}}
 #pragma acc kernels device_type(*) finalize
   while(1);
   // expected-error at +2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'kernels' construct}}

diff  --git a/clang/test/SemaOpenACC/data-construct-finalize-ast.cpp b/clang/test/SemaOpenACC/data-construct-finalize-ast.cpp
new file mode 100644
index 00000000000000..0dc6605cc60428
--- /dev/null
+++ b/clang/test/SemaOpenACC/data-construct-finalize-ast.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s
+
+// Test this with PCH.
+// RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s
+// RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s
+#ifndef PCH_HELPER
+#define PCH_HELPER
+
+void Uses() {
+  // CHECK: FunctionDecl{{.*}}Uses
+  // CHECK-NEXT: CompoundStmt
+
+  int I;
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl
+
+#pragma acc exit data copyout(I) finalize
+  // CHECK-NEXT: OpenACCExitDataConstruct{{.*}}exit data
+  // CHECK-NEXT: copyout clause
+  // CHECK-NEXT: DeclRefExpr{{.*}}'I' 'int'
+  // CHECK-NEXT: finalize clause
+}
+
+template<typename T>
+void TemplUses() {
+  // CHECK: FunctionTemplateDecl{{.*}}TemplUses
+  // CHECK-NEXT: TemplateTypeParmDecl{{.*}}T
+  // CHECK-NEXT: FunctionDecl{{.*}}TemplUses
+  // CHECK-NEXT: CompoundStmt
+
+  T I;
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl
+
+#pragma acc exit data copyout(I) finalize
+  // CHECK-NEXT: OpenACCExitDataConstruct{{.*}}exit data
+  // CHECK-NEXT: copyout clause
+  // CHECK-NEXT: DeclRefExpr{{.*}}'I' 'T'
+  // CHECK-NEXT: finalize clause
+
+  // Instantiations
+  // CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void ()' implicit_instantiation
+  // CHECK-NEXT: TemplateArgument type 'int'
+  // CHECK-NEXT: BuiltinType{{.*}} 'int'
+  // CHECK-NEXT: CompoundStmt
+
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl
+
+  // CHECK-NEXT: OpenACCExitDataConstruct{{.*}}exit data
+  // CHECK-NEXT: copyout clause
+  // CHECK-NEXT: DeclRefExpr{{.*}}'I' 'int'
+  // CHECK-NEXT: finalize clause
+}
+void Inst() {
+  TemplUses<int>();
+}
+
+
+#endif // PCH_HELPER

diff  --git a/clang/test/SemaOpenACC/data-construct-finalize-clause.c b/clang/test/SemaOpenACC/data-construct-finalize-clause.c
new file mode 100644
index 00000000000000..b2b4ada0e42ed9
--- /dev/null
+++ b/clang/test/SemaOpenACC/data-construct-finalize-clause.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fopenacc -verify
+
+void Test() {
+  int I;
+
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'data' directive}}
+#pragma acc data copyin(I) finalize
+  ;
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'enter data' directive}}
+#pragma acc enter data copyin(I) finalize
+  ;
+
+  // finalize is valid only on exit data, otherwise has no other rules.
+#pragma acc exit data copyout(I) finalize
+  ;
+  // expected-warning at +2{{OpenACC clause 'use_device' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'host_data' directive}}
+#pragma acc host_data use_device(I) finalize
+  ;
+}

diff  --git a/clang/test/SemaOpenACC/data-construct.cpp b/clang/test/SemaOpenACC/data-construct.cpp
index 7b819f698c26c2..3d345bc63d520e 100644
--- a/clang/test/SemaOpenACC/data-construct.cpp
+++ b/clang/test/SemaOpenACC/data-construct.cpp
@@ -84,7 +84,6 @@ void AtLeastOneOf() {
 #pragma acc exit data if(Var)
 #pragma acc exit data async
 #pragma acc exit data wait
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
 #pragma acc exit data finalize
 #pragma acc exit data
 

diff  --git a/clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c b/clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c
index ecf2835776673f..dbb243869b8e21 100644
--- a/clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c
+++ b/clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c
@@ -37,7 +37,7 @@ void uses() {
   int *VarPtr;
 
   // 'auto' can combine with any other clause.
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop auto finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -171,7 +171,7 @@ void uses() {
 #pragma acc loop auto wait
   for(unsigned i = 0; i < 5; ++i);
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop finalize auto
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -306,7 +306,7 @@ void uses() {
   for(unsigned i = 0; i < 5; ++i);
 
   // 'independent' can also be combined with any clauses
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop independent finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -440,7 +440,7 @@ void uses() {
 #pragma acc loop independent wait
   for(unsigned i = 0; i < 5; ++i);
 
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop finalize independent
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -587,7 +587,7 @@ void uses() {
   // expected-note at +1{{previous clause is here}}
 #pragma acc loop seq vector
   for(unsigned i = 0; i < 5; ++i);
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop seq finalize
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}
@@ -727,7 +727,7 @@ void uses() {
   // expected-note at +1{{previous clause is here}}
 #pragma acc loop vector seq
   for(unsigned i = 0; i < 5; ++i);
-  // expected-warning at +1{{OpenACC clause 'finalize' not yet implemented}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop finalize seq
   for(unsigned i = 0; i < 5; ++i);
   // expected-warning at +1{{OpenACC clause 'if_present' not yet implemented}}

diff  --git a/clang/test/SemaOpenACC/loop-construct-device_type-clause.c b/clang/test/SemaOpenACC/loop-construct-device_type-clause.c
index 94406de079cdcd..09c4d12b24a52a 100644
--- a/clang/test/SemaOpenACC/loop-construct-device_type-clause.c
+++ b/clang/test/SemaOpenACC/loop-construct-device_type-clause.c
@@ -41,8 +41,7 @@ void uses() {
 #pragma acc loop device_type(*) vector
   for(int i = 0; i < 5; ++i);
 
-  // expected-error at +2{{OpenACC clause 'finalize' may not follow a 'device_type' clause in a 'loop' construct}}
-  // expected-note at +1{{previous clause is here}}
+  // expected-error at +1{{OpenACC 'finalize' clause is not valid on 'loop' directive}}
 #pragma acc loop device_type(*) finalize
   for(int i = 0; i < 5; ++i);
   // expected-error at +2{{OpenACC clause 'if_present' may not follow a 'device_type' clause in a 'loop' construct}}

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index d0fc69af7c847d..611b73cb1330b1 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2921,6 +2921,8 @@ void OpenACCClauseEnqueue::VisitAutoClause(const OpenACCAutoClause &C) {}
 void OpenACCClauseEnqueue::VisitIndependentClause(
     const OpenACCIndependentClause &C) {}
 void OpenACCClauseEnqueue::VisitSeqClause(const OpenACCSeqClause &C) {}
+void OpenACCClauseEnqueue::VisitFinalizeClause(const OpenACCFinalizeClause &C) {
+}
 void OpenACCClauseEnqueue::VisitCollapseClause(const OpenACCCollapseClause &C) {
   Visitor.AddStmt(C.getLoopCount());
 }


        


More information about the cfe-commits mailing list