parent
7017a6d3a3
commit
6a38205039
|
@ -118,6 +118,7 @@ def CXX11CompatDeprecatedWritableStr :
|
|||
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">;
|
||||
|
@ -135,6 +136,7 @@ def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings",
|
|||
[CXX11CompatDeprecatedWritableStr]>;
|
||||
// FIXME: Why is DeprecatedImplementations not in this group?
|
||||
def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
|
||||
DeprecatedCommaSubscript,
|
||||
DeprecatedDeclarations,
|
||||
DeprecatedDynamicExceptionSpec,
|
||||
DeprecatedIncrementBool,
|
||||
|
|
|
@ -5719,6 +5719,9 @@ def err_arithmetic_nonfragile_interface : Error<
|
|||
"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">;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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
|
||||
|
||||
|
@ -99,5 +100,30 @@ namespace DeprecatedCopy {
|
|||
}
|
||||
#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();
|
||||
|
|
|
@ -1098,7 +1098,7 @@ as the draft C++2a standard evolves.
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue