[clang] [NFC] Factor out common parts of ArraySections into its own class (PR #89639)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 24 11:53:29 PDT 2024
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/89639
>From b95304b22915217ad149c1b22a6517c585067acf Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 22 Apr 2024 10:35:13 -0700
Subject: [PATCH 1/7] [NFC] Factor out common parts of ArraySections into its
own class
OpenACC is going to need an array sections implementation that is a
simpler version/more restrictive version of the OpenMP version. This
patch extracts the things that should be common between the two into a
template base class. This will allow a followup patch to implement an
OpenACC array sections expression type.
---
clang/include/clang/AST/Expr.h | 105 +++++++++++++++++++++++++++
clang/include/clang/AST/ExprOpenMP.h | 74 ++++---------------
2 files changed, 119 insertions(+), 60 deletions(-)
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 2bfefeabc348be..3fc0170d1a0d8e 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6610,6 +6610,111 @@ class TypoExpr : public Expr {
};
+// This is a sub-class for OpenMP and OpenACC array sections. OpenACC uses a
+// very small subset of the functionality, so this class only exposes the things
+// the two have in common. This type is not expected to be used directly,
+// instead it is inherited from by the OMP and OpenACC variants.
+//
+// This type does not capture a 'stride', only a lower-bound and length (plus
+// the base expression), but provides room via a template argument to get
+// additional ones.
+template<unsigned NumSubExprs, bool AllowNullExprs>
+class ArraySectionExprBase : public Expr {
+ enum {BASE, LOWER_BOUND, LENGTH, END_EXPR = NumSubExprs};
+ Stmt *SubExprs[END_EXPR];
+ SourceLocation ColonLocFirst;
+ SourceLocation RBracketLoc;
+
+ protected:
+ ArraySectionExprBase(StmtClass SC, Expr *Base, Expr *LowerBound,
+ Expr *Length, QualType Type, ExprValueKind VK,
+ ExprObjectKind OK, SourceLocation ColonLocFirst,
+ SourceLocation RBracketLoc)
+ : Expr(SC, Type, VK, OK), ColonLocFirst(ColonLocFirst),
+ RBracketLoc(RBracketLoc) {
+ setBase(Base);
+ setLowerBound(LowerBound);
+ setLength(Length);
+ }
+
+ explicit ArraySectionExprBase(StmtClass SC, EmptyShell Shell)
+ : Expr(SC, Shell) {}
+
+ void setSubExpr(unsigned Idx, Expr *SubExpr) {
+ assert(Idx > LENGTH &&
+ "setting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'setter' functions");
+ assert((SubExpr || AllowNullExprs) && "Null expression when not allowed");
+ SubExprs[Idx] = SubExpr;
+ }
+
+ Expr *getSubExpr(unsigned Idx) {
+ assert(Idx > LENGTH &&
+ "getting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'getter' functions");
+ return cast_or_null<Expr>(SubExprs[Idx]);
+ }
+ const Expr *getSubExpr(unsigned Idx) const {
+ assert(Idx > LENGTH &&
+ "getting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'getter' functions");
+ return cast_or_null<Expr>(SubExprs[Idx]);
+ }
+
+ public:
+ /// Get base of the array section.
+ Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
+ const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
+ /// Set base of the array section.
+ void setBase(Expr *E) {
+ assert((E || AllowNullExprs) && "Null expression when not allowed");
+ SubExprs[BASE] = E;
+ }
+
+ /// Get lower bound of array section.
+ Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
+ const Expr *getLowerBound() const {
+ return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
+ }
+ /// Set lower bound of the array section.
+ void setLowerBound(Expr *E) {
+ assert((E || AllowNullExprs) && "Null expression when not allowed");
+ SubExprs[LOWER_BOUND] = E;
+ }
+
+ /// Get length of array section.
+ Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
+ const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
+ /// Set length of the array section.
+ void setLength(Expr *E) {
+ assert((E || AllowNullExprs) && "Null expression when not allowed");
+ SubExprs[LENGTH] = E;
+ }
+
+ SourceLocation getBeginLoc() const LLVM_READONLY {
+ return getBase()->getBeginLoc();
+ }
+
+ SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
+
+ SourceLocation getColonLocFirst() const { return ColonLocFirst; }
+ void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
+
+ SourceLocation getRBracketLoc() const { return RBracketLoc; }
+ void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
+
+ SourceLocation getExprLoc() const LLVM_READONLY {
+ return getBase()->getExprLoc();
+ }
+ child_range children() {
+ return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ }
+
+ const_child_range children() const {
+ return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ }
+};
+
/// Frontend produces RecoveryExprs on semantic errors that prevent creating
/// other well-formed expressions. E.g. when type-checking of a binary operator
/// fails, we cannot produce a BinaryOperator expression. Instead, we can choose
diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h
index be5b1f3fdd112f..c410c82d9469a3 100644
--- a/clang/include/clang/AST/ExprOpenMP.h
+++ b/clang/include/clang/AST/ExprOpenMP.h
@@ -53,92 +53,46 @@ namespace clang {
/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉,
/// where size is the size of the array dimension. When the lower-bound is
/// absent it defaults to 0.
-class OMPArraySectionExpr : public Expr {
+namespace OMPArraySectionIndices {
enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
- Stmt *SubExprs[END_EXPR];
- SourceLocation ColonLocFirst;
+}
+class OMPArraySectionExpr
+ : public ArraySectionExprBase<OMPArraySectionIndices::END_EXPR,
+ /*AllowNullExprs=*/true> {
SourceLocation ColonLocSecond;
- SourceLocation RBracketLoc;
public:
OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride,
QualType Type, ExprValueKind VK, ExprObjectKind OK,
SourceLocation ColonLocFirst,
SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
- : Expr(OMPArraySectionExprClass, Type, VK, OK),
- ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
- RBracketLoc(RBracketLoc) {
- SubExprs[BASE] = Base;
- SubExprs[LOWER_BOUND] = LowerBound;
- SubExprs[LENGTH] = Length;
- SubExprs[STRIDE] = Stride;
+ : ArraySectionExprBase(OMPArraySectionExprClass, Base, LowerBound, Length,
+ Type, VK, OK, ColonLocFirst, RBracketLoc) {
+ setSubExpr(OMPArraySectionIndices::STRIDE, Stride);
setDependence(computeDependence(this));
}
/// Create an empty array section expression.
explicit OMPArraySectionExpr(EmptyShell Shell)
- : Expr(OMPArraySectionExprClass, Shell) {}
-
- /// An array section can be written only as Base[LowerBound:Length].
-
- /// Get base of the array section.
- Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
- const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
- /// Set base of the array section.
- void setBase(Expr *E) { SubExprs[BASE] = E; }
+ : ArraySectionExprBase(OMPArraySectionExprClass, Shell) {}
/// Return original type of the base expression for array section.
static QualType getBaseOriginalType(const Expr *Base);
- /// Get lower bound of array section.
- Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
- const Expr *getLowerBound() const {
- return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
- }
- /// Set lower bound of the array section.
- void setLowerBound(Expr *E) { SubExprs[LOWER_BOUND] = E; }
-
- /// Get length of array section.
- Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
- const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
- /// Set length of the array section.
- void setLength(Expr *E) { SubExprs[LENGTH] = E; }
-
/// Get stride of array section.
- Expr *getStride() { return cast_or_null<Expr>(SubExprs[STRIDE]); }
- const Expr *getStride() const { return cast_or_null<Expr>(SubExprs[STRIDE]); }
- /// Set length of the array section.
- void setStride(Expr *E) { SubExprs[STRIDE] = E; }
-
- SourceLocation getBeginLoc() const LLVM_READONLY {
- return getBase()->getBeginLoc();
+ Expr *getStride() { return getSubExpr(OMPArraySectionIndices::STRIDE); }
+ const Expr *getStride() const {
+ return getSubExpr(OMPArraySectionIndices::STRIDE);
}
- SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
-
- SourceLocation getColonLocFirst() const { return ColonLocFirst; }
- void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
+ /// Set length of the array section.
+ void setStride(Expr *E) { setSubExpr(OMPArraySectionIndices::STRIDE, E); }
SourceLocation getColonLocSecond() const { return ColonLocSecond; }
void setColonLocSecond(SourceLocation L) { ColonLocSecond = L; }
- SourceLocation getRBracketLoc() const { return RBracketLoc; }
- void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
-
- SourceLocation getExprLoc() const LLVM_READONLY {
- return getBase()->getExprLoc();
- }
-
static bool classof(const Stmt *T) {
return T->getStmtClass() == OMPArraySectionExprClass;
}
-
- child_range children() {
- return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
- }
-
- const_child_range children() const {
- return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
- }
};
/// An explicit cast in C or a C-style cast in C++, which uses the syntax
>From e4739614794889d45058d899ab55ed80088290d2 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 22 Apr 2024 11:18:20 -0700
Subject: [PATCH 2/7] Move to protected + clang-format
---
clang/include/clang/AST/Expr.h | 108 ++++++++++++++-------------
clang/include/clang/AST/ExprOpenMP.h | 2 +-
2 files changed, 57 insertions(+), 53 deletions(-)
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 3fc0170d1a0d8e..c4aa56519b21ad 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6618,79 +6618,83 @@ class TypoExpr : public Expr {
// This type does not capture a 'stride', only a lower-bound and length (plus
// the base expression), but provides room via a template argument to get
// additional ones.
-template<unsigned NumSubExprs, bool AllowNullExprs>
+template <unsigned NumSubExprs, bool AllowNullExprs>
class ArraySectionExprBase : public Expr {
- enum {BASE, LOWER_BOUND, LENGTH, END_EXPR = NumSubExprs};
+ friend class ASTStmtReader;
+
+ enum { BASE, LOWER_BOUND, LENGTH, END_EXPR = NumSubExprs };
Stmt *SubExprs[END_EXPR];
SourceLocation ColonLocFirst;
SourceLocation RBracketLoc;
- protected:
- ArraySectionExprBase(StmtClass SC, Expr *Base, Expr *LowerBound,
- Expr *Length, QualType Type, ExprValueKind VK,
- ExprObjectKind OK, SourceLocation ColonLocFirst,
- SourceLocation RBracketLoc)
- : Expr(SC, Type, VK, OK), ColonLocFirst(ColonLocFirst),
- RBracketLoc(RBracketLoc) {
- setBase(Base);
- setLowerBound(LowerBound);
- setLength(Length);
- }
+protected:
+ ArraySectionExprBase(StmtClass SC, Expr *Base, Expr *LowerBound, Expr *Length,
+ QualType Type, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation ColonLocFirst, SourceLocation RBracketLoc)
+ : Expr(SC, Type, VK, OK), ColonLocFirst(ColonLocFirst),
+ RBracketLoc(RBracketLoc) {
+ setBase(Base);
+ setLowerBound(LowerBound);
+ setLength(Length);
+ }
- explicit ArraySectionExprBase(StmtClass SC, EmptyShell Shell)
- : Expr(SC, Shell) {}
+ explicit ArraySectionExprBase(StmtClass SC, EmptyShell Shell)
+ : Expr(SC, Shell) {}
- void setSubExpr(unsigned Idx, Expr *SubExpr) {
- assert(Idx > LENGTH &&
- "setting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'setter' functions");
- assert((SubExpr || AllowNullExprs) && "Null expression when not allowed");
- SubExprs[Idx] = SubExpr;
- }
+ void setSubExpr(unsigned Idx, Expr *SubExpr) {
+ assert(Idx > LENGTH &&
+ "setting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'setter' functions");
+ assert((SubExpr || AllowNullExprs) && "Null expression when not allowed");
+ SubExprs[Idx] = SubExpr;
+ }
- Expr *getSubExpr(unsigned Idx) {
- assert(Idx > LENGTH &&
- "getting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'getter' functions");
- return cast_or_null<Expr>(SubExprs[Idx]);
- }
- const Expr *getSubExpr(unsigned Idx) const {
- assert(Idx > LENGTH &&
- "getting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'getter' functions");
- return cast_or_null<Expr>(SubExprs[Idx]);
- }
+ Expr *getSubExpr(unsigned Idx) {
+ assert(Idx > LENGTH &&
+ "getting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'getter' functions");
+ return cast_or_null<Expr>(SubExprs[Idx]);
+ }
+ const Expr *getSubExpr(unsigned Idx) const {
+ assert(Idx > LENGTH &&
+ "getting sub expression owned by ArraySectionExprBase: Should be "
+ "using the direct 'getter' functions");
+ return cast_or_null<Expr>(SubExprs[Idx]);
+ }
- public:
- /// Get base of the array section.
- Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
- const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
/// Set base of the array section.
void setBase(Expr *E) {
assert((E || AllowNullExprs) && "Null expression when not allowed");
SubExprs[BASE] = E;
}
- /// Get lower bound of array section.
- Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
- const Expr *getLowerBound() const {
- return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
- }
/// Set lower bound of the array section.
void setLowerBound(Expr *E) {
assert((E || AllowNullExprs) && "Null expression when not allowed");
SubExprs[LOWER_BOUND] = E;
}
- /// Get length of array section.
- Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
- const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
/// Set length of the array section.
void setLength(Expr *E) {
assert((E || AllowNullExprs) && "Null expression when not allowed");
SubExprs[LENGTH] = E;
}
+public:
+ /// Get base of the array section.
+ Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
+ const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
+
+ /// Get lower bound of array section.
+ Expr *getLowerBound() { return cast_or_null<Expr>(SubExprs[LOWER_BOUND]); }
+ const Expr *getLowerBound() const {
+ return cast_or_null<Expr>(SubExprs[LOWER_BOUND]);
+ }
+
+ /// Get length of array section.
+ Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
+ const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
+
SourceLocation getBeginLoc() const LLVM_READONLY {
return getBase()->getBeginLoc();
}
@@ -6706,13 +6710,13 @@ class ArraySectionExprBase : public Expr {
SourceLocation getExprLoc() const LLVM_READONLY {
return getBase()->getExprLoc();
}
- child_range children() {
- return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
- }
+ child_range children() {
+ return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ }
- const_child_range children() const {
- return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
- }
+ const_child_range children() const {
+ return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ }
};
/// Frontend produces RecoveryExprs on semantic errors that prevent creating
diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h
index c410c82d9469a3..f013f92cca430a 100644
--- a/clang/include/clang/AST/ExprOpenMP.h
+++ b/clang/include/clang/AST/ExprOpenMP.h
@@ -54,7 +54,7 @@ namespace clang {
/// where size is the size of the array dimension. When the lower-bound is
/// absent it defaults to 0.
namespace OMPArraySectionIndices {
- enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
+enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
}
class OMPArraySectionExpr
: public ArraySectionExprBase<OMPArraySectionIndices::END_EXPR,
>From c8a9094b640c87d98074d5b1f67523e4204cdaef Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 22 Apr 2024 11:54:27 -0700
Subject: [PATCH 3/7] Correctly initialize second-colon-loc so it prints
correctly
---
clang/include/clang/AST/ExprOpenMP.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h
index f013f92cca430a..930b9e3603b7c2 100644
--- a/clang/include/clang/AST/ExprOpenMP.h
+++ b/clang/include/clang/AST/ExprOpenMP.h
@@ -67,7 +67,8 @@ class OMPArraySectionExpr
SourceLocation ColonLocFirst,
SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
: ArraySectionExprBase(OMPArraySectionExprClass, Base, LowerBound, Length,
- Type, VK, OK, ColonLocFirst, RBracketLoc) {
+ Type, VK, OK, ColonLocFirst, RBracketLoc),
+ ColonLocSecond(ColonLocSecond) {
setSubExpr(OMPArraySectionIndices::STRIDE, Stride);
setDependence(computeDependence(this));
}
>From 9c7489e34c064bb99b3c5aaac4a5003a06278b45 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Tue, 23 Apr 2024 14:03:49 -0700
Subject: [PATCH 4/7] Re-implementation: renames OMPArraySectionExpr to
ArraySectionExpr
This version of the patch generializes the OMPArraySectionExpr to
be more generic, and renames it ArraySectionExpr. There is a LOT of work
involved obviously, but it is pretty rote. I've also added stubs for the
OpenACC implementation/use of this, but there is currently no Sema for
it implemented.
Note that I've found a few small 'bugs' in the OpenMP implementation
while auditing hte code, which I'll mention inline.
---
clang/include/clang-c/Index.h | 3 +-
clang/include/clang/AST/ASTContext.h | 3 +-
clang/include/clang/AST/BuiltinTypes.def | 2 +-
clang/include/clang/AST/ComputeDependence.h | 4 +-
clang/include/clang/AST/Expr.h | 287 +++++++++++++-----
clang/include/clang/AST/ExprOpenMP.h | 79 -----
clang/include/clang/AST/RecursiveASTVisitor.h | 2 +-
.../clang/Basic/DiagnosticSemaKinds.td | 2 +-
clang/include/clang/Basic/StmtNodes.td | 2 +-
clang/include/clang/Sema/SemaOpenACC.h | 6 +
.../include/clang/Serialization/ASTBitCodes.h | 6 +-
clang/lib/AST/ASTContext.cpp | 12 +-
clang/lib/AST/ComputeDependence.cpp | 7 +-
clang/lib/AST/Expr.cpp | 6 +-
clang/lib/AST/ExprClassification.cpp | 2 +-
clang/lib/AST/ExprConstant.cpp | 2 +-
clang/lib/AST/ItaniumMangle.cpp | 2 +-
clang/lib/AST/NSAPI.cpp | 2 +-
clang/lib/AST/StmtPrinter.cpp | 4 +-
clang/lib/AST/StmtProfile.cpp | 2 +-
clang/lib/AST/Type.cpp | 6 +-
clang/lib/AST/TypeLoc.cpp | 2 +-
clang/lib/CodeGen/CGExpr.cpp | 16 +-
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 42 +--
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 4 +-
clang/lib/CodeGen/CGStmtOpenMP.cpp | 4 +-
clang/lib/CodeGen/CodeGenFunction.h | 4 +-
clang/lib/Parse/ParseExpr.cpp | 26 +-
clang/lib/Sema/SemaChecking.cpp | 6 +-
clang/lib/Sema/SemaExceptionSpec.cpp | 2 +-
clang/lib/Sema/SemaExpr.cpp | 23 +-
clang/lib/Sema/SemaInit.cpp | 4 +-
clang/lib/Sema/SemaOpenACC.cpp | 16 +
clang/lib/Sema/SemaOpenMP.cpp | 75 ++---
clang/lib/Sema/TreeTransform.h | 51 ++--
clang/lib/Serialization/ASTCommon.cpp | 4 +-
clang/lib/Serialization/ASTReader.cpp | 6 +-
clang/lib/Serialization/ASTReaderStmt.cpp | 18 +-
clang/lib/Serialization/ASTWriterStmt.cpp | 13 +-
.../Checkers/DereferenceChecker.cpp | 4 +-
.../Checkers/IdenticalExprChecker.cpp | 2 +-
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +-
clang/test/OpenMP/target_depend_messages.cpp | 2 +-
.../target_enter_data_depend_messages.cpp | 4 +-
.../target_exit_data_depend_messages.cpp | 4 +-
clang/test/OpenMP/target_map_messages.cpp | 10 +-
.../target_parallel_depend_messages.cpp | 2 +-
.../target_parallel_for_depend_messages.cpp | 2 +-
...rget_parallel_for_simd_depend_messages.cpp | 2 +-
.../OpenMP/target_simd_depend_messages.cpp | 2 +-
.../OpenMP/target_teams_depend_messages.cpp | 2 +-
...arget_teams_distribute_depend_messages.cpp | 2 +-
...istribute_parallel_for_depend_messages.cpp | 2 +-
...bute_parallel_for_simd_depend_messages.cpp | 2 +-
..._teams_distribute_simd_depend_messages.cpp | 2 +-
.../test/OpenMP/target_teams_map_messages.cpp | 8 +-
.../OpenMP/target_update_depend_messages.cpp | 4 +-
.../OpenMP/target_update_from_messages.cpp | 8 +-
.../test/OpenMP/target_update_to_messages.cpp | 8 +-
clang/test/OpenMP/task_affinity_messages.cpp | 2 +-
clang/test/OpenMP/task_depend_messages.cpp | 4 +-
.../test/OpenMP/taskwait_depend_messages.cpp | 2 +-
.../ParserOpenACC/parse-cache-construct.cpp | 4 +-
clang/test/ParserOpenACC/parse-clauses.c | 4 +-
clang/tools/libclang/CIndex.cpp | 4 +-
clang/tools/libclang/CXCursor.cpp | 4 +-
66 files changed, 499 insertions(+), 356 deletions(-)
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 7a8bd985a91fc0..365b607c741179 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -1644,8 +1644,9 @@ enum CXCursorKind {
CXCursor_ObjCSelfExpr = 146,
/** OpenMP 5.0 [2.1.5, Array Section].
+ * OpenACC 3.3 [2.7.1, Data Specification for Data Clauses (Sub Arrays)]
*/
- CXCursor_OMPArraySectionExpr = 147,
+ CXCursor_ArraySectionExpr = 147,
/** Represents an @available(...) check.
*/
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 28f8d67811f0a2..1cd622ac6fde04 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1127,7 +1127,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
CanQualType OCLQueueTy, OCLReserveIDTy;
CanQualType IncompleteMatrixIdxTy;
- CanQualType OMPArraySectionTy, OMPArrayShapingTy, OMPIteratorTy;
+ CanQualType ArraySectionTy;
+ CanQualType OMPArrayShapingTy, OMPIteratorTy;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
CanQualType Id##Ty;
#include "clang/Basic/OpenCLExtensionTypes.def"
diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f127191..0a36fdc5d9c0f7 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -320,7 +320,7 @@ PLACEHOLDER_TYPE(ARCUnbridgedCast, ARCUnbridgedCastTy)
PLACEHOLDER_TYPE(IncompleteMatrixIdx, IncompleteMatrixIdxTy)
// A placeholder type for OpenMP array sections.
-PLACEHOLDER_TYPE(OMPArraySection, OMPArraySectionTy)
+PLACEHOLDER_TYPE(ArraySection, ArraySectionTy)
// A placeholder type for OpenMP array shaping operation.
PLACEHOLDER_TYPE(OMPArrayShaping, OMPArrayShapingTy)
diff --git a/clang/include/clang/AST/ComputeDependence.h b/clang/include/clang/AST/ComputeDependence.h
index 7abf9141237dc8..6d3a51c379f9df 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -94,7 +94,7 @@ class DesignatedInitExpr;
class ParenListExpr;
class PseudoObjectExpr;
class AtomicExpr;
-class OMPArraySectionExpr;
+class ArraySectionExpr;
class OMPArrayShapingExpr;
class OMPIteratorExpr;
class ObjCArrayLiteral;
@@ -189,7 +189,7 @@ ExprDependence computeDependence(ParenListExpr *E);
ExprDependence computeDependence(PseudoObjectExpr *E);
ExprDependence computeDependence(AtomicExpr *E);
-ExprDependence computeDependence(OMPArraySectionExpr *E);
+ExprDependence computeDependence(ArraySectionExpr *E);
ExprDependence computeDependence(OMPArrayShapingExpr *E);
ExprDependence computeDependence(OMPIteratorExpr *E);
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index c4aa56519b21ad..d3d10c4f014f78 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6610,77 +6610,181 @@ class TypoExpr : public Expr {
};
-// This is a sub-class for OpenMP and OpenACC array sections. OpenACC uses a
-// very small subset of the functionality, so this class only exposes the things
-// the two have in common. This type is not expected to be used directly,
-// instead it is inherited from by the OMP and OpenACC variants.
-//
-// This type does not capture a 'stride', only a lower-bound and length (plus
-// the base expression), but provides room via a template argument to get
-// additional ones.
-template <unsigned NumSubExprs, bool AllowNullExprs>
-class ArraySectionExprBase : public Expr {
+/// This class represents BOTH the OpenMP Array Section and OpenACC 'subarray',
+/// with a boolean differentiator.
+/// OpenMP 5.0 [2.1.5, Array Sections].
+/// To specify an array section in an OpenMP construct, array subscript
+/// expressions are extended with the following syntax:
+/// \code
+/// [ lower-bound : length : stride ]
+/// [ lower-bound : length : ]
+/// [ lower-bound : length ]
+/// [ lower-bound : : stride ]
+/// [ lower-bound : : ]
+/// [ lower-bound : ]
+/// [ : length : stride ]
+/// [ : length : ]
+/// [ : length ]
+/// [ : : stride ]
+/// [ : : ]
+/// [ : ]
+/// \endcode
+/// The array section must be a subset of the original array.
+/// Array sections are allowed on multidimensional arrays. Base language array
+/// subscript expressions can be used to specify length-one dimensions of
+/// multidimensional array sections.
+/// Each of the lower-bound, length, and stride expressions if specified must be
+/// an integral type expressions of the base language. When evaluated
+/// they represent a set of integer values as follows:
+/// \code
+/// { lower-bound, lower-bound + stride, lower-bound + 2 * stride,... ,
+/// lower-bound + ((length - 1) * stride) }
+/// \endcode
+/// The lower-bound and length must evaluate to non-negative integers.
+/// The stride must evaluate to a positive integer.
+/// When the size of the array dimension is not known, the length must be
+/// specified explicitly.
+/// When the stride is absent it defaults to 1.
+/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉,
+/// where size is the size of the array dimension. When the lower-bound is
+/// absent it defaults to 0.
+///
+///
+/// OpenACC 3.3 [2.7.1 Data Specification in Data Clauses]
+/// In C and C++, a subarray is an array name followed by an extended array
+/// range specification in brackets, with start and length, such as
+///
+/// AA[2:n]
+///
+/// If the lower bound is missing, zero is used. If the length is missing and
+/// the array has known size, the size of the array is used; otherwise the
+/// length is required. The subarray AA[2:n] means elements AA[2], AA[3], . . .
+/// , AA[2+n-1]. In C and C++, a two dimensional array may be declared in at
+/// least four ways:
+///
+/// -Statically-sized array: float AA[100][200];
+/// -Pointer to statically sized rows: typedef float row[200]; row* BB;
+/// -Statically-sized array of pointers: float* CC[200];
+/// -Pointer to pointers: float** DD;
+///
+/// Each dimension may be statically sized, or a pointer to dynamically
+/// allocated memory. Each of these may be included in a data clause using
+/// subarray notation to specify a rectangular array:
+///
+/// -AA[2:n][0:200]
+/// -BB[2:n][0:m]
+/// -CC[2:n][0:m]
+/// -DD[2:n][0:m]
+///
+/// Multidimensional rectangular subarrays in C and C++ may be specified for any
+/// array with any combination of statically-sized or dynamically-allocated
+/// dimensions. For statically sized dimensions, all dimensions except the first
+/// must specify the whole extent to preserve the contiguous data restriction,
+/// discussed below. For dynamically allocated dimensions, the implementation
+/// will allocate pointers in device memory corresponding to the pointers in
+/// local memory and will fill in those pointers as appropriate.
+///
+/// In Fortran, a subarray is an array name followed by a comma-separated list
+/// of range specifications in parentheses, with lower and upper bound
+/// subscripts, such as
+///
+/// arr(1:high,low:100)
+///
+/// If either the lower or upper bounds are missing, the declared or allocated
+/// bounds of the array, if known, are used. All dimensions except the last must
+/// specify the whole extent, to preserve the contiguous data restriction,
+/// discussed below.
+///
+/// Restrictions
+///
+/// -In Fortran, the upper bound for the last dimension of an assumed-size dummy
+/// array must be specified.
+///
+/// -In C and C++, the length for dynamically allocated dimensions of an array
+/// must be explicitly specified.
+///
+/// -In C and C++, modifying pointers in pointer arrays during the data
+/// lifetime, either on the host or on the device, may result in undefined
+/// behavior.
+///
+/// -If a subarray appears in a data clause, the implementation may choose to
+/// allocate memory for only that subarray on the accelerator.
+///
+/// -In Fortran, array pointers may appear, but pointer association is not
+/// preserved in device memory.
+///
+/// -Any array or subarray in a data clause, including Fortran array pointers,
+/// must be a contiguous section of memory, except for dynamic multidimensional
+/// C arrays.
+///
+/// -In C and C++, if a variable or array of composite type appears, all the
+/// data members of the struct or class are allocated and copied, as
+/// appropriate. If a composite member is a pointer type, the data addressed by
+/// that pointer are not implicitly copied.
+///
+/// -In Fortran, if a variable or array of composite type appears, all the
+/// members of that derived type are allocated and copied, as appropriate. If
+/// any member has the allocatable or pointer attribute, the data accessed
+/// through that member are not copied.
+///
+/// -If an expression is used in a subscript or subarray expression in a clause
+/// on a data construct, the same value is used when copying data at the end of
+/// the data region, even if the values of variables in the expression change
+/// during the data region.
+class ArraySectionExpr : public Expr {
friend class ASTStmtReader;
+ friend class ASTStmtWriter;
+ public:
+ enum ArraySectionType { OMPArraySection, OpenACCArraySection};
+ private:
+ enum {
+ BASE,
+ LOWER_BOUND,
+ LENGTH,
+ STRIDE,
+ END_EXPR,
+ OPENACC_END_EXPR = STRIDE
+ };
- enum { BASE, LOWER_BOUND, LENGTH, END_EXPR = NumSubExprs };
- Stmt *SubExprs[END_EXPR];
- SourceLocation ColonLocFirst;
- SourceLocation RBracketLoc;
-
-protected:
- ArraySectionExprBase(StmtClass SC, Expr *Base, Expr *LowerBound, Expr *Length,
- QualType Type, ExprValueKind VK, ExprObjectKind OK,
- SourceLocation ColonLocFirst, SourceLocation RBracketLoc)
- : Expr(SC, Type, VK, OK), ColonLocFirst(ColonLocFirst),
- RBracketLoc(RBracketLoc) {
- setBase(Base);
- setLowerBound(LowerBound);
- setLength(Length);
- }
-
- explicit ArraySectionExprBase(StmtClass SC, EmptyShell Shell)
- : Expr(SC, Shell) {}
-
- void setSubExpr(unsigned Idx, Expr *SubExpr) {
- assert(Idx > LENGTH &&
- "setting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'setter' functions");
- assert((SubExpr || AllowNullExprs) && "Null expression when not allowed");
- SubExprs[Idx] = SubExpr;
- }
-
- Expr *getSubExpr(unsigned Idx) {
- assert(Idx > LENGTH &&
- "getting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'getter' functions");
- return cast_or_null<Expr>(SubExprs[Idx]);
- }
- const Expr *getSubExpr(unsigned Idx) const {
- assert(Idx > LENGTH &&
- "getting sub expression owned by ArraySectionExprBase: Should be "
- "using the direct 'getter' functions");
- return cast_or_null<Expr>(SubExprs[Idx]);
- }
+ ArraySectionType ASType;
+ Stmt *SubExprs[END_EXPR] = {0};
+ SourceLocation ColonLocFirst;
+ SourceLocation ColonLocSecond;
+ SourceLocation RBracketLoc;
- /// Set base of the array section.
- void setBase(Expr *E) {
- assert((E || AllowNullExprs) && "Null expression when not allowed");
- SubExprs[BASE] = E;
- }
+ public:
+ ArraySectionExpr(ArraySectionType ASType, Expr *Base, Expr *LowerBound,
+ Expr *Length, Expr *Stride, QualType Type,
+ ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation ColonLocFirst,
+ SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
+ : Expr(ArraySectionExprClass, Type, VK, OK), ASType(ASType),
+ ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
+ RBracketLoc(RBracketLoc) {
+ setBase(Base);
+ setLowerBound(LowerBound);
+ setLength(Length);
+
+ assert((!isOpenACCArraySection() || Stride == nullptr) &&
+ "Stride not valid on an OpenACC array section");
+ if (ASType == OMPArraySection)
+ setStride(Stride);
+ setDependence(computeDependence(this));
+ }
+ /// Create an empty array section expression.
+ explicit ArraySectionExpr(EmptyShell Shell)
+ : Expr(ArraySectionExprClass, Shell) {}
+
+ /// Return original type of the base expression for array section.
+ static QualType getBaseOriginalType(const Expr *Base);
- /// Set lower bound of the array section.
- void setLowerBound(Expr *E) {
- assert((E || AllowNullExprs) && "Null expression when not allowed");
- SubExprs[LOWER_BOUND] = E;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ArraySectionExprClass;
}
- /// Set length of the array section.
- void setLength(Expr *E) {
- assert((E || AllowNullExprs) && "Null expression when not allowed");
- SubExprs[LENGTH] = E;
- }
+ bool isOMPArraySection() const { return ASType == OMPArraySection; }
+ bool isOpenACCArraySection() const { return ASType == OpenACCArraySection; }
-public:
/// Get base of the array section.
Expr *getBase() { return cast<Expr>(SubExprs[BASE]); }
const Expr *getBase() const { return cast<Expr>(SubExprs[BASE]); }
@@ -6695,28 +6799,71 @@ class ArraySectionExprBase : public Expr {
Expr *getLength() { return cast_or_null<Expr>(SubExprs[LENGTH]); }
const Expr *getLength() const { return cast_or_null<Expr>(SubExprs[LENGTH]); }
+ /// Get stride of array section.
+ Expr *getStride() {
+ assert(ASType != OpenACCArraySection &&
+ "Stride not valid in OpenACC subarrays");
+ return cast_or_null<Expr>(SubExprs[STRIDE]); }
+
+ const Expr *getStride() const {
+ assert(ASType != OpenACCArraySection &&
+ "Stride not valid in OpenACC subarrays");
+ return cast_or_null<Expr>(SubExprs[STRIDE]);
+ }
+
SourceLocation getBeginLoc() const LLVM_READONLY {
return getBase()->getBeginLoc();
}
-
SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; }
SourceLocation getColonLocFirst() const { return ColonLocFirst; }
- void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
-
+ SourceLocation getColonLocSecond() const {
+ assert(ASType != OpenACCArraySection &&
+ "second colon for stride not valid in OpenACC subarrays");
+ return ColonLocSecond; }
SourceLocation getRBracketLoc() const { return RBracketLoc; }
- void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
SourceLocation getExprLoc() const LLVM_READONLY {
return getBase()->getExprLoc();
}
+
child_range children() {
- return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ return child_range(
+ &SubExprs[BASE],
+ &SubExprs[ASType == OMPArraySection ? END_EXPR : OPENACC_END_EXPR]);
}
const_child_range children() const {
- return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]);
+ return const_child_range(
+ &SubExprs[BASE],
+ &SubExprs[ASType == OMPArraySection ? END_EXPR : OPENACC_END_EXPR]);
}
+
+private:
+ /// Set base of the array section.
+ void setBase(Expr *E) { SubExprs[BASE] = E; }
+
+ /// Set lower bound of the array section.
+ void setLowerBound(Expr *E) { SubExprs[LOWER_BOUND] = E; }
+
+ /// Set length of the array section.
+ void setLength(Expr *E) { SubExprs[LENGTH] = E; }
+
+ /// Set length of the array section.
+ void setStride(Expr *E) {
+ assert(ASType != OpenACCArraySection &&
+ "Stride not valid in OpenACC subarrays");
+ SubExprs[STRIDE] = E;
+ }
+
+ void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; }
+
+ void setColonLocSecond(SourceLocation L) {
+ assert(ASType != OpenACCArraySection &&
+ "second colon for stride not valid in OpenACC subarrays");
+ ColonLocSecond = L;
+ }
+ void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
};
/// Frontend produces RecoveryExprs on semantic errors that prevent creating
diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h
index 930b9e3603b7c2..54a0c203f656c3 100644
--- a/clang/include/clang/AST/ExprOpenMP.h
+++ b/clang/include/clang/AST/ExprOpenMP.h
@@ -17,85 +17,6 @@
#include "clang/AST/Expr.h"
namespace clang {
-/// OpenMP 5.0 [2.1.5, Array Sections].
-/// To specify an array section in an OpenMP construct, array subscript
-/// expressions are extended with the following syntax:
-/// \code
-/// [ lower-bound : length : stride ]
-/// [ lower-bound : length : ]
-/// [ lower-bound : length ]
-/// [ lower-bound : : stride ]
-/// [ lower-bound : : ]
-/// [ lower-bound : ]
-/// [ : length : stride ]
-/// [ : length : ]
-/// [ : length ]
-/// [ : : stride ]
-/// [ : : ]
-/// [ : ]
-/// \endcode
-/// The array section must be a subset of the original array.
-/// Array sections are allowed on multidimensional arrays. Base language array
-/// subscript expressions can be used to specify length-one dimensions of
-/// multidimensional array sections.
-/// Each of the lower-bound, length, and stride expressions if specified must be
-/// an integral type expressions of the base language. When evaluated
-/// they represent a set of integer values as follows:
-/// \code
-/// { lower-bound, lower-bound + stride, lower-bound + 2 * stride,... ,
-/// lower-bound + ((length - 1) * stride) }
-/// \endcode
-/// The lower-bound and length must evaluate to non-negative integers.
-/// The stride must evaluate to a positive integer.
-/// When the size of the array dimension is not known, the length must be
-/// specified explicitly.
-/// When the stride is absent it defaults to 1.
-/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉,
-/// where size is the size of the array dimension. When the lower-bound is
-/// absent it defaults to 0.
-namespace OMPArraySectionIndices {
-enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR };
-}
-class OMPArraySectionExpr
- : public ArraySectionExprBase<OMPArraySectionIndices::END_EXPR,
- /*AllowNullExprs=*/true> {
- SourceLocation ColonLocSecond;
-
-public:
- OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride,
- QualType Type, ExprValueKind VK, ExprObjectKind OK,
- SourceLocation ColonLocFirst,
- SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
- : ArraySectionExprBase(OMPArraySectionExprClass, Base, LowerBound, Length,
- Type, VK, OK, ColonLocFirst, RBracketLoc),
- ColonLocSecond(ColonLocSecond) {
- setSubExpr(OMPArraySectionIndices::STRIDE, Stride);
- setDependence(computeDependence(this));
- }
-
- /// Create an empty array section expression.
- explicit OMPArraySectionExpr(EmptyShell Shell)
- : ArraySectionExprBase(OMPArraySectionExprClass, Shell) {}
-
- /// Return original type of the base expression for array section.
- static QualType getBaseOriginalType(const Expr *Base);
-
- /// Get stride of array section.
- Expr *getStride() { return getSubExpr(OMPArraySectionIndices::STRIDE); }
- const Expr *getStride() const {
- return getSubExpr(OMPArraySectionIndices::STRIDE);
- }
- /// Set length of the array section.
- void setStride(Expr *E) { setSubExpr(OMPArraySectionIndices::STRIDE, E); }
-
- SourceLocation getColonLocSecond() const { return ColonLocSecond; }
- void setColonLocSecond(SourceLocation L) { ColonLocSecond = L; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == OMPArraySectionExprClass;
- }
-};
-
/// An explicit cast in C or a C-style cast in C++, which uses the syntax
/// ([s1][s2]...[sn])expr. For example: @c ([3][3])f.
class OMPArrayShapingExpr final
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 7eb92e304a3856..f9b145b4e86a55 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2740,7 +2740,7 @@ DEF_TRAVERSE_STMT(CXXMemberCallExpr, {})
DEF_TRAVERSE_STMT(AddrLabelExpr, {})
DEF_TRAVERSE_STMT(ArraySubscriptExpr, {})
DEF_TRAVERSE_STMT(MatrixSubscriptExpr, {})
-DEF_TRAVERSE_STMT(OMPArraySectionExpr, {})
+DEF_TRAVERSE_STMT(ArraySectionExpr, {})
DEF_TRAVERSE_STMT(OMPArrayShapingExpr, {})
DEF_TRAVERSE_STMT(OMPIteratorExpr, {})
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a95424862e63f4..f435deeeb1886a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11163,7 +11163,7 @@ def err_omp_declare_mapper_redefinition : Error<
"redefinition of user-defined mapper for type %0 with name %1">;
def err_omp_invalid_mapper: Error<
"cannot find a valid user-defined mapper for type %0 with name %1">;
-def err_omp_array_section_use : Error<"OpenMP array section is not allowed here">;
+def err_array_section_use : Error<"array section is not allowed here">;
def err_omp_array_shaping_use : Error<"OpenMP array shaping operation is not allowed here">;
def err_omp_iterator_use : Error<"OpenMP iterator is not allowed here">;
def err_omp_typecheck_section_value : Error<
diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index b4e3ae573b95e6..305f19daa4a923 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -71,7 +71,7 @@ def OffsetOfExpr : StmtNode<Expr>;
def UnaryExprOrTypeTraitExpr : StmtNode<Expr>;
def ArraySubscriptExpr : StmtNode<Expr>;
def MatrixSubscriptExpr : StmtNode<Expr>;
-def OMPArraySectionExpr : StmtNode<Expr>;
+def ArraySectionExpr : StmtNode<Expr>;
def OMPIteratorExpr : StmtNode<Expr>;
def CallExpr : StmtNode<Expr>;
def MemberExpr : StmtNode<Expr>;
diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h
index ea28617f79b81b..da19503c2902fd 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -193,6 +193,12 @@ class SemaOpenACC : public SemaBase {
/// conversions and diagnostics to 'int'.
ExprResult ActOnIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
SourceLocation Loc, Expr *IntExpr);
+
+ /// Checks and creates an Array Section used in an OpenACC construct/clause.
+ ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
+ Expr *LowerBound,
+ SourceLocation ColonLocFirst, Expr *Length,
+ SourceLocation RBLoc);
};
} // namespace clang
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index 500098dd3dab1d..f433d7a32e401e 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -981,8 +981,8 @@ enum PredefinedTypeIDs {
/// OpenCL reserve_id type.
PREDEF_TYPE_RESERVE_ID_ID = 41,
- /// The placeholder type for OpenMP array section.
- PREDEF_TYPE_OMP_ARRAY_SECTION = 42,
+ /// The placeholder type for an array section.
+ PREDEF_TYPE_ARRAY_SECTION = 42,
/// The '__float128' type
PREDEF_TYPE_FLOAT128_ID = 43,
@@ -2002,7 +2002,7 @@ enum StmtCode {
STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE,
STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE,
STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE,
- EXPR_OMP_ARRAY_SECTION,
+ EXPR_ARRAY_SECTION,
EXPR_OMP_ARRAY_SHAPING,
EXPR_OMP_ITERATOR,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b974fc28283c77..3c2eaaf09acd23 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1320,16 +1320,14 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
// Placeholder type for OMP array sections.
if (LangOpts.OpenMP) {
- InitBuiltinType(OMPArraySectionTy, BuiltinType::OMPArraySection);
+ InitBuiltinType(ArraySectionTy, BuiltinType::ArraySection);
InitBuiltinType(OMPArrayShapingTy, BuiltinType::OMPArrayShaping);
InitBuiltinType(OMPIteratorTy, BuiltinType::OMPIterator);
}
- // Placeholder type for OpenACC array sections.
- if (LangOpts.OpenACC) {
- // FIXME: Once we implement OpenACC array sections in Sema, this will either
- // be combined with the OpenMP type, or given its own type. In the meantime,
- // just use the OpenMP type so that parsing can work.
- InitBuiltinType(OMPArraySectionTy, BuiltinType::OMPArraySection);
+ // Placeholder type for OpenACC array sections, if we are ALSO in OMP mode,
+ // don't bother, as we're just using the same type as OMP.
+ if (LangOpts.OpenACC && !LangOpts.OpenMP) {
+ InitBuiltinType(ArraySectionTy, BuiltinType::ArraySection);
}
if (LangOpts.MatrixTypes)
InitBuiltinType(IncompleteMatrixIdxTy, BuiltinType::IncompleteMatrixIdx);
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp
index 5ec3013fabba9a..bad8e75b2f878c 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -443,12 +443,17 @@ ExprDependence clang::computeDependence(ObjCIndirectCopyRestoreExpr *E) {
return E->getSubExpr()->getDependence();
}
-ExprDependence clang::computeDependence(OMPArraySectionExpr *E) {
+ExprDependence clang::computeDependence(ArraySectionExpr *E) {
auto D = E->getBase()->getDependence();
if (auto *LB = E->getLowerBound())
D |= LB->getDependence();
if (auto *Len = E->getLength())
D |= Len->getDependence();
+
+ if (E->isOMPArraySection()) {
+ if (auto *Stride = E->getStride())
+ D |= Stride->getDependence();
+ }
return D;
}
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 9eec7edc9d1a3e..63dcdb919c7117 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3680,7 +3680,7 @@ bool Expr::HasSideEffects(const ASTContext &Ctx,
case ParenExprClass:
case ArraySubscriptExprClass:
case MatrixSubscriptExprClass:
- case OMPArraySectionExprClass:
+ case ArraySectionExprClass:
case OMPArrayShapingExprClass:
case OMPIteratorExprClass:
case MemberExprClass:
@@ -5060,9 +5060,9 @@ QualType AtomicExpr::getValueType() const {
return T;
}
-QualType OMPArraySectionExpr::getBaseOriginalType(const Expr *Base) {
+QualType ArraySectionExpr::getBaseOriginalType(const Expr *Base) {
unsigned ArraySectionCount = 0;
- while (auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->IgnoreParens())) {
+ while (auto *OASE = dyn_cast<ArraySectionExpr>(Base->IgnoreParens())) {
Base = OASE->getBase();
++ArraySectionCount;
}
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index 7026fca8554ce9..2bb8f9aeedc7e2 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -145,7 +145,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
case Expr::FunctionParmPackExprClass:
case Expr::MSPropertyRefExprClass:
case Expr::MSPropertySubscriptExprClass:
- case Expr::OMPArraySectionExprClass:
+ case Expr::ArraySectionExprClass:
case Expr::OMPArrayShapingExprClass:
case Expr::OMPIteratorExprClass:
return Cl::CL_LValue;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 73ae8d8efb23a2..d68fd0156d899f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -16130,7 +16130,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
case Expr::StringLiteralClass:
case Expr::ArraySubscriptExprClass:
case Expr::MatrixSubscriptExprClass:
- case Expr::OMPArraySectionExprClass:
+ case Expr::ArraySectionExprClass:
case Expr::OMPArrayShapingExprClass:
case Expr::OMPIteratorExprClass:
case Expr::MemberExprClass:
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 106c69dd5beed7..ed9e6eeb36c75d 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -4715,7 +4715,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
case Expr::MSPropertySubscriptExprClass:
case Expr::TypoExprClass: // This should no longer exist in the AST by now.
case Expr::RecoveryExprClass:
- case Expr::OMPArraySectionExprClass:
+ case Expr::ArraySectionExprClass:
case Expr::OMPArrayShapingExprClass:
case Expr::OMPIteratorExprClass:
case Expr::CXXInheritedCtorInitExprClass:
diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp
index ecc56c13fb7573..6f586173edb021 100644
--- a/clang/lib/AST/NSAPI.cpp
+++ b/clang/lib/AST/NSAPI.cpp
@@ -462,7 +462,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
case BuiltinType::PseudoObject:
case BuiltinType::BuiltinFn:
case BuiltinType::IncompleteMatrixIdx:
- case BuiltinType::OMPArraySection:
+ case BuiltinType::ArraySection:
case BuiltinType::OMPArrayShaping:
case BuiltinType::OMPIterator:
case BuiltinType::BFloat16:
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 5855ab3141edcc..f010d36513a49e 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1521,7 +1521,7 @@ void StmtPrinter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *Node) {
OS << "]";
}
-void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
+void StmtPrinter::VisitArraySectionExpr(ArraySectionExpr *Node) {
PrintExpr(Node->getBase());
OS << "[";
if (Node->getLowerBound())
@@ -1531,7 +1531,7 @@ void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) {
if (Node->getLength())
PrintExpr(Node->getLength());
}
- if (Node->getColonLocSecond().isValid()) {
+ if (Node->isOMPArraySection() && Node->getColonLocSecond().isValid()) {
OS << ":";
if (Node->getStride())
PrintExpr(Node->getStride());
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index c81724f84dd9ce..a95f5c6103e24d 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1435,7 +1435,7 @@ void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) {
VisitExpr(S);
}
-void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
+void StmtProfiler::VisitArraySectionExpr(const ArraySectionExpr *S) {
VisitExpr(S);
}
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index cb22c91a12aa89..8aaa6801d85b8b 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3413,8 +3413,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
return "reserve_id_t";
case IncompleteMatrixIdx:
return "<incomplete matrix index type>";
- case OMPArraySection:
- return "<OpenMP array section type>";
+ case ArraySection:
+ return "<array section type>";
case OMPArrayShaping:
return "<OpenMP array shaping type>";
case OMPIterator:
@@ -4710,7 +4710,7 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
case BuiltinType::BuiltinFn:
case BuiltinType::NullPtr:
case BuiltinType::IncompleteMatrixIdx:
- case BuiltinType::OMPArraySection:
+ case BuiltinType::ArraySection:
case BuiltinType::OMPArrayShaping:
case BuiltinType::OMPIterator:
return false;
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index 21e152f6aea8a0..ce45b47d5cfea5 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -429,7 +429,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
#include "clang/Basic/WebAssemblyReferenceTypes.def"
case BuiltinType::BuiltinFn:
case BuiltinType::IncompleteMatrixIdx:
- case BuiltinType::OMPArraySection:
+ case BuiltinType::ArraySection:
case BuiltinType::OMPArrayShaping:
case BuiltinType::OMPIterator:
return TST_unspecified;
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 931cb391342ea2..7eb58d9fed33ee 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1621,8 +1621,8 @@ LValue CodeGenFunction::EmitLValueHelper(const Expr *E,
return EmitArraySubscriptExpr(cast<ArraySubscriptExpr>(E));
case Expr::MatrixSubscriptExprClass:
return EmitMatrixSubscriptExpr(cast<MatrixSubscriptExpr>(E));
- case Expr::OMPArraySectionExprClass:
- return EmitOMPArraySectionExpr(cast<OMPArraySectionExpr>(E));
+ case Expr::ArraySectionExprClass:
+ return EmitArraySectionExpr(cast<ArraySectionExpr>(E));
case Expr::ExtVectorElementExprClass:
return EmitExtVectorElementExpr(cast<ExtVectorElementExpr>(E));
case Expr::CXXThisExprClass:
@@ -4363,8 +4363,8 @@ static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
QualType BaseTy, QualType ElTy,
bool IsLowerBound) {
LValue BaseLVal;
- if (auto *ASE = dyn_cast<OMPArraySectionExpr>(Base->IgnoreParenImpCasts())) {
- BaseLVal = CGF.EmitOMPArraySectionExpr(ASE, IsLowerBound);
+ if (auto *ASE = dyn_cast<ArraySectionExpr>(Base->IgnoreParenImpCasts())) {
+ BaseLVal = CGF.EmitArraySectionExpr(ASE, IsLowerBound);
if (BaseTy->isArrayType()) {
Address Addr = BaseLVal.getAddress(CGF);
BaseInfo = BaseLVal.getBaseInfo();
@@ -4396,9 +4396,13 @@ static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
return CGF.EmitPointerWithAlignment(Base, &BaseInfo, &TBAAInfo);
}
-LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
+LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
bool IsLowerBound) {
- QualType BaseTy = OMPArraySectionExpr::getBaseOriginalType(E->getBase());
+
+ assert(!E->isOpenACCArraySection() &&
+ "OpenACC Array section codegen not implemented");
+
+ QualType BaseTy = ArraySectionExpr::getBaseOriginalType(E->getBase());
QualType ResultExprTy;
if (auto *AT = getContext().getAsArrayType(BaseTy))
ResultExprTy = AT->getElementType();
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 2ae11e129c75e4..790bec9bfc1b41 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -742,8 +742,8 @@ LValue ReductionCodeGen::emitSharedLValue(CodeGenFunction &CGF, const Expr *E) {
LValue ReductionCodeGen::emitSharedLValueUB(CodeGenFunction &CGF,
const Expr *E) {
- if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(E))
- return CGF.EmitOMPArraySectionExpr(OASE, /*IsLowerBound=*/false);
+ if (const auto *OASE = dyn_cast<ArraySectionExpr>(E))
+ return CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false);
return LValue();
}
@@ -800,7 +800,7 @@ void ReductionCodeGen::emitSharedOrigLValue(CodeGenFunction &CGF, unsigned N) {
void ReductionCodeGen::emitAggregateType(CodeGenFunction &CGF, unsigned N) {
QualType PrivateType = getPrivateType(N);
- bool AsArraySection = isa<OMPArraySectionExpr>(ClausesData[N].Ref);
+ bool AsArraySection = isa<ArraySectionExpr>(ClausesData[N].Ref);
if (!PrivateType->isVariablyModifiedType()) {
Sizes.emplace_back(
CGF.getTypeSize(OrigAddresses[N].first.getType().getNonReferenceType()),
@@ -941,9 +941,9 @@ static Address castToBase(CodeGenFunction &CGF, QualType BaseTy, QualType ElTy,
static const VarDecl *getBaseDecl(const Expr *Ref, const DeclRefExpr *&DE) {
const VarDecl *OrigVD = nullptr;
- if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(Ref)) {
+ if (const auto *OASE = dyn_cast<ArraySectionExpr>(Ref)) {
const Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
- while (const auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base))
+ while (const auto *TempOASE = dyn_cast<ArraySectionExpr>(Base))
Base = TempOASE->getBase()->IgnoreParenImpCasts();
while (const auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = TempASE->getBase()->IgnoreParenImpCasts();
@@ -3570,9 +3570,9 @@ getPointerAndSize(CodeGenFunction &CGF, const Expr *E) {
SizeVal = CGF.Builder.CreateNUWMul(SizeVal, Sz);
}
} else if (const auto *ASE =
- dyn_cast<OMPArraySectionExpr>(E->IgnoreParenImpCasts())) {
+ dyn_cast<ArraySectionExpr>(E->IgnoreParenImpCasts())) {
LValue UpAddrLVal =
- CGF.EmitOMPArraySectionExpr(ASE, /*IsLowerBound=*/false);
+ CGF.EmitArraySectionExpr(ASE, /*IsLowerBound=*/false);
Address UpAddrAddress = UpAddrLVal.getAddress(CGF);
llvm::Value *UpAddr = CGF.Builder.CreateConstGEP1_32(
UpAddrAddress.getElementType(), UpAddrAddress.emitRawPointer(CGF),
@@ -6672,8 +6672,8 @@ class MappableExprsHandler {
// Given that an array section is considered a built-in type, we need to
// do the calculation based on the length of the section instead of relying
// on CGF.getTypeSize(E->getType()).
- if (const auto *OAE = dyn_cast<OMPArraySectionExpr>(E)) {
- QualType BaseTy = OMPArraySectionExpr::getBaseOriginalType(
+ if (const auto *OAE = dyn_cast<ArraySectionExpr>(E)) {
+ QualType BaseTy = ArraySectionExpr::getBaseOriginalType(
OAE->getBase()->IgnoreParenImpCasts())
.getCanonicalType();
@@ -6779,7 +6779,7 @@ class MappableExprsHandler {
/// Return true if the provided expression is a final array section. A
/// final array section, is one whose length can't be proved to be one.
bool isFinalArraySectionExpression(const Expr *E) const {
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(E);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(E);
// It is not an array section and therefore not a unity-size one.
if (!OASE)
@@ -6795,7 +6795,7 @@ class MappableExprsHandler {
// for this dimension. Also, we should always expect a length if the
// base type is pointer.
if (!Length) {
- QualType BaseQTy = OMPArraySectionExpr::getBaseOriginalType(
+ QualType BaseQTy = ArraySectionExpr::getBaseOriginalType(
OASE->getBase()->IgnoreParenImpCasts())
.getCanonicalType();
if (const auto *ATy = dyn_cast<ConstantArrayType>(BaseQTy.getTypePtr()))
@@ -7027,7 +7027,7 @@ class MappableExprsHandler {
Address BP = Address::invalid();
const Expr *AssocExpr = I->getAssociatedExpression();
const auto *AE = dyn_cast<ArraySubscriptExpr>(AssocExpr);
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(AssocExpr);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(AssocExpr);
const auto *OAShE = dyn_cast<OMPArrayShapingExpr>(AssocExpr);
if (isa<MemberExpr>(AssocExpr)) {
@@ -7179,14 +7179,14 @@ class MappableExprsHandler {
// special treatment for array sections given that they are built-in
// types.
const auto *OASE =
- dyn_cast<OMPArraySectionExpr>(I->getAssociatedExpression());
+ dyn_cast<ArraySectionExpr>(I->getAssociatedExpression());
const auto *OAShE =
dyn_cast<OMPArrayShapingExpr>(I->getAssociatedExpression());
const auto *UO = dyn_cast<UnaryOperator>(I->getAssociatedExpression());
const auto *BO = dyn_cast<BinaryOperator>(I->getAssociatedExpression());
bool IsPointer =
OAShE ||
- (OASE && OMPArraySectionExpr::getBaseOriginalType(OASE)
+ (OASE && ArraySectionExpr::getBaseOriginalType(OASE)
.getCanonicalType()
->isAnyPointerType()) ||
I->getAssociatedExpression()->getType()->isAnyPointerType();
@@ -7207,7 +7207,7 @@ class MappableExprsHandler {
assert((Next == CE ||
isa<MemberExpr>(Next->getAssociatedExpression()) ||
isa<ArraySubscriptExpr>(Next->getAssociatedExpression()) ||
- isa<OMPArraySectionExpr>(Next->getAssociatedExpression()) ||
+ isa<ArraySectionExpr>(Next->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(Next->getAssociatedExpression()) ||
isa<UnaryOperator>(Next->getAssociatedExpression()) ||
isa<BinaryOperator>(Next->getAssociatedExpression())) &&
@@ -7439,7 +7439,7 @@ class MappableExprsHandler {
PartialStruct.LowestElem = {FieldIndex, LowestElem};
if (IsFinalArraySection) {
Address HB =
- CGF.EmitOMPArraySectionExpr(OASE, /*IsLowerBound=*/false)
+ CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
.getAddress(CGF);
PartialStruct.HighestElem = {FieldIndex, HB};
} else {
@@ -7452,7 +7452,7 @@ class MappableExprsHandler {
} else if (FieldIndex > PartialStruct.HighestElem.first) {
if (IsFinalArraySection) {
Address HB =
- CGF.EmitOMPArraySectionExpr(OASE, /*IsLowerBound=*/false)
+ CGF.EmitArraySectionExpr(OASE, /*IsLowerBound=*/false)
.getAddress(CGF);
PartialStruct.HighestElem = {FieldIndex, HB};
} else {
@@ -7510,12 +7510,12 @@ class MappableExprsHandler {
for (const OMPClauseMappableExprCommon::MappableComponent &Component :
Components) {
const Expr *AssocExpr = Component.getAssociatedExpression();
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(AssocExpr);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(AssocExpr);
if (!OASE)
continue;
- QualType Ty = OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
+ QualType Ty = ArraySectionExpr::getBaseOriginalType(OASE->getBase());
auto *CAT = Context.getAsConstantArrayType(Ty);
auto *VAT = Context.getAsVariableArrayType(Ty);
@@ -7589,7 +7589,7 @@ class MappableExprsHandler {
continue;
}
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(AssocExpr);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(AssocExpr);
if (!OASE)
continue;
@@ -8780,7 +8780,7 @@ static ValueDecl *getDeclFromThisExpr(const Expr *E) {
if (!E)
return nullptr;
- if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(E->IgnoreParenCasts()))
+ if (const auto *OASE = dyn_cast<ArraySectionExpr>(E->IgnoreParenCasts()))
if (const MemberExpr *ME =
dyn_cast<MemberExpr>(OASE->getBase()->IgnoreParenImpCasts()))
return ME->getMemberDecl();
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index eb716520e5ff56..87496c8e488c67 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -92,9 +92,9 @@ static const ValueDecl *getPrivateItem(const Expr *RefExpr) {
while (const auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = TempASE->getBase()->IgnoreParenImpCasts();
RefExpr = Base;
- } else if (auto *OASE = dyn_cast<OMPArraySectionExpr>(RefExpr)) {
+ } else if (auto *OASE = dyn_cast<ArraySectionExpr>(RefExpr)) {
const Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
- while (const auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base))
+ while (const auto *TempOASE = dyn_cast<ArraySectionExpr>(Base))
Base = TempOASE->getBase()->IgnoreParenImpCasts();
while (const auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = TempASE->getBase()->IgnoreParenImpCasts();
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index a0a8a07c76ba16..ef3aa3a8e0dc61 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1256,7 +1256,7 @@ void CodeGenFunction::EmitOMPReductionClauseInit(
const auto *LHSVD = cast<VarDecl>(cast<DeclRefExpr>(*ILHS)->getDecl());
const auto *RHSVD = cast<VarDecl>(cast<DeclRefExpr>(*IRHS)->getDecl());
QualType Type = PrivateVD->getType();
- bool isaOMPArraySectionExpr = isa<OMPArraySectionExpr>(IRef);
+ bool isaOMPArraySectionExpr = isa<ArraySectionExpr>(IRef);
if (isaOMPArraySectionExpr && Type->isVariablyModifiedType()) {
// Store the address of the original variable associated with the LHS
// implicit variable.
@@ -7289,7 +7289,7 @@ void CodeGenFunction::EmitOMPUseDevicePtrClause(
static const VarDecl *getBaseDecl(const Expr *Ref) {
const Expr *Base = Ref->IgnoreParenImpCasts();
- while (const auto *OASE = dyn_cast<OMPArraySectionExpr>(Base))
+ while (const auto *OASE = dyn_cast<ArraySectionExpr>(Base))
Base = OASE->getBase()->IgnoreParenImpCasts();
while (const auto *ASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = ASE->getBase()->IgnoreParenImpCasts();
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index ff1873325d409f..6ce3a21e08071e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4169,8 +4169,8 @@ class CodeGenFunction : public CodeGenTypeCache {
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
bool Accessed = false);
LValue EmitMatrixSubscriptExpr(const MatrixSubscriptExpr *E);
- LValue EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
- bool IsLowerBound = true);
+ LValue EmitArraySectionExpr(const ArraySectionExpr *E,
+ bool IsLowerBound = true);
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E);
LValue EmitMemberExpr(const MemberExpr *E);
LValue EmitObjCIsaExpr(const ObjCIsaExpr *E);
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 32d96f81c4c8de..7d6febb04a82c4 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -31,6 +31,7 @@
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaCUDA.h"
+#include "clang/Sema/SemaOpenACC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "clang/Sema/SemaSYCL.h"
#include "clang/Sema/TypoCorrection.h"
@@ -2070,15 +2071,22 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (!LHS.isInvalid() && !HasError && !Length.isInvalid() &&
!Stride.isInvalid() && Tok.is(tok::r_square)) {
if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) {
- // FIXME: OpenACC hasn't implemented Sema/Array section handling at a
- // semantic level yet. For now, just reuse the OpenMP implementation
- // as it gets the parsing/type management mostly right, and we can
- // replace this call to ActOnOpenACCArraySectionExpr in the future.
- // Eventually we'll genericize the OPenMPArraySectionExpr type as
- // well.
- LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
- LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
- ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(), RLoc);
+ // Like above, AllowOpenACCArraySections is 'more specific' and only
+ // enabled when actively parsing a 'var' in a 'var-list' during
+ // clause/'cache' construct parsing, so it is more specific. So we
+ // should do it first, so that the correct node gets created.
+ if (AllowOpenACCArraySections) {
+ assert(!Stride.isUsable() && !ColonLocSecond.isValid() &&
+ "Stride/second colon not allowed for OpenACC");
+ LHS = Actions.OpenACC().ActOnArraySectionExpr(
+ LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
+ ColonLocFirst, Length.get(), RLoc);
+ } else {
+ LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
+ LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
+ ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(),
+ RLoc);
+ }
} else {
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
ArgExprs, RLoc);
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2ef95741b3d637..7c3bbd3d29a7bc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -18711,8 +18711,10 @@ void Sema::CheckArrayAccess(const Expr *expr) {
expr = cast<MemberExpr>(expr)->getBase();
break;
}
- case Stmt::OMPArraySectionExprClass: {
- const OMPArraySectionExpr *ASE = cast<OMPArraySectionExpr>(expr);
+ case Stmt::ArraySectionExprClass: {
+ const ArraySectionExpr *ASE = cast<ArraySectionExpr>(expr);
+ // FIXME: We should probably be checking all of the elements to the
+ // 'length' here as well.
if (ASE->getLowerBound())
CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(),
/*ASE=*/nullptr, AllowOnePastEnd > 0);
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 00384f9dc16aa0..c9dd6bb2413e38 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -1314,7 +1314,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
// Some might be dependent for other reasons.
case Expr::ArraySubscriptExprClass:
case Expr::MatrixSubscriptExprClass:
- case Expr::OMPArraySectionExprClass:
+ case Expr::ArraySectionExprClass:
case Expr::OMPArrayShapingExprClass:
case Expr::OMPIteratorExprClass:
case Expr::BinaryOperatorClass:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 092da4a75dc310..597b6db19975eb 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5067,11 +5067,18 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base,
SourceLocation rbLoc) {
if (base && !base->getType().isNull() &&
- base->hasPlaceholderType(BuiltinType::OMPArraySection))
- return OpenMP().ActOnOMPArraySectionExpr(base, lbLoc, ArgExprs.front(),
- SourceLocation(), SourceLocation(),
- /*Length*/ nullptr,
- /*Stride=*/nullptr, rbLoc);
+ base->hasPlaceholderType(BuiltinType::ArraySection)) {
+ auto *AS = cast<ArraySectionExpr>(base);
+ if (AS->isOMPArraySection())
+ return OpenMP().ActOnOMPArraySectionExpr(
+ base, lbLoc, ArgExprs.front(), SourceLocation(), SourceLocation(),
+ /*Length*/ nullptr,
+ /*Stride=*/nullptr, rbLoc);
+
+ return OpenACC().ActOnArraySectionExpr(base, lbLoc, ArgExprs.front(),
+ SourceLocation(), /*Length*/ nullptr,
+ rbLoc);
+ }
// Since this might be a postfix expression, get rid of ParenListExprs.
if (isa<ParenListExpr>(base)) {
@@ -6359,7 +6366,7 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
case BuiltinType::BoundMember:
case BuiltinType::BuiltinFn:
case BuiltinType::IncompleteMatrixIdx:
- case BuiltinType::OMPArraySection:
+ case BuiltinType::ArraySection:
case BuiltinType::OMPArrayShaping:
case BuiltinType::OMPIterator:
return true;
@@ -21341,8 +21348,8 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
return ExprError();
// Expressions of unknown type.
- case BuiltinType::OMPArraySection:
- Diag(E->getBeginLoc(), diag::err_omp_array_section_use);
+ case BuiltinType::ArraySection:
+ Diag(E->getBeginLoc(), diag::err_array_section_use);
return ExprError();
// Expressions of unknown type.
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 793e16df178914..003a157990d307 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7753,9 +7753,9 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
break;
}
- case Stmt::OMPArraySectionExprClass: {
+ case Stmt::ArraySectionExprClass: {
visitLocalsRetainedByInitializer(Path,
- cast<OMPArraySectionExpr>(Init)->getBase(),
+ cast<ArraySectionExpr>(Init)->getBase(),
Visit, true, EnableLifetimeWarnings);
break;
}
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index ba69e71e30a181..baaee6cf519732 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -423,6 +423,22 @@ ExprResult SemaOpenACC::ActOnIntExpr(OpenACCDirectiveKind DK,
return IntExpr;
}
+ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
+ Expr *LowerBound,
+ SourceLocation ColonLoc,
+ Expr *Length,
+ SourceLocation RBLoc) {
+ ASTContext &Context = getASTContext();
+
+ // TODO OpenACC: We likely have to reproduce a lot of the same logic from the
+ // OMP version of this, but at the moment we don't have a good way to test it,
+ // so for now we'll just create the node.
+ return new (Context) ArraySectionExpr(
+ ArraySectionExpr::OpenACCArraySection, Base, LowerBound, Length,
+ /*Stride=*/nullptr, Context.ArraySectionTy, VK_LValue, OK_Ordinary,
+ ColonLoc, SourceLocation{}, RBLoc);
+}
+
bool SemaOpenACC::ActOnStartStmtDirective(OpenACCDirectiveKind K,
SourceLocation StartLoc) {
return diagnoseConstructAppertainment(*this, K, StartLoc, /*IsStmt=*/true);
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 5ba09926acf2b9..3c0e93627c4c89 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2230,7 +2230,7 @@ bool SemaOpenMP::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
dyn_cast<UnaryOperator>(Last->getAssociatedExpression());
if ((UO && UO->getOpcode() == UO_Deref) ||
isa<ArraySubscriptExpr>(Last->getAssociatedExpression()) ||
- isa<OMPArraySectionExpr>(Last->getAssociatedExpression()) ||
+ isa<ArraySectionExpr>(Last->getAssociatedExpression()) ||
isa<MemberExpr>(EI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(Last->getAssociatedExpression())) {
IsVariableAssociatedWithSection = true;
@@ -3884,7 +3884,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
MappableComponent &MC) {
return MC.getAssociatedDeclaration() ==
nullptr &&
- (isa<OMPArraySectionExpr>(
+ (isa<ArraySectionExpr>(
MC.getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(
MC.getAssociatedExpression()) ||
@@ -4062,7 +4062,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// Do both expressions have the same kind?
if (CCI->getAssociatedExpression()->getStmtClass() !=
SC.getAssociatedExpression()->getStmtClass())
- if (!((isa<OMPArraySectionExpr>(
+ if (!((isa<ArraySectionExpr>(
SC.getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(
SC.getAssociatedExpression())) &&
@@ -5428,9 +5428,9 @@ static std::pair<ValueDecl *, bool> getPrivateItem(Sema &S, Expr *&RefExpr,
Base = TempASE->getBase()->IgnoreParenImpCasts();
RefExpr = Base;
IsArrayExpr = ArraySubscript;
- } else if (auto *OASE = dyn_cast_or_null<OMPArraySectionExpr>(RefExpr)) {
+ } else if (auto *OASE = dyn_cast_or_null<ArraySectionExpr>(RefExpr)) {
Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
- while (auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base))
+ while (auto *TempOASE = dyn_cast<ArraySectionExpr>(Base))
Base = TempOASE->getBase()->IgnoreParenImpCasts();
while (auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = TempASE->getBase()->IgnoreParenImpCasts();
@@ -6060,10 +6060,10 @@ processImplicitMapsWithDefaultMappers(Sema &S, DSAStackTy *Stack,
// Array section - need to check for the mapping of the array section
// element.
QualType CanonType = E->getType().getCanonicalType();
- if (CanonType->isSpecificBuiltinType(BuiltinType::OMPArraySection)) {
- const auto *OASE = cast<OMPArraySectionExpr>(E->IgnoreParenImpCasts());
+ if (CanonType->isSpecificBuiltinType(BuiltinType::ArraySection)) {
+ const auto *OASE = cast<ArraySectionExpr>(E->IgnoreParenImpCasts());
QualType BaseType =
- OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
+ ArraySectionExpr::getBaseOriginalType(OASE->getBase());
QualType ElemType;
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
ElemType = ATy->getElementType();
@@ -19513,7 +19513,7 @@ struct ReductionData {
} // namespace
static bool checkOMPArraySectionConstantForReduction(
- ASTContext &Context, const OMPArraySectionExpr *OASE, bool &SingleElement,
+ ASTContext &Context, const ArraySectionExpr *OASE, bool &SingleElement,
SmallVectorImpl<llvm::APSInt> &ArraySizes) {
const Expr *Length = OASE->getLength();
if (Length == nullptr) {
@@ -19540,7 +19540,7 @@ static bool checkOMPArraySectionConstantForReduction(
// We require length = 1 for all array sections except the right-most to
// guarantee that the memory region is contiguous and has no holes in it.
- while (const auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base)) {
+ while (const auto *TempOASE = dyn_cast<ArraySectionExpr>(Base)) {
Length = TempOASE->getLength();
if (Length == nullptr) {
// For array sections of the form [1:] or [:], we would need to analyze
@@ -19745,12 +19745,12 @@ static bool actOnOMPReductionKindClause(
Expr *TaskgroupDescriptor = nullptr;
QualType Type;
auto *ASE = dyn_cast<ArraySubscriptExpr>(RefExpr->IgnoreParens());
- auto *OASE = dyn_cast<OMPArraySectionExpr>(RefExpr->IgnoreParens());
+ auto *OASE = dyn_cast<ArraySectionExpr>(RefExpr->IgnoreParens());
if (ASE) {
Type = ASE->getType().getNonReferenceType();
} else if (OASE) {
QualType BaseType =
- OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
+ ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
Type = ATy->getElementType();
else
@@ -21284,10 +21284,10 @@ OMPClause *SemaOpenMP::ActOnOpenMPDependClause(
// List items used in depend clauses cannot be zero-length array
// sections.
QualType ExprTy = RefExpr->getType().getNonReferenceType();
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(SimpleExpr);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(SimpleExpr);
if (OASE) {
QualType BaseType =
- OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
+ ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (BaseType.isNull())
return nullptr;
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
@@ -21346,7 +21346,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPDependClause(
Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf,
RefExpr->IgnoreParenImpCasts());
}
- if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr) &&
+ if (!Res.isUsable() && !isa<ArraySectionExpr>(SimpleExpr) &&
!isa<OMPArrayShapingExpr>(SimpleExpr)) {
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
<< (getLangOpts().OpenMP >= 50 ? 1 : 0)
@@ -21447,7 +21447,7 @@ static bool checkTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef,
static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef,
const Expr *E,
QualType BaseQTy) {
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(E);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(E);
// If this is an array subscript, it refers to the whole size if the size of
// the dimension is constant and equals 1. Also, an array section assumes the
@@ -21505,7 +21505,7 @@ static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef,
static bool checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef,
const Expr *E,
QualType BaseQTy) {
- const auto *OASE = dyn_cast<OMPArraySectionExpr>(E);
+ const auto *OASE = dyn_cast<ArraySectionExpr>(E);
// An array subscript always refer to a single element. Also, an array section
// assumes the format of an array subscript if no colon is used.
@@ -21720,14 +21720,14 @@ class MapBaseChecker final : public StmtVisitor<MapBaseChecker, bool> {
return RelevantExpr || Visit(E);
}
- bool VisitOMPArraySectionExpr(OMPArraySectionExpr *OASE) {
+ bool VisitArraySectionExpr(ArraySectionExpr *OASE) {
// After OMP 5.0 Array section in reduction clause will be implicitly
// mapped
assert(!(SemaRef.getLangOpts().OpenMP < 50 && NoDiagnose) &&
"Array sections cannot be implicitly mapped.");
Expr *E = OASE->getBase()->IgnoreParenImpCasts();
QualType CurType =
- OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+ ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
// If the type of a list item is a reference to a type T then the type
@@ -21900,7 +21900,7 @@ static const Expr *checkMapClauseExpressionBase(
auto CE = CurComponents.rend();
for (; CI != CE; ++CI) {
const auto *OASE =
- dyn_cast<OMPArraySectionExpr>(CI->getAssociatedExpression());
+ dyn_cast<ArraySectionExpr>(CI->getAssociatedExpression());
if (!OASE)
continue;
if (OASE && OASE->getLength())
@@ -21970,10 +21970,10 @@ static bool checkMapConflicts(
// variable in map clauses of the same construct.
if (CurrentRegionOnly &&
(isa<ArraySubscriptExpr>(CI->getAssociatedExpression()) ||
- isa<OMPArraySectionExpr>(CI->getAssociatedExpression()) ||
+ isa<ArraySectionExpr>(CI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(CI->getAssociatedExpression())) &&
(isa<ArraySubscriptExpr>(SI->getAssociatedExpression()) ||
- isa<OMPArraySectionExpr>(SI->getAssociatedExpression()) ||
+ isa<ArraySectionExpr>(SI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(SI->getAssociatedExpression()))) {
SemaRef.Diag(CI->getAssociatedExpression()->getExprLoc(),
diag::err_omp_multiple_array_items_in_map_clause)
@@ -22001,11 +22001,11 @@ static bool checkMapConflicts(
if (const auto *ASE =
dyn_cast<ArraySubscriptExpr>(SI->getAssociatedExpression())) {
Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
- } else if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(
+ } else if (const auto *OASE = dyn_cast<ArraySectionExpr>(
SI->getAssociatedExpression())) {
const Expr *E = OASE->getBase()->IgnoreParenImpCasts();
Type =
- OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+ ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
} else if (const auto *OASE = dyn_cast<OMPArrayShapingExpr>(
SI->getAssociatedExpression())) {
Type = OASE->getBase()->getType()->getPointeeType();
@@ -22480,13 +22480,13 @@ static void checkMappableExpressionList(
(void)I;
QualType Type;
auto *ASE = dyn_cast<ArraySubscriptExpr>(VE->IgnoreParens());
- auto *OASE = dyn_cast<OMPArraySectionExpr>(VE->IgnoreParens());
+ auto *OASE = dyn_cast<ArraySectionExpr>(VE->IgnoreParens());
auto *OAShE = dyn_cast<OMPArrayShapingExpr>(VE->IgnoreParens());
if (ASE) {
Type = ASE->getType().getNonReferenceType();
} else if (OASE) {
QualType BaseType =
- OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
+ ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
Type = ATy->getElementType();
else
@@ -23955,7 +23955,7 @@ SemaOpenMP::ActOnOpenMPUseDeviceAddrClause(ArrayRef<Expr *> VarList,
MVLI.VarBaseDeclarations.push_back(D);
MVLI.VarComponents.emplace_back();
Expr *Component = SimpleRefExpr;
- if (VD && (isa<OMPArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
+ if (VD && (isa<ArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
isa<ArraySubscriptExpr>(RefExpr->IgnoreParenImpCasts())))
Component =
SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
@@ -24105,7 +24105,7 @@ SemaOpenMP::ActOnOpenMPHasDeviceAddrClause(ArrayRef<Expr *> VarList,
// against other clauses later on.
Expr *Component = SimpleRefExpr;
auto *VD = dyn_cast<VarDecl>(D);
- if (VD && (isa<OMPArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
+ if (VD && (isa<ArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
isa<ArraySubscriptExpr>(RefExpr->IgnoreParenImpCasts())))
Component =
SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
@@ -24519,7 +24519,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPAffinityClause(
Sema::TentativeAnalysisScope Trap(SemaRef);
Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf, SimpleExpr);
}
- if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr) &&
+ if (!Res.isUsable() && !isa<ArraySectionExpr>(SimpleExpr) &&
!isa<OMPArrayShapingExpr>(SimpleExpr)) {
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
<< 1 << 0 << RefExpr->getSourceRange();
@@ -24632,7 +24632,7 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
Expr *Stride, SourceLocation RBLoc) {
ASTContext &Context = getASTContext();
if (Base->hasPlaceholderType() &&
- !Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
+ !Base->hasPlaceholderType(BuiltinType::ArraySection)) {
ExprResult Result = SemaRef.CheckPlaceholderExpr(Base);
if (Result.isInvalid())
return ExprError();
@@ -24672,13 +24672,13 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
(LowerBound->isTypeDependent() || LowerBound->isValueDependent())) ||
(Length && (Length->isTypeDependent() || Length->isValueDependent())) ||
(Stride && (Stride->isTypeDependent() || Stride->isValueDependent()))) {
- return new (Context) OMPArraySectionExpr(
- Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue,
+ return new (Context) ArraySectionExpr(
+ ArraySectionExpr::OMPArraySection, Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue,
OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}
// Perform default conversions.
- QualType OriginalTy = OMPArraySectionExpr::getBaseOriginalType(Base);
+ QualType OriginalTy = ArraySectionExpr::getBaseOriginalType(Base);
QualType ResultTy;
if (OriginalTy->isAnyPointerType()) {
ResultTy = OriginalTy->getPointeeType();
@@ -24801,15 +24801,16 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
}
}
- if (!Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
+ if (!Base->hasPlaceholderType(BuiltinType::ArraySection)) {
ExprResult Result = SemaRef.DefaultFunctionArrayLvalueConversion(Base);
if (Result.isInvalid())
return ExprError();
Base = Result.get();
}
- return new (Context) OMPArraySectionExpr(
- Base, LowerBound, Length, Stride, Context.OMPArraySectionTy, VK_LValue,
- OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
+ return new (Context)
+ ArraySectionExpr(ArraySectionExpr::OMPArraySection, Base, LowerBound,
+ Length, Stride, Context.ArraySectionTy, VK_LValue,
+ OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}
ExprResult SemaOpenMP::ActOnOMPArrayShapingExpr(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 9404be5a46f3f7..e38a41830bb901 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -2784,15 +2784,23 @@ class TreeTransform {
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc,
- Expr *LowerBound,
- SourceLocation ColonLocFirst,
- SourceLocation ColonLocSecond,
- Expr *Length, Expr *Stride,
- SourceLocation RBracketLoc) {
- return getSema().OpenMP().ActOnOMPArraySectionExpr(
- Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
- Stride, RBracketLoc);
+ ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base,
+ SourceLocation LBracketLoc,
+ Expr *LowerBound,
+ SourceLocation ColonLocFirst,
+ SourceLocation ColonLocSecond,
+ Expr *Length, Expr *Stride,
+ SourceLocation RBracketLoc) {
+ if (IsOMPArraySection)
+ return getSema().OpenMP().ActOnOMPArraySectionExpr(
+ Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
+ Stride, RBracketLoc);
+
+ assert(Stride == nullptr && !ColonLocSecond.isValid() &&
+ "Stride/second colon not allowed for OpenACC");
+
+ return getSema().OpenACC().ActOnArraySectionExpr(
+ Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
}
/// Build a new array shaping expression.
@@ -11742,7 +11750,7 @@ TreeTransform<Derived>::TransformMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
template <typename Derived>
ExprResult
-TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) {
+TreeTransform<Derived>::TransformArraySectionExpr(ArraySectionExpr *E) {
ExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return ExprError();
@@ -11762,20 +11770,25 @@ TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) {
}
ExprResult Stride;
- if (Expr *Str = E->getStride()) {
- Stride = getDerived().TransformExpr(Str);
- if (Stride.isInvalid())
- return ExprError();
+ if (E->isOMPArraySection()) {
+ if (Expr *Str = E->getStride()) {
+ Stride = getDerived().TransformExpr(Str);
+ if (Stride.isInvalid())
+ return ExprError();
+ }
}
if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
- LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
+ LowerBound.get() == E->getLowerBound() &&
+ Length.get() == E->getLength() &&
+ (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
return E;
- return getDerived().RebuildOMPArraySectionExpr(
- Base.get(), E->getBase()->getEndLoc(), LowerBound.get(),
- E->getColonLocFirst(), E->getColonLocSecond(), Length.get(), Stride.get(),
- E->getRBracketLoc());
+ return getDerived().RebuildArraySectionExpr(
+ E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
+ LowerBound.get(), E->getColonLocFirst(),
+ E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
+ Length.get(), Stride.get(), E->getRBracketLoc());
}
template <typename Derived>
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index f8d54c0c398906..e017f5bdb48858 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -261,8 +261,8 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
case BuiltinType::IncompleteMatrixIdx:
ID = PREDEF_TYPE_INCOMPLETE_MATRIX_IDX;
break;
- case BuiltinType::OMPArraySection:
- ID = PREDEF_TYPE_OMP_ARRAY_SECTION;
+ case BuiltinType::ArraySection:
+ ID = PREDEF_TYPE_ARRAY_SECTION;
break;
case BuiltinType::OMPArrayShaping:
ID = PREDEF_TYPE_OMP_ARRAY_SHAPING;
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d64925676df7b1..e7eaa3979af6c7 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7384,11 +7384,11 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_INCOMPLETE_MATRIX_IDX:
T = Context.IncompleteMatrixIdxTy;
break;
- case PREDEF_TYPE_OMP_ARRAY_SECTION:
- T = Context.OMPArraySectionTy;
+ case PREDEF_TYPE_ARRAY_SECTION:
+ T = Context.ArraySectionTy;
break;
case PREDEF_TYPE_OMP_ARRAY_SHAPING:
- T = Context.OMPArraySectionTy;
+ T = Context.OMPArrayShapingTy;
break;
case PREDEF_TYPE_OMP_ITERATOR:
T = Context.OMPIteratorTy;
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index baded0fe19831f..7d3930022a69c0 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -956,14 +956,22 @@ void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
E->setRBracketLoc(readSourceLocation());
}
-void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
+void ASTStmtReader::VisitArraySectionExpr(ArraySectionExpr *E) {
VisitExpr(E);
+ E->ASType = Record.readEnum<ArraySectionExpr::ArraySectionType>();
+
E->setBase(Record.readSubExpr());
E->setLowerBound(Record.readSubExpr());
E->setLength(Record.readSubExpr());
- E->setStride(Record.readSubExpr());
+
+ if (E->isOMPArraySection())
+ E->setStride(Record.readSubExpr());
+
E->setColonLocFirst(readSourceLocation());
- E->setColonLocSecond(readSourceLocation());
+
+ if (E->isOMPArraySection())
+ E->setColonLocSecond(readSourceLocation());
+
E->setRBracketLoc(readSourceLocation());
}
@@ -3090,8 +3098,8 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) MatrixSubscriptExpr(Empty);
break;
- case EXPR_OMP_ARRAY_SECTION:
- S = new (Context) OMPArraySectionExpr(Empty);
+ case EXPR_ARRAY_SECTION:
+ S = new (Context) ArraySectionExpr(Empty);
break;
case EXPR_OMP_ARRAY_SHAPING:
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index cd5f733baf76f4..39aec31b6d8790 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -880,16 +880,21 @@ void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
Code = serialization::EXPR_ARRAY_SUBSCRIPT;
}
-void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
+void ASTStmtWriter::VisitArraySectionExpr(ArraySectionExpr *E) {
VisitExpr(E);
+ Record.writeEnum(E->ASType);
Record.AddStmt(E->getBase());
Record.AddStmt(E->getLowerBound());
Record.AddStmt(E->getLength());
- Record.AddStmt(E->getStride());
+ if (E->isOMPArraySection())
+ Record.AddStmt(E->getStride());
Record.AddSourceLocation(E->getColonLocFirst());
- Record.AddSourceLocation(E->getColonLocSecond());
+
+ if (E->isOMPArraySection())
+ Record.AddSourceLocation(E->getColonLocSecond());
+
Record.AddSourceLocation(E->getRBracketLoc());
- Code = serialization::EXPR_OMP_ARRAY_SECTION;
+ Code = serialization::EXPR_ARRAY_SECTION;
}
void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
index a678c3827e7f12..1cebfbbee77dae 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -188,9 +188,9 @@ void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State,
os << DerefStr1;
break;
}
- case Stmt::OMPArraySectionExprClass: {
+ case Stmt::ArraySectionExprClass: {
os << "Array access";
- const OMPArraySectionExpr *AE = cast<OMPArraySectionExpr>(S);
+ const ArraySectionExpr *AE = cast<ArraySectionExpr>(S);
AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(),
State.get(), N->getLocationContext());
os << DerefStr1;
diff --git a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
index 1cf81b54e77d32..7ac34ef8164e4c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
@@ -350,7 +350,7 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
return false;
case Stmt::CallExprClass:
case Stmt::ArraySubscriptExprClass:
- case Stmt::OMPArraySectionExprClass:
+ case Stmt::ArraySectionExprClass:
case Stmt::OMPArrayShapingExprClass:
case Stmt::OMPIteratorExprClass:
case Stmt::ImplicitCastExprClass:
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 09c69f9612d96b..0b1edf3e5c96bf 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1948,7 +1948,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXPseudoDestructorExprClass:
case Stmt::SubstNonTypeTemplateParmExprClass:
case Stmt::CXXNullPtrLiteralExprClass:
- case Stmt::OMPArraySectionExprClass:
+ case Stmt::ArraySectionExprClass:
case Stmt::OMPArrayShapingExprClass:
case Stmt::OMPIteratorExprClass:
case Stmt::SYCLUniqueStableNameExprClass:
diff --git a/clang/test/OpenMP/target_depend_messages.cpp b/clang/test/OpenMP/target_depend_messages.cpp
index 68bbdc544880d3..df1a0ceaaf2b79 100644
--- a/clang/test/OpenMP/target_depend_messages.cpp
+++ b/clang/test/OpenMP/target_depend_messages.cpp
@@ -86,7 +86,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_enter_data_depend_messages.cpp b/clang/test/OpenMP/target_enter_data_depend_messages.cpp
index cecd535d26f2de..25fb6535ac73ec 100644
--- a/clang/test/OpenMP/target_enter_data_depend_messages.cpp
+++ b/clang/test/OpenMP/target_enter_data_depend_messages.cpp
@@ -82,7 +82,7 @@ int tmain(T argc, S **argv, R *env[]) {
foo();
#pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target enter data map(to: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
@@ -157,7 +157,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target enter data map(to: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_exit_data_depend_messages.cpp b/clang/test/OpenMP/target_exit_data_depend_messages.cpp
index 58a84d8bdcb4e7..99f468ccdffcac 100644
--- a/clang/test/OpenMP/target_exit_data_depend_messages.cpp
+++ b/clang/test/OpenMP/target_exit_data_depend_messages.cpp
@@ -82,7 +82,7 @@ int tmain(T argc, S **argv, R *env[]) {
foo();
#pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target exit data map(from: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
@@ -157,7 +157,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target exit data map(from: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp
index a6776ee12c0ee2..6a7a7cf1f74b19 100644
--- a/clang/test/OpenMP/target_map_messages.cpp
+++ b/clang/test/OpenMP/target_map_messages.cpp
@@ -234,7 +234,7 @@ struct SA {
{}
#pragma omp target map(always close: a) // expected-error {{missing map type}} omp52-error{{missing ',' after map type modifier}}
{}
- #pragma omp target map(always close bf: a) // omp52-error 2 {{missing ',' after map type modifier}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
+ #pragma omp target map(always close bf: a) // omp52-error 2 {{missing ',' after map type modifier}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
{}
// omp52-error at +4 {{missing ',' after map type modifier}}
// ge51-error at +3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
@@ -421,9 +421,9 @@ void SAclient(int arg) {
#pragma omp target map(r.ArrS[0].B)
{}
-#pragma omp target map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target map(r.ArrS[:1].B) // expected-error {{array section is not allowed here}}
{}
-#pragma omp target map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target map(r.ArrS[:arg].B) // expected-error {{array section is not allowed here}}
{}
#pragma omp target map(r.ArrS[0].Arr [1:23])
{}
@@ -473,9 +473,9 @@ void SAclient(int arg) {
{}
#pragma omp target map(r.Ptr [3:5])
{}
-#pragma omp target map(r.ArrS [3:5].A) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target map(r.ArrS [3:5].A) // expected-error {{array section is not allowed here}}
{}
-#pragma omp target map(r.ArrS [3:5].Arr [6:7]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target map(r.ArrS [3:5].Arr [6:7]) // expected-error {{array section is not allowed here}}
{}
#pragma omp target map(r.ArrS[3].Arr [6:7])
{}
diff --git a/clang/test/OpenMP/target_parallel_depend_messages.cpp b/clang/test/OpenMP/target_parallel_depend_messages.cpp
index cfee2a1b4ebc1a..7eab36d0c018cd 100644
--- a/clang/test/OpenMP/target_parallel_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_depend_messages.cpp
@@ -80,7 +80,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target parallel depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target parallel depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target parallel depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target parallel depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
index 9c099b3b599ac4..84fc01115934be 100644
--- a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target parallel for depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target parallel for depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
index c153b1ae48b4d9..301ac80860d244 100644
--- a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_simd_depend_messages.cpp b/clang/test/OpenMP/target_simd_depend_messages.cpp
index a74993ac3fac3e..20f29e969e6638 100644
--- a/clang/test/OpenMP/target_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_simd_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_depend_messages.cpp b/clang/test/OpenMP/target_teams_depend_messages.cpp
index 890ce835ef9e87..0345f277f2a059 100644
--- a/clang/test/OpenMP/target_teams_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_depend_messages.cpp
@@ -80,7 +80,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target teams depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
-#pragma omp target teams depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target teams depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
foo();
#pragma omp target teams depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
index 154dc164f097fb..ab1e8cb0519607 100644
--- a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
@@ -84,7 +84,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target teams distribute depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
index 2eeefc4f8abb06..030e8f5e6f0ed5 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
@@ -85,7 +85,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute parallel for depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target teams distribute parallel for depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
index 9df415c4729bea..9b3c1a36d3010c 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
@@ -85,7 +85,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target teams distribute parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
index d3aaf9981ce289..52c06f18d4a980 100644
--- a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
@@ -84,7 +84,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target teams distribute simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_map_messages.cpp b/clang/test/OpenMP/target_teams_map_messages.cpp
index 9da3e752f635ba..72fdc889557940 100644
--- a/clang/test/OpenMP/target_teams_map_messages.cpp
+++ b/clang/test/OpenMP/target_teams_map_messages.cpp
@@ -228,9 +228,9 @@ void SAclient(int arg) {
#pragma omp target teams map(r.ArrS[0].B)
{}
- #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{array section is not allowed here}}
{}
- #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{array section is not allowed here}}
{}
#pragma omp target teams map(r.ArrS[0].Arr[1:23])
{}
@@ -282,9 +282,9 @@ void SAclient(int arg) {
{}
#pragma omp target teams map(r.Ptr[3:5])
{}
- #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{array section is not allowed here}}
{}
- #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{array section is not allowed here}}
{}
#pragma omp target teams map(r.ArrS[3].Arr[6:7])
{}
diff --git a/clang/test/OpenMP/target_update_depend_messages.cpp b/clang/test/OpenMP/target_update_depend_messages.cpp
index 62264055f4188d..5d2e07be987194 100644
--- a/clang/test/OpenMP/target_update_depend_messages.cpp
+++ b/clang/test/OpenMP/target_update_depend_messages.cpp
@@ -58,7 +58,7 @@ int tmain(T argc, S **argv, R *env[]) {
#pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp target update to(z) depend(in : a [0:1]) // expected-error {{subscripted value is not an array or pointer}}
-#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{array section is not allowed here}}
#pragma omp target update to(z) depend(in : argv [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : env [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp target update to(z) depend(in : argv[:argc] [1:argc - 1])
@@ -105,7 +105,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp target update to(z) depend(in : a [0:1]) // expected-error {{subscripted value is not an array or pointer}}
-#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{array section is not allowed here}}
#pragma omp target update to(z) depend(in : argv [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : env [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp target update to(z) depend(in : argv[:argc] [1:argc - 1])
diff --git a/clang/test/OpenMP/target_update_from_messages.cpp b/clang/test/OpenMP/target_update_from_messages.cpp
index 02cd293c9a30a4..ac3a3e0492f7bd 100644
--- a/clang/test/OpenMP/target_update_from_messages.cpp
+++ b/clang/test/OpenMP/target_update_from_messages.cpp
@@ -128,8 +128,8 @@ T tmain(T argc) {
#pragma omp target update from(x, (m+1)[2]) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update from(s7.i, s7.a[:3])
#pragma omp target update from(s7.s6[1].aa[0:5])
-#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
-#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
#pragma omp target update from(s7.p[:10])
#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
@@ -184,8 +184,8 @@ int main(int argc, char **argv) {
#pragma omp target update from(x, (m+1)[2]) // // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update from(s7.i, s7.a[:3])
#pragma omp target update from(s7.s6[1].aa[0:5])
-#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
-#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
#pragma omp target update from(s7.p[:10])
#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
diff --git a/clang/test/OpenMP/target_update_to_messages.cpp b/clang/test/OpenMP/target_update_to_messages.cpp
index 33aaf3bb9028b5..5998b7778d0a87 100644
--- a/clang/test/OpenMP/target_update_to_messages.cpp
+++ b/clang/test/OpenMP/target_update_to_messages.cpp
@@ -133,8 +133,8 @@ T tmain(T argc) {
#pragma omp target update to(x, (m+1)[2]) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update to(s7.i, s7.a[:3])
#pragma omp target update to(s7.s6[1].aa[0:5])
-#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
-#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
#pragma omp target update to(s7.p[:10])
#pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}}
#pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
@@ -188,8 +188,8 @@ int main(int argc, char **argv) {
#pragma omp target update to(x, (m+1)[2]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update to(s7.i, s7.a[:3])
#pragma omp target update to(s7.s6[1].aa[0:5])
-#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
-#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
#pragma omp target update to(s7.p[:10])
#pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}}
#pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
diff --git a/clang/test/OpenMP/task_affinity_messages.cpp b/clang/test/OpenMP/task_affinity_messages.cpp
index aeaa963594b309..c323cc7801b3b2 100644
--- a/clang/test/OpenMP/task_affinity_messages.cpp
+++ b/clang/test/OpenMP/task_affinity_messages.cpp
@@ -46,7 +46,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp task affinity (argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task affinity (argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp task affinity(a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
#pragma omp task affinity(argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task affinity(env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp task affinity(argv[ : argc][1 : argc - 1])
diff --git a/clang/test/OpenMP/task_depend_messages.cpp b/clang/test/OpenMP/task_depend_messages.cpp
index 388595bef4de1b..6e2983d4a3af00 100644
--- a/clang/test/OpenMP/task_depend_messages.cpp
+++ b/clang/test/OpenMP/task_depend_messages.cpp
@@ -56,13 +56,13 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
#pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp task depend(in : argv[ : argc][1 : argc - 1])
#pragma omp task depend(in : arr[0])
#pragma omp task depend(depobj:argc) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not 'int'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not 'int'}}
- #pragma omp task depend(depobj : argv[ : argc][1 : argc - 1]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not '<OpenMP array section type>'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not '<OpenMP array section type>'}}
+ #pragma omp task depend(depobj : argv[ : argc][1 : argc - 1]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not '<array section type>'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not '<array section type>'}}
#pragma omp task depend(depobj : arr[0]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
#pragma omp task depend(in : ([ // expected-error {{expected variable name or 'this' in lambda capture list}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp task depend(in : ([] // expected-error {{expected body of lambda expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
diff --git a/clang/test/OpenMP/taskwait_depend_messages.cpp b/clang/test/OpenMP/taskwait_depend_messages.cpp
index 1c97618cae64e2..b05775ef799e60 100644
--- a/clang/test/OpenMP/taskwait_depend_messages.cpp
+++ b/clang/test/OpenMP/taskwait_depend_messages.cpp
@@ -53,7 +53,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp taskwait depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp taskwait depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp taskwait depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp taskwait depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
+ #pragma omp taskwait depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
#pragma omp taskwait depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp taskwait depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp taskwait depend(in : argv[ : argc][1 : argc - 1])
diff --git a/clang/test/ParserOpenACC/parse-cache-construct.cpp b/clang/test/ParserOpenACC/parse-cache-construct.cpp
index f0a35824696d8c..b2f25b13b1fd8d 100644
--- a/clang/test/ParserOpenACC/parse-cache-construct.cpp
+++ b/clang/test/ParserOpenACC/parse-cache-construct.cpp
@@ -74,12 +74,12 @@ void use() {
for (int i = 0; i < 10; ++i) {
// FIXME: Once we have a new array-section type to represent OpenACC as
// well, change this error message.
- // expected-error at +2{{OpenMP array section is not allowed here}}
+ // expected-error at +2{{array section is not allowed here}}
// expected-warning at +1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[1:4])
}
for (int i = 0; i < 10; ++i) {
- // expected-error at +2{{OpenMP array section is not allowed here}}
+ // expected-error at +2{{array section is not allowed here}}
// expected-warning at +1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[4])
}
diff --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c
index 799f22b8c120e5..1fe02a07fcede9 100644
--- a/clang/test/ParserOpenACC/parse-clauses.c
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -482,13 +482,13 @@ void VarListClauses() {
#pragma acc serial copy(HasMem.MemArr[3].array[1:4]), seq
for(;;){}
- // expected-error at +3{{OpenMP array section is not allowed here}}
+ // expected-error at +3{{array section is not allowed here}}
// expected-warning at +2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning at +1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1]), seq
for(;;){}
- // expected-error at +3{{OpenMP array section is not allowed here}}
+ // expected-error at +3{{array section is not allowed here}}
// expected-warning at +2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning at +1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1:2]), seq
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 74163f30e19b1d..398a11a5703558 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -5713,8 +5713,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("UnaryOperator");
case CXCursor_ArraySubscriptExpr:
return cxstring::createRef("ArraySubscriptExpr");
- case CXCursor_OMPArraySectionExpr:
- return cxstring::createRef("OMPArraySectionExpr");
+ case CXCursor_ArraySectionExpr:
+ return cxstring::createRef("ArraySectionExpr");
case CXCursor_OMPArrayShapingExpr:
return cxstring::createRef("OMPArrayShapingExpr");
case CXCursor_OMPIteratorExpr:
diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp
index 454bf754986189..9325a16d2a8486 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -423,8 +423,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
K = CXCursor_UnexposedExpr;
break;
- case Stmt::OMPArraySectionExprClass:
- K = CXCursor_OMPArraySectionExpr;
+ case Stmt::ArraySectionExprClass:
+ K = CXCursor_ArraySectionExpr;
break;
case Stmt::OMPArrayShapingExprClass:
>From 40e7dea0acf578a7ad3ac610fe590318c84a4ef8 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Wed, 24 Apr 2024 08:05:05 -0700
Subject: [PATCH 5/7] Clang-format
---
clang/include/clang/AST/Expr.h | 75 ++++++++++++++-------------
clang/lib/CodeGen/CGExpr.cpp | 2 +-
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 3 +-
clang/lib/Sema/SemaOpenMP.cpp | 10 ++--
4 files changed, 46 insertions(+), 44 deletions(-)
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d3d10c4f014f78..2fd1096c5ceb16 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6734,42 +6734,43 @@ class TypoExpr : public Expr {
class ArraySectionExpr : public Expr {
friend class ASTStmtReader;
friend class ASTStmtWriter;
- public:
- enum ArraySectionType { OMPArraySection, OpenACCArraySection};
- private:
- enum {
- BASE,
- LOWER_BOUND,
- LENGTH,
- STRIDE,
- END_EXPR,
- OPENACC_END_EXPR = STRIDE
- };
- ArraySectionType ASType;
- Stmt *SubExprs[END_EXPR] = {0};
- SourceLocation ColonLocFirst;
- SourceLocation ColonLocSecond;
- SourceLocation RBracketLoc;
+public:
+ enum ArraySectionType { OMPArraySection, OpenACCArraySection };
- public:
- ArraySectionExpr(ArraySectionType ASType, Expr *Base, Expr *LowerBound,
- Expr *Length, Expr *Stride, QualType Type,
- ExprValueKind VK, ExprObjectKind OK,
- SourceLocation ColonLocFirst,
- SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
- : Expr(ArraySectionExprClass, Type, VK, OK), ASType(ASType),
- ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
- RBracketLoc(RBracketLoc) {
- setBase(Base);
- setLowerBound(LowerBound);
- setLength(Length);
-
- assert((!isOpenACCArraySection() || Stride == nullptr) &&
- "Stride not valid on an OpenACC array section");
- if (ASType == OMPArraySection)
- setStride(Stride);
- setDependence(computeDependence(this));
+private:
+ enum {
+ BASE,
+ LOWER_BOUND,
+ LENGTH,
+ STRIDE,
+ END_EXPR,
+ OPENACC_END_EXPR = STRIDE
+ };
+
+ ArraySectionType ASType;
+ Stmt *SubExprs[END_EXPR] = {0};
+ SourceLocation ColonLocFirst;
+ SourceLocation ColonLocSecond;
+ SourceLocation RBracketLoc;
+
+public:
+ ArraySectionExpr(ArraySectionType ASType, Expr *Base, Expr *LowerBound,
+ Expr *Length, Expr *Stride, QualType Type, ExprValueKind VK,
+ ExprObjectKind OK, SourceLocation ColonLocFirst,
+ SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
+ : Expr(ArraySectionExprClass, Type, VK, OK), ASType(ASType),
+ ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
+ RBracketLoc(RBracketLoc) {
+ setBase(Base);
+ setLowerBound(LowerBound);
+ setLength(Length);
+
+ assert((!isOpenACCArraySection() || Stride == nullptr) &&
+ "Stride not valid on an OpenACC array section");
+ if (ASType == OMPArraySection)
+ setStride(Stride);
+ setDependence(computeDependence(this));
}
/// Create an empty array section expression.
explicit ArraySectionExpr(EmptyShell Shell)
@@ -6803,7 +6804,8 @@ class ArraySectionExpr : public Expr {
Expr *getStride() {
assert(ASType != OpenACCArraySection &&
"Stride not valid in OpenACC subarrays");
- return cast_or_null<Expr>(SubExprs[STRIDE]); }
+ return cast_or_null<Expr>(SubExprs[STRIDE]);
+ }
const Expr *getStride() const {
assert(ASType != OpenACCArraySection &&
@@ -6820,7 +6822,8 @@ class ArraySectionExpr : public Expr {
SourceLocation getColonLocSecond() const {
assert(ASType != OpenACCArraySection &&
"second colon for stride not valid in OpenACC subarrays");
- return ColonLocSecond; }
+ return ColonLocSecond;
+ }
SourceLocation getRBracketLoc() const { return RBracketLoc; }
SourceLocation getExprLoc() const LLVM_READONLY {
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 7eb58d9fed33ee..c94322f51e46cf 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4397,7 +4397,7 @@ static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
}
LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
- bool IsLowerBound) {
+ bool IsLowerBound) {
assert(!E->isOpenACCArraySection() &&
"OpenACC Array section codegen not implemented");
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 790bec9bfc1b41..e39c7c58d2780e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3571,8 +3571,7 @@ getPointerAndSize(CodeGenFunction &CGF, const Expr *E) {
}
} else if (const auto *ASE =
dyn_cast<ArraySectionExpr>(E->IgnoreParenImpCasts())) {
- LValue UpAddrLVal =
- CGF.EmitArraySectionExpr(ASE, /*IsLowerBound=*/false);
+ LValue UpAddrLVal = CGF.EmitArraySectionExpr(ASE, /*IsLowerBound=*/false);
Address UpAddrAddress = UpAddrLVal.getAddress(CGF);
llvm::Value *UpAddr = CGF.Builder.CreateConstGEP1_32(
UpAddrAddress.getElementType(), UpAddrAddress.emitRawPointer(CGF),
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3c0e93627c4c89..cbfdbac529010d 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -22004,8 +22004,7 @@ static bool checkMapConflicts(
} else if (const auto *OASE = dyn_cast<ArraySectionExpr>(
SI->getAssociatedExpression())) {
const Expr *E = OASE->getBase()->IgnoreParenImpCasts();
- Type =
- ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
+ Type = ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
} else if (const auto *OASE = dyn_cast<OMPArrayShapingExpr>(
SI->getAssociatedExpression())) {
Type = OASE->getBase()->getType()->getPointeeType();
@@ -24672,9 +24671,10 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
(LowerBound->isTypeDependent() || LowerBound->isValueDependent())) ||
(Length && (Length->isTypeDependent() || Length->isValueDependent())) ||
(Stride && (Stride->isTypeDependent() || Stride->isValueDependent()))) {
- return new (Context) ArraySectionExpr(
- ArraySectionExpr::OMPArraySection, Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue,
- OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
+ return new (Context)
+ ArraySectionExpr(ArraySectionExpr::OMPArraySection, Base, LowerBound,
+ Length, Stride, Context.DependentTy, VK_LValue,
+ OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}
// Perform default conversions.
>From 883b55640fcbdaba1f344fd9f6704be9f17f6057 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Wed, 24 Apr 2024 11:10:08 -0700
Subject: [PATCH 6/7] Do the requested changes to ArraySectionExpr, be more
specific on the error message
---
clang/include/clang/AST/Expr.h | 27 +++++++++++++------
.../clang/Basic/DiagnosticSemaKinds.td | 2 +-
clang/lib/Sema/SemaExpr.cpp | 3 ++-
clang/lib/Sema/SemaOpenACC.cpp | 7 +++--
clang/lib/Sema/SemaOpenMP.cpp | 14 +++++-----
clang/test/OpenMP/target_depend_messages.cpp | 2 +-
.../target_enter_data_depend_messages.cpp | 4 +--
.../target_exit_data_depend_messages.cpp | 4 +--
clang/test/OpenMP/target_map_messages.cpp | 10 +++----
.../target_parallel_depend_messages.cpp | 2 +-
.../target_parallel_for_depend_messages.cpp | 2 +-
...rget_parallel_for_simd_depend_messages.cpp | 2 +-
.../OpenMP/target_simd_depend_messages.cpp | 2 +-
.../OpenMP/target_teams_depend_messages.cpp | 2 +-
...arget_teams_distribute_depend_messages.cpp | 2 +-
...istribute_parallel_for_depend_messages.cpp | 2 +-
...bute_parallel_for_simd_depend_messages.cpp | 2 +-
..._teams_distribute_simd_depend_messages.cpp | 2 +-
.../test/OpenMP/target_teams_map_messages.cpp | 8 +++---
.../OpenMP/target_update_depend_messages.cpp | 4 +--
.../OpenMP/target_update_from_messages.cpp | 8 +++---
.../test/OpenMP/target_update_to_messages.cpp | 8 +++---
clang/test/OpenMP/task_affinity_messages.cpp | 2 +-
clang/test/OpenMP/task_depend_messages.cpp | 2 +-
.../test/OpenMP/taskwait_depend_messages.cpp | 2 +-
.../ParserOpenACC/parse-cache-construct.cpp | 4 +--
clang/test/ParserOpenACC/parse-clauses.c | 4 +--
27 files changed, 71 insertions(+), 62 deletions(-)
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 2fd1096c5ceb16..04c99a21f4f23e 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6748,30 +6748,41 @@ class ArraySectionExpr : public Expr {
OPENACC_END_EXPR = STRIDE
};
- ArraySectionType ASType;
- Stmt *SubExprs[END_EXPR] = {0};
+ ArraySectionType ASType = OMPArraySection;
+ Stmt *SubExprs[END_EXPR] = {nullptr};
SourceLocation ColonLocFirst;
SourceLocation ColonLocSecond;
SourceLocation RBracketLoc;
public:
- ArraySectionExpr(ArraySectionType ASType, Expr *Base, Expr *LowerBound,
+ // Constructor for OMP array sections, which include a 'stride'.
+ ArraySectionExpr(Expr *Base, Expr *LowerBound,
Expr *Length, Expr *Stride, QualType Type, ExprValueKind VK,
ExprObjectKind OK, SourceLocation ColonLocFirst,
SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
- : Expr(ArraySectionExprClass, Type, VK, OK), ASType(ASType),
+ : Expr(ArraySectionExprClass, Type, VK, OK), ASType(OMPArraySection),
ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
RBracketLoc(RBracketLoc) {
setBase(Base);
setLowerBound(LowerBound);
setLength(Length);
+ setStride(Stride);
+ setDependence(computeDependence(this));
+ }
- assert((!isOpenACCArraySection() || Stride == nullptr) &&
- "Stride not valid on an OpenACC array section");
- if (ASType == OMPArraySection)
- setStride(Stride);
+ // Constructor for OpenACC sub-arrays, which do not permit a 'stride'.
+ ArraySectionExpr(Expr *Base, Expr *LowerBound,
+ Expr *Length, QualType Type, ExprValueKind VK,
+ ExprObjectKind OK, SourceLocation ColonLoc,
+ SourceLocation RBracketLoc)
+ : Expr(ArraySectionExprClass, Type, VK, OK), ASType(OpenACCArraySection),
+ ColonLocFirst(ColonLoc), RBracketLoc(RBracketLoc) {
+ setBase(Base);
+ setLowerBound(LowerBound);
+ setLength(Length);
setDependence(computeDependence(this));
}
+
/// Create an empty array section expression.
explicit ArraySectionExpr(EmptyShell Shell)
: Expr(ArraySectionExprClass, Shell) {}
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f435deeeb1886a..1e72634d830da3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11163,7 +11163,7 @@ def err_omp_declare_mapper_redefinition : Error<
"redefinition of user-defined mapper for type %0 with name %1">;
def err_omp_invalid_mapper: Error<
"cannot find a valid user-defined mapper for type %0 with name %1">;
-def err_array_section_use : Error<"array section is not allowed here">;
+def err_array_section_use : Error<"%select{OpenACC sub-array|OpenMP array section}0 is not allowed here">;
def err_omp_array_shaping_use : Error<"OpenMP array shaping operation is not allowed here">;
def err_omp_iterator_use : Error<"OpenMP iterator is not allowed here">;
def err_omp_typecheck_section_value : Error<
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 597b6db19975eb..f3a1dffddeb392 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -21349,7 +21349,8 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
// Expressions of unknown type.
case BuiltinType::ArraySection:
- Diag(E->getBeginLoc(), diag::err_array_section_use);
+ Diag(E->getBeginLoc(), diag::err_array_section_use)
+ << cast<ArraySectionExpr>(E)->isOMPArraySection();
return ExprError();
// Expressions of unknown type.
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index baaee6cf519732..d5cfe82a5d7098 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -433,10 +433,9 @@ ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
// TODO OpenACC: We likely have to reproduce a lot of the same logic from the
// OMP version of this, but at the moment we don't have a good way to test it,
// so for now we'll just create the node.
- return new (Context) ArraySectionExpr(
- ArraySectionExpr::OpenACCArraySection, Base, LowerBound, Length,
- /*Stride=*/nullptr, Context.ArraySectionTy, VK_LValue, OK_Ordinary,
- ColonLoc, SourceLocation{}, RBLoc);
+ return new (Context)
+ ArraySectionExpr(Base, LowerBound, Length, Context.ArraySectionTy,
+ VK_LValue, OK_Ordinary, ColonLoc, RBLoc);
}
bool SemaOpenACC::ActOnStartStmtDirective(OpenACCDirectiveKind K,
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index cbfdbac529010d..cee8da495c5495 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -24671,10 +24671,9 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
(LowerBound->isTypeDependent() || LowerBound->isValueDependent())) ||
(Length && (Length->isTypeDependent() || Length->isValueDependent())) ||
(Stride && (Stride->isTypeDependent() || Stride->isValueDependent()))) {
- return new (Context)
- ArraySectionExpr(ArraySectionExpr::OMPArraySection, Base, LowerBound,
- Length, Stride, Context.DependentTy, VK_LValue,
- OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
+ return new (Context) ArraySectionExpr(
+ Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue,
+ OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}
// Perform default conversions.
@@ -24807,10 +24806,9 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
return ExprError();
Base = Result.get();
}
- return new (Context)
- ArraySectionExpr(ArraySectionExpr::OMPArraySection, Base, LowerBound,
- Length, Stride, Context.ArraySectionTy, VK_LValue,
- OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
+ return new (Context) ArraySectionExpr(
+ Base, LowerBound, Length, Stride, Context.ArraySectionTy, VK_LValue,
+ OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}
ExprResult SemaOpenMP::ActOnOMPArrayShapingExpr(
diff --git a/clang/test/OpenMP/target_depend_messages.cpp b/clang/test/OpenMP/target_depend_messages.cpp
index df1a0ceaaf2b79..68bbdc544880d3 100644
--- a/clang/test/OpenMP/target_depend_messages.cpp
+++ b/clang/test/OpenMP/target_depend_messages.cpp
@@ -86,7 +86,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_enter_data_depend_messages.cpp b/clang/test/OpenMP/target_enter_data_depend_messages.cpp
index 25fb6535ac73ec..cecd535d26f2de 100644
--- a/clang/test/OpenMP/target_enter_data_depend_messages.cpp
+++ b/clang/test/OpenMP/target_enter_data_depend_messages.cpp
@@ -82,7 +82,7 @@ int tmain(T argc, S **argv, R *env[]) {
foo();
#pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target enter data map(to: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
@@ -157,7 +157,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target enter data map(to: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target enter data map(to: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_exit_data_depend_messages.cpp b/clang/test/OpenMP/target_exit_data_depend_messages.cpp
index 99f468ccdffcac..58a84d8bdcb4e7 100644
--- a/clang/test/OpenMP/target_exit_data_depend_messages.cpp
+++ b/clang/test/OpenMP/target_exit_data_depend_messages.cpp
@@ -82,7 +82,7 @@ int tmain(T argc, S **argv, R *env[]) {
foo();
#pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target exit data map(from: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
@@ -157,7 +157,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target exit data map(from: i) depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target exit data map(from: i) depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp
index 6a7a7cf1f74b19..a6776ee12c0ee2 100644
--- a/clang/test/OpenMP/target_map_messages.cpp
+++ b/clang/test/OpenMP/target_map_messages.cpp
@@ -234,7 +234,7 @@ struct SA {
{}
#pragma omp target map(always close: a) // expected-error {{missing map type}} omp52-error{{missing ',' after map type modifier}}
{}
- #pragma omp target map(always close bf: a) // omp52-error 2 {{missing ',' after map type modifier}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
+ #pragma omp target map(always close bf: a) // omp52-error 2 {{missing ',' after map type modifier}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
{}
// omp52-error at +4 {{missing ',' after map type modifier}}
// ge51-error at +3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
@@ -421,9 +421,9 @@ void SAclient(int arg) {
#pragma omp target map(r.ArrS[0].B)
{}
-#pragma omp target map(r.ArrS[:1].B) // expected-error {{array section is not allowed here}}
+#pragma omp target map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
{}
-#pragma omp target map(r.ArrS[:arg].B) // expected-error {{array section is not allowed here}}
+#pragma omp target map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
{}
#pragma omp target map(r.ArrS[0].Arr [1:23])
{}
@@ -473,9 +473,9 @@ void SAclient(int arg) {
{}
#pragma omp target map(r.Ptr [3:5])
{}
-#pragma omp target map(r.ArrS [3:5].A) // expected-error {{array section is not allowed here}}
+#pragma omp target map(r.ArrS [3:5].A) // expected-error {{OpenMP array section is not allowed here}}
{}
-#pragma omp target map(r.ArrS [3:5].Arr [6:7]) // expected-error {{array section is not allowed here}}
+#pragma omp target map(r.ArrS [3:5].Arr [6:7]) // expected-error {{OpenMP array section is not allowed here}}
{}
#pragma omp target map(r.ArrS[3].Arr [6:7])
{}
diff --git a/clang/test/OpenMP/target_parallel_depend_messages.cpp b/clang/test/OpenMP/target_parallel_depend_messages.cpp
index 7eab36d0c018cd..cfee2a1b4ebc1a 100644
--- a/clang/test/OpenMP/target_parallel_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_depend_messages.cpp
@@ -80,7 +80,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target parallel depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
- #pragma omp target parallel depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target parallel depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target parallel depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
index 84fc01115934be..9c099b3b599ac4 100644
--- a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target parallel for depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target parallel for depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
index 301ac80860d244..c153b1ae48b4d9 100644
--- a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target parallel for simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_simd_depend_messages.cpp b/clang/test/OpenMP/target_simd_depend_messages.cpp
index 20f29e969e6638..a74993ac3fac3e 100644
--- a/clang/test/OpenMP/target_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_simd_depend_messages.cpp
@@ -88,7 +88,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
- #pragma omp target simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp target simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_depend_messages.cpp b/clang/test/OpenMP/target_teams_depend_messages.cpp
index 0345f277f2a059..890ce835ef9e87 100644
--- a/clang/test/OpenMP/target_teams_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_depend_messages.cpp
@@ -80,7 +80,7 @@ int main(int argc, char **argv, char *env[]) {
foo();
#pragma omp target teams depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
foo();
-#pragma omp target teams depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target teams depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
foo();
#pragma omp target teams depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
index ab1e8cb0519607..154dc164f097fb 100644
--- a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
@@ -84,7 +84,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target teams distribute depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
index 030e8f5e6f0ed5..2eeefc4f8abb06 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
@@ -85,7 +85,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute parallel for depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target teams distribute parallel for depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
index 9b3c1a36d3010c..9df415c4729bea 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
@@ -85,7 +85,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target teams distribute parallel for simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute parallel for simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
index 52c06f18d4a980..d3aaf9981ce289 100644
--- a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
@@ -84,7 +84,7 @@ int main(int argc, char **argv, char *env[]) {
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute simd depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target teams distribute simd depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
for (i = 0; i < argc; ++i) foo();
#pragma omp target teams distribute simd depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
for (i = 0; i < argc; ++i) foo();
diff --git a/clang/test/OpenMP/target_teams_map_messages.cpp b/clang/test/OpenMP/target_teams_map_messages.cpp
index 72fdc889557940..9da3e752f635ba 100644
--- a/clang/test/OpenMP/target_teams_map_messages.cpp
+++ b/clang/test/OpenMP/target_teams_map_messages.cpp
@@ -228,9 +228,9 @@ void SAclient(int arg) {
#pragma omp target teams map(r.ArrS[0].B)
{}
- #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
{}
- #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
{}
#pragma omp target teams map(r.ArrS[0].Arr[1:23])
{}
@@ -282,9 +282,9 @@ void SAclient(int arg) {
{}
#pragma omp target teams map(r.Ptr[3:5])
{}
- #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{OpenMP array section is not allowed here}}
{}
- #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{array section is not allowed here}}
+ #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{OpenMP array section is not allowed here}}
{}
#pragma omp target teams map(r.ArrS[3].Arr[6:7])
{}
diff --git a/clang/test/OpenMP/target_update_depend_messages.cpp b/clang/test/OpenMP/target_update_depend_messages.cpp
index 5d2e07be987194..62264055f4188d 100644
--- a/clang/test/OpenMP/target_update_depend_messages.cpp
+++ b/clang/test/OpenMP/target_update_depend_messages.cpp
@@ -58,7 +58,7 @@ int tmain(T argc, S **argv, R *env[]) {
#pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp target update to(z) depend(in : a [0:1]) // expected-error {{subscripted value is not an array or pointer}}
-#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update to(z) depend(in : argv [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : env [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp target update to(z) depend(in : argv[:argc] [1:argc - 1])
@@ -105,7 +105,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp target update to(z) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp target update to(z) depend(in : a [0:1]) // expected-error {{subscripted value is not an array or pointer}}
-#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(z) depend(in : argv [argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update to(z) depend(in : argv [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp target update to(z) depend(in : env [0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp target update to(z) depend(in : argv[:argc] [1:argc - 1])
diff --git a/clang/test/OpenMP/target_update_from_messages.cpp b/clang/test/OpenMP/target_update_from_messages.cpp
index ac3a3e0492f7bd..02cd293c9a30a4 100644
--- a/clang/test/OpenMP/target_update_from_messages.cpp
+++ b/clang/test/OpenMP/target_update_from_messages.cpp
@@ -128,8 +128,8 @@ T tmain(T argc) {
#pragma omp target update from(x, (m+1)[2]) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update from(s7.i, s7.a[:3])
#pragma omp target update from(s7.s6[1].aa[0:5])
-#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
-#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update from(s7.p[:10])
#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
@@ -184,8 +184,8 @@ int main(int argc, char **argv) {
#pragma omp target update from(x, (m+1)[2]) // // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update from(s7.i, s7.a[:3])
#pragma omp target update from(s7.s6[1].aa[0:5])
-#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
-#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update from(s7.p[:10])
#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
diff --git a/clang/test/OpenMP/target_update_to_messages.cpp b/clang/test/OpenMP/target_update_to_messages.cpp
index 5998b7778d0a87..33aaf3bb9028b5 100644
--- a/clang/test/OpenMP/target_update_to_messages.cpp
+++ b/clang/test/OpenMP/target_update_to_messages.cpp
@@ -133,8 +133,8 @@ T tmain(T argc) {
#pragma omp target update to(x, (m+1)[2]) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update to(s7.i, s7.a[:3])
#pragma omp target update to(s7.s6[1].aa[0:5])
-#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
-#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update to(s7.p[:10])
#pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}}
#pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
@@ -188,8 +188,8 @@ int main(int argc, char **argv) {
#pragma omp target update to(x, (m+1)[2]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}}
#pragma omp target update to(s7.i, s7.a[:3])
#pragma omp target update to(s7.s6[1].aa[0:5])
-#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{array section is not allowed here}}
-#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
+#pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp target update to(s7.p[:10])
#pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}}
#pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
diff --git a/clang/test/OpenMP/task_affinity_messages.cpp b/clang/test/OpenMP/task_affinity_messages.cpp
index c323cc7801b3b2..aeaa963594b309 100644
--- a/clang/test/OpenMP/task_affinity_messages.cpp
+++ b/clang/test/OpenMP/task_affinity_messages.cpp
@@ -46,7 +46,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp task affinity (argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task affinity (argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp task affinity(a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp task affinity(argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp task affinity(argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task affinity(env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp task affinity(argv[ : argc][1 : argc - 1])
diff --git a/clang/test/OpenMP/task_depend_messages.cpp b/clang/test/OpenMP/task_depend_messages.cpp
index 6e2983d4a3af00..3f39c55527b5d4 100644
--- a/clang/test/OpenMP/task_depend_messages.cpp
+++ b/clang/test/OpenMP/task_depend_messages.cpp
@@ -56,7 +56,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp task depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp task depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp task depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp task depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp task depend(in : argv[ : argc][1 : argc - 1])
diff --git a/clang/test/OpenMP/taskwait_depend_messages.cpp b/clang/test/OpenMP/taskwait_depend_messages.cpp
index b05775ef799e60..1c97618cae64e2 100644
--- a/clang/test/OpenMP/taskwait_depend_messages.cpp
+++ b/clang/test/OpenMP/taskwait_depend_messages.cpp
@@ -53,7 +53,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp taskwait depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp taskwait depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
#pragma omp taskwait depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}}
- #pragma omp taskwait depend(in:argv[argv[:2]:1]) // expected-error {{array section is not allowed here}}
+ #pragma omp taskwait depend(in:argv[argv[:2]:1]) // expected-error {{OpenMP array section is not allowed here}}
#pragma omp taskwait depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
#pragma omp taskwait depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
#pragma omp taskwait depend(in : argv[ : argc][1 : argc - 1])
diff --git a/clang/test/ParserOpenACC/parse-cache-construct.cpp b/clang/test/ParserOpenACC/parse-cache-construct.cpp
index b2f25b13b1fd8d..1ab2153a68be8d 100644
--- a/clang/test/ParserOpenACC/parse-cache-construct.cpp
+++ b/clang/test/ParserOpenACC/parse-cache-construct.cpp
@@ -74,12 +74,12 @@ void use() {
for (int i = 0; i < 10; ++i) {
// FIXME: Once we have a new array-section type to represent OpenACC as
// well, change this error message.
- // expected-error at +2{{array section is not allowed here}}
+ // expected-error at +2{{OpenACC sub-array is not allowed here}}
// expected-warning at +1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[1:4])
}
for (int i = 0; i < 10; ++i) {
- // expected-error at +2{{array section is not allowed here}}
+ // expected-error at +2{{OpenACC sub-array is not allowed here}}
// expected-warning at +1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[4])
}
diff --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c
index 1fe02a07fcede9..ee2cb2d1501dea 100644
--- a/clang/test/ParserOpenACC/parse-clauses.c
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -482,13 +482,13 @@ void VarListClauses() {
#pragma acc serial copy(HasMem.MemArr[3].array[1:4]), seq
for(;;){}
- // expected-error at +3{{array section is not allowed here}}
+ // expected-error at +3{{OpenACC sub-array is not allowed here}}
// expected-warning at +2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning at +1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1]), seq
for(;;){}
- // expected-error at +3{{array section is not allowed here}}
+ // expected-error at +3{{OpenACC sub-array is not allowed here}}
// expected-warning at +2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning at +1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1:2]), seq
>From bac62f398b082b7f220b927718354dffe47f2fd3 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Wed, 24 Apr 2024 11:53:16 -0700
Subject: [PATCH 7/7] Clang-format
---
clang/include/clang/AST/Expr.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 04c99a21f4f23e..f2bf667636dc9b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6756,10 +6756,10 @@ class ArraySectionExpr : public Expr {
public:
// Constructor for OMP array sections, which include a 'stride'.
- ArraySectionExpr(Expr *Base, Expr *LowerBound,
- Expr *Length, Expr *Stride, QualType Type, ExprValueKind VK,
- ExprObjectKind OK, SourceLocation ColonLocFirst,
- SourceLocation ColonLocSecond, SourceLocation RBracketLoc)
+ ArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride,
+ QualType Type, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation ColonLocFirst, SourceLocation ColonLocSecond,
+ SourceLocation RBracketLoc)
: Expr(ArraySectionExprClass, Type, VK, OK), ASType(OMPArraySection),
ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond),
RBracketLoc(RBracketLoc) {
@@ -6771,9 +6771,8 @@ class ArraySectionExpr : public Expr {
}
// Constructor for OpenACC sub-arrays, which do not permit a 'stride'.
- ArraySectionExpr(Expr *Base, Expr *LowerBound,
- Expr *Length, QualType Type, ExprValueKind VK,
- ExprObjectKind OK, SourceLocation ColonLoc,
+ ArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type,
+ ExprValueKind VK, ExprObjectKind OK, SourceLocation ColonLoc,
SourceLocation RBracketLoc)
: Expr(ArraySectionExprClass, Type, VK, OK), ASType(OpenACCArraySection),
ColonLocFirst(ColonLoc), RBracketLoc(RBracketLoc) {
More information about the cfe-commits
mailing list