forked from OSchip/llvm-project
If we have a C-style cast, functional cast, or a static_cast to a
class type, don't perform the array-to-pointer or function-to-pointer conversions, because we may end up binding a reference to a function or array. With this change, FileCheck now passes -fsyntax-only! llvm-svn: 86211
This commit is contained in:
parent
02ba0ea461
commit
ad8b22269e
|
|
@ -388,7 +388,7 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DestType->isLValueReferenceType())
|
if (!DestType->isLValueReferenceType() && !DestType->isRecordType())
|
||||||
Self.DefaultFunctionArrayConversion(SrcExpr);
|
Self.DefaultFunctionArrayConversion(SrcExpr);
|
||||||
|
|
||||||
unsigned msg = diag::err_bad_cxx_cast_generic;
|
unsigned msg = diag::err_bad_cxx_cast_generic;
|
||||||
|
|
@ -1104,7 +1104,7 @@ bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
|
||||||
if (CastTy->isDependentType() || CastExpr->isTypeDependent())
|
if (CastTy->isDependentType() || CastExpr->isTypeDependent())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!CastTy->isLValueReferenceType())
|
if (!CastTy->isLValueReferenceType() && !CastTy->isRecordType())
|
||||||
DefaultFunctionArrayConversion(CastExpr);
|
DefaultFunctionArrayConversion(CastExpr);
|
||||||
|
|
||||||
// C++ [expr.cast]p5: The conversions performed by
|
// C++ [expr.cast]p5: The conversions performed by
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,17 @@ int main () {
|
||||||
// expected-warning {{expression result unused}}
|
// expected-warning {{expression result unused}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct X0 {
|
||||||
|
X0(const T &);
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
X0<T> make_X0(const T &Val) {
|
||||||
|
return X0<T>(Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_X0() {
|
||||||
|
const char array[2];
|
||||||
|
make_X0(array);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue