[cfe-commits] r84514 - in /cfe/trunk: lib/Sema/SemaCXXCast.cpp test/CodeGenCXX/casts.cpp
Anders Carlsson
andersca at mac.com
Mon Oct 19 11:14:29 PDT 2009
Author: andersca
Date: Mon Oct 19 13:14:28 2009
New Revision: 84514
URL: http://llvm.org/viewvc/llvm-project?rev=84514&view=rev
Log:
Set the cast kind to CK_NoOp for C-style casts that are really const casts. Fixes PR5248.
Added:
cfe/trunk/test/CodeGenCXX/casts.cpp
Modified:
cfe/trunk/lib/Sema/SemaCXXCast.cpp
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=84514&r1=84513&r2=84514&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Mon Oct 19 13:14:28 2009
@@ -1113,6 +1113,9 @@
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,
Added: cfe/trunk/test/CodeGenCXX/casts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/casts.cpp?rev=84514&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/casts.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/casts.cpp Mon Oct 19 13:14:28 2009
@@ -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();
+}
+}
+
More information about the cfe-commits
mailing list