aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaAccess.cpp
diff options
context:
space:
mode:
authorCorentin Jabot <corentin.jabot@gmail.com>2022-02-08 12:09:03 -0500
committerAaron Ballman <aaron@aaronballman.com>2022-02-08 12:10:47 -0500
commitc1512250960bd247519a9f959ad4af202402dcc4 (patch)
tree777da02df015fac62ce35deab5ab0c6250d6904f /clang/lib/Sema/SemaAccess.cpp
parentcaf7f05c1c7320fe29c2ec4ebecac91a5c970633 (diff)
downloadllvm-c1512250960bd247519a9f959ad4af202402dcc4.zip
llvm-c1512250960bd247519a9f959ad4af202402dcc4.tar.gz
llvm-c1512250960bd247519a9f959ad4af202402dcc4.tar.bz2
[C++2b] Implement multidimentional subscript operator
Implement P2128R6 in C++23 mode. Unlike GCC's implementation, this doesn't try to recover when a user meant to use a comma expression. Because the syntax changes meaning in C++23, the patch is *NOT* implemented as an extension. Instead, declaring an array with not exactly 1 parameter is an error in older languages modes. There is an off-by-default extension warning in C++23 mode. Unlike the standard, we supports default arguments; Ie, we assume, based on conversations in WG21, that the proposed resolution to CWG2507 will be accepted. We allow arrays OpenMP sections and C++23 multidimensional array to coexist: [a , b] multi dimensional array [a : b] open mp section [a, b: c] // error The rest of the patch is relatively straight forward: we take care to support an arbitrary number of arguments everywhere.
Diffstat (limited to 'clang/lib/Sema/SemaAccess.cpp')
-rw-r--r--clang/lib/Sema/SemaAccess.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index 3f7b387..00d3efd 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -1761,14 +1761,11 @@ Sema::CheckStructuredBindingMemberAccess(SourceLocation UseLoc,
return CheckAccess(*this, UseLoc, Entity);
}
-/// Checks access to an overloaded member operator, including
-/// conversion operators.
Sema::AccessResult Sema::CheckMemberOperatorAccess(SourceLocation OpLoc,
Expr *ObjectExpr,
- Expr *ArgExpr,
+ const SourceRange &Range,
DeclAccessPair Found) {
- if (!getLangOpts().AccessControl ||
- Found.getAccess() == AS_public)
+ if (!getLangOpts().AccessControl || Found.getAccess() == AS_public)
return AR_accessible;
const RecordType *RT = ObjectExpr->getType()->castAs<RecordType>();
@@ -1776,13 +1773,35 @@ Sema::AccessResult Sema::CheckMemberOperatorAccess(SourceLocation OpLoc,
AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
ObjectExpr->getType());
- Entity.setDiag(diag::err_access)
- << ObjectExpr->getSourceRange()
- << (ArgExpr ? ArgExpr->getSourceRange() : SourceRange());
+ Entity.setDiag(diag::err_access) << ObjectExpr->getSourceRange() << Range;
return CheckAccess(*this, OpLoc, Entity);
}
+/// Checks access to an overloaded member operator, including
+/// conversion operators.
+Sema::AccessResult Sema::CheckMemberOperatorAccess(SourceLocation OpLoc,
+ Expr *ObjectExpr,
+ Expr *ArgExpr,
+ DeclAccessPair Found) {
+ return CheckMemberOperatorAccess(
+ OpLoc, ObjectExpr, ArgExpr ? ArgExpr->getSourceRange() : SourceRange(),
+ Found);
+}
+
+Sema::AccessResult Sema::CheckMemberOperatorAccess(SourceLocation OpLoc,
+ Expr *ObjectExpr,
+ ArrayRef<Expr *> ArgExprs,
+ DeclAccessPair FoundDecl) {
+ SourceRange R;
+ if (!ArgExprs.empty()) {
+ R = SourceRange(ArgExprs.front()->getBeginLoc(),
+ ArgExprs.back()->getEndLoc());
+ }
+
+ return CheckMemberOperatorAccess(OpLoc, ObjectExpr, R, FoundDecl);
+}
+
/// Checks access to the target of a friend declaration.
Sema::AccessResult Sema::CheckFriendAccess(NamedDecl *target) {
assert(isa<CXXMethodDecl>(target->getAsFunction()));