forked from OSchip/llvm-project
Set the cast kind to CK_NoOp for C-style casts that are really const casts. Fixes PR5248.
llvm-svn: 84514
This commit is contained in:
parent
24fcb826bd
commit
027732b5b9
|
@ -1113,6 +1113,9 @@ bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
|
|||
unsigned msg = diag::err_bad_cxx_cast_generic;
|
||||
TryCastResult tcr = TryConstCast(*this, CastExpr, CastTy, /*CStyle*/true,
|
||||
msg);
|
||||
if (tcr == TC_Success)
|
||||
Kind = CastExpr::CK_NoOp;
|
||||
|
||||
if (tcr == TC_NotApplicable) {
|
||||
// ... or if that is not possible, a static_cast, ignoring const, ...
|
||||
tcr = TryStaticCast(*this, CastExpr, CastTy, /*CStyle*/true, R, msg,
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// RUN: clang-cc %s -emit-llvm -o %t
|
||||
|
||||
// PR5248
|
||||
namespace PR5248 {
|
||||
struct A {
|
||||
void copyFrom(const A &src);
|
||||
void addRef(void);
|
||||
};
|
||||
|
||||
void A::copyFrom(const A &src) {
|
||||
((A &)src).addRef();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue