DiagGroup<"c++11-compat-deprecated-writable-strings">;
def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
+def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
[CXX11CompatDeprecatedWritableStr]>;
// FIXME: Why is DeprecatedImplementations not in this group?
def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
+ DeprecatedCommaSubscript,
DeprecatedDeclarations,
DeprecatedDynamicExceptionSpec,
DeprecatedIncrementBool,
"arithmetic on pointer to interface %0, which is not a constant size for "
"this architecture and platform">;
+def warn_deprecated_comma_subscript : Warning<
+ "top-level comma expression in array subscript is deprecated">,
+ InGroup<DeprecatedCommaSubscript>;
def ext_subscript_non_lvalue : Extension<
"ISO C90 does not allow subscripting non-lvalue array">;
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
// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++17 %s -Wdeprecated -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++2a %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
}
#endif
+struct X {
+ friend int operator,(X, X);
+ void operator[](int);
+};
+void array_index_comma() {
+ int arr[123];
+ (void)arr[(void)1, 2];
+ (void)arr[X(), X()];
+ X()[(void)1, 2];
+ X()[X(), X()];
+#if __cplusplus > 201703L
+ // expected-warning@-5 {{deprecated}}
+ // expected-warning@-5 {{deprecated}}
+ // expected-warning@-5 {{deprecated}}
+ // expected-warning@-5 {{deprecated}}
+#endif
+
+ (void)arr[((void)1, 2)];
+ (void)arr[(X(), X())];
+ (void)((void)1,2)[arr];
+ (void)(X(), X())[arr];
+ X()[((void)1, 2)];
+ X()[(X(), X())];
+}
+
# 1 "/usr/include/system-header.h" 1 3
void system_header_function(void) throw();
<tr>
<td>Deprecate <tt>a[b,c]</tt></td>
<td><a href="http://wg21.link/p1161r3">P1161R3</a></td>
- <td class="none" align="center">No</td>
+ <td class="svn" align="center">SVN</td>
</tr>
<tr>
<td>Deprecate some problematic uses of <tt>volatile</tt></td>