diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-07-20 09:32:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-07-20 09:32:27 +0000 |
commit | 6a3820503910cd839b8f7c2bdb22601d25c4356a (patch) | |
tree | 1e6b26ebfcde6af49235b8547aa81089ef481cc6 /clang/lib/Sema/SemaExpr.cpp | |
parent | 7017a6d3a3f44f4c0302a34b026d190f1e69a704 (diff) | |
download | bcm5719-llvm-6a3820503910cd839b8f7c2bdb22601d25c4356a.tar.gz bcm5719-llvm-6a3820503910cd839b8f7c2bdb22601d25c4356a.zip |
[c++20] P1161R3: a[b,c] is deprecated.
llvm-svn: 366630
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d8869ffe945..401bb3c000b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4317,6 +4317,15 @@ Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc, base = result.get(); } + // A comma-expression as the index is deprecated in C++2a onwards. + if (getLangOpts().CPlusPlus2a && + ((isa<BinaryOperator>(idx) && cast<BinaryOperator>(idx)->isCommaOp()) || + (isa<CXXOperatorCallExpr>(idx) && + cast<CXXOperatorCallExpr>(idx)->getOperator() == OO_Comma))) { + Diag(idx->getExprLoc(), diag::warn_deprecated_comma_subscript) + << SourceRange(base->getBeginLoc(), rbLoc); + } + // Handle any non-overload placeholder types in the base and index // expressions. We can't handle overloads here because the other // operand might be an overloadable type, in which case the overload |