forked from OSchip/llvm-project
Allow comparison of 'void *' with function pointer
as a g++ extension (fixes radar 7481987
).
llvm-svn: 91827
This commit is contained in:
parent
0fc1f6c595
commit
ffc420cb51
|
@ -5170,7 +5170,18 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
|
|||
if (getLangOptions().CPlusPlus) {
|
||||
if (LCanPointeeTy == RCanPointeeTy)
|
||||
return ResultTy;
|
||||
|
||||
if (!isRelational &&
|
||||
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
|
||||
// Valid unless comparison between non-null pointer and function pointer
|
||||
// This is a gcc extension compatibility comparison.
|
||||
if ((LCanPointeeTy->isFunctionType() || RCanPointeeTy->isFunctionType())
|
||||
&& !LHSIsNull && !RHSIsNull) {
|
||||
Diag(Loc, diag::ext_typecheck_comparison_of_fptr_to_void)
|
||||
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
|
||||
ImpCastExprToType(rex, lType, CastExpr::CK_BitCast);
|
||||
return ResultTy;
|
||||
}
|
||||
}
|
||||
// C++ [expr.rel]p2:
|
||||
// [...] Pointer conversions (4.10) and qualification
|
||||
// conversions (4.4) are performed on pointer operands (or on
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
extern "C" id (*_dealloc)(id) ;
|
||||
|
||||
void foo() {
|
||||
extern void *_original_dealloc;
|
||||
if (_dealloc == _original_dealloc) { }
|
||||
if (_dealloc != _original_dealloc) { }
|
||||
}
|
Loading…
Reference in New Issue