forked from OSchip/llvm-project
Fix a missed case in the NULL operand to conditional operator
diagnostics. Patch by Stephen Hines. llvm-svn: 125998
This commit is contained in:
parent
fc1ad1f371
commit
9c9127eace
|
@ -3141,6 +3141,10 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
|
||||||
if (!Composite.isNull())
|
if (!Composite.isNull())
|
||||||
return Composite;
|
return Composite;
|
||||||
|
|
||||||
|
// Check if we are using a null with a non-pointer type.
|
||||||
|
if (DiagnoseConditionalForNull(LHS, RHS, QuestionLoc))
|
||||||
|
return QualType();
|
||||||
|
|
||||||
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
|
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
|
||||||
<< LHS->getType() << RHS->getType()
|
<< LHS->getType() << RHS->getType()
|
||||||
<< LHS->getSourceRange() << RHS->getSourceRange();
|
<< LHS->getSourceRange() << RHS->getSourceRange();
|
||||||
|
|
|
@ -311,10 +311,12 @@ namespace PR7598 {
|
||||||
namespace PR9236 {
|
namespace PR9236 {
|
||||||
#define NULL 0L
|
#define NULL 0L
|
||||||
void f() {
|
void f() {
|
||||||
|
int i;
|
||||||
(void)(true ? A() : NULL); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
(void)(true ? A() : NULL); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
||||||
(void)(true ? NULL : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
(void)(true ? NULL : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
||||||
(void)(true ? 0 : A()); // expected-error{{incompatible operand types}}
|
(void)(true ? 0 : A()); // expected-error{{incompatible operand types}}
|
||||||
(void)(true ? nullptr : A()); // expected-error{{non-pointer operand type 'A' incompatible with nullptr}}
|
(void)(true ? nullptr : A()); // expected-error{{non-pointer operand type 'A' incompatible with nullptr}}
|
||||||
|
(void)(true ? nullptr : i); // expected-error{{non-pointer operand type 'int' incompatible with nullptr}}
|
||||||
(void)(true ? __null : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
(void)(true ? __null : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
|
||||||
(void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}}
|
(void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ nullptr_t f(nullptr_t null)
|
||||||
(void)(1 > nullptr); // expected-error {{invalid operands to binary expression}}
|
(void)(1 > nullptr); // expected-error {{invalid operands to binary expression}}
|
||||||
(void)(1 != nullptr); // expected-error {{invalid operands to binary expression}}
|
(void)(1 != nullptr); // expected-error {{invalid operands to binary expression}}
|
||||||
(void)(1 + nullptr); // expected-error {{invalid operands to binary expression}}
|
(void)(1 + nullptr); // expected-error {{invalid operands to binary expression}}
|
||||||
(void)(0 ? nullptr : 0); // expected-error {{incompatible operand types}}
|
(void)(0 ? nullptr : 0); // expected-error {{non-pointer operand type 'int' incompatible with nullptr}}
|
||||||
(void)(0 ? nullptr : (void*)0);
|
(void)(0 ? nullptr : (void*)0);
|
||||||
(void)(0 ? nullptr : A()); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
|
(void)(0 ? nullptr : A()); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
|
||||||
(void)(0 ? A() : nullptr); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
|
(void)(0 ? A() : nullptr); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
|
||||||
|
|
Loading…
Reference in New Issue