[cfe-commits] r86211 - in /cfe/trunk: lib/Sema/SemaCXXCast.cpp test/SemaCXX/cast-conversion.cpp
Douglas Gregor
dgregor at apple.com
Thu Nov 5 17:14:42 PST 2009
Author: dgregor
Date: Thu Nov 5 19:14:41 2009
New Revision: 86211
URL: http://llvm.org/viewvc/llvm-project?rev=86211&view=rev
Log:
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!
Modified:
cfe/trunk/lib/Sema/SemaCXXCast.cpp
cfe/trunk/test/SemaCXX/cast-conversion.cpp
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=86211&r1=86210&r2=86211&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Thu Nov 5 19:14:41 2009
@@ -388,7 +388,7 @@
return;
}
- if (!DestType->isLValueReferenceType())
+ if (!DestType->isLValueReferenceType() && !DestType->isRecordType())
Self.DefaultFunctionArrayConversion(SrcExpr);
unsigned msg = diag::err_bad_cxx_cast_generic;
@@ -1104,7 +1104,7 @@
if (CastTy->isDependentType() || CastExpr->isTypeDependent())
return false;
- if (!CastTy->isLValueReferenceType())
+ if (!CastTy->isLValueReferenceType() && !CastTy->isRecordType())
DefaultFunctionArrayConversion(CastExpr);
// C++ [expr.cast]p5: The conversions performed by
Modified: cfe/trunk/test/SemaCXX/cast-conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cast-conversion.cpp?rev=86211&r1=86210&r2=86211&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cast-conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/cast-conversion.cpp Thu Nov 5 19:14:41 2009
@@ -19,3 +19,17 @@
// 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);
+}
More information about the cfe-commits
mailing list