Skip to content

Commit 33779b8

Browse files
committed
Reword a diagnostic; NFC
This diagnostic used to talk about complex integer types but is issued for use of the increment or decrement operators on any complex type, not just integral ones. The diagnostic also had zero test coverage, so new coverage is added along with the rewording.
1 parent 78eac46 commit 33779b8

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7588,8 +7588,8 @@ def ext_gnu_ptr_func_arith : Extension<
75887588
InGroup<GNUPointerArith>;
75897589
def err_readonly_message_assignment : Error<
75907590
"assigning to 'readonly' return result of an Objective-C message not allowed">;
7591-
def ext_integer_increment_complex : Extension<
7592-
"ISO C does not support '++'/'--' on complex integer type %0">;
7591+
def ext_increment_complex : Extension<
7592+
"'%select{--|++}0' on an object of complex type is a Clang extension">;
75937593
def ext_integer_complement_complex : Extension<
75947594
"ISO C does not support '~' for complex conjugation of %0">;
75957595
def err_nosetter_property_assignment : Error<

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14859,8 +14859,8 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
1485914859
return QualType();
1486014860
} else if (ResType->isAnyComplexType()) {
1486114861
// C99 does not support ++/-- on complex types, we allow as an extension.
14862-
S.Diag(OpLoc, diag::ext_integer_increment_complex)
14863-
<< ResType << Op->getSourceRange();
14862+
S.Diag(OpLoc, diag::ext_increment_complex)
14863+
<< IsInc << Op->getSourceRange();
1486414864
} else if (ResType->isPlaceholderType()) {
1486514865
ExprResult PR = S.CheckPlaceholderExpr(Op);
1486614866
if (PR.isInvalid()) return QualType();

clang/test/Sema/complex-inc-dec.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -verify -pedantic -std=c99 %s
2+
3+
void func(void) {
4+
_Complex float cf;
5+
_Complex double cd;
6+
_Complex long double cld;
7+
8+
++cf; // expected-warning {{'++' on an object of complex type is a Clang extension}}
9+
++cd; // expected-warning {{'++' on an object of complex type is a Clang extension}}
10+
++cld; // expected-warning {{'++' on an object of complex type is a Clang extension}}
11+
12+
--cf; // expected-warning {{'--' on an object of complex type is a Clang extension}}
13+
--cd; // expected-warning {{'--' on an object of complex type is a Clang extension}}
14+
--cld; // expected-warning {{'--' on an object of complex type is a Clang extension}}
15+
16+
cf++; // expected-warning {{'++' on an object of complex type is a Clang extension}}
17+
cd++; // expected-warning {{'++' on an object of complex type is a Clang extension}}
18+
cld++; // expected-warning {{'++' on an object of complex type is a Clang extension}}
19+
20+
cf--; // expected-warning {{'--' on an object of complex type is a Clang extension}}
21+
cd--; // expected-warning {{'--' on an object of complex type is a Clang extension}}
22+
cld--; // expected-warning {{'--' on an object of complex type is a Clang extension}}
23+
}
24+

0 commit comments

Comments
 (0)