From 02ba0ea46137225189469670fec3aa237e8aed16 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 6 Nov 2009 01:02:41 +0000 Subject: [PATCH] When we encounter a derived-to-base conversion when performing an implicit conversion sequence, check the validity of this conversion and then perform it. llvm-svn: 86210 --- clang/lib/Sema/SemaExprCXX.cpp | 12 +++++++++++- clang/test/SemaCXX/overload-call.cpp | 13 +++++++++++++ clang/utils/C++Tests/LLVM-Syntax/lit.local.cfg | 5 ++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index c4fd39be6c2f..4188905fddec 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1295,6 +1295,16 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, ImpCastExprToType(From, Context.BoolTy, CastExpr::CK_Unknown); break; + case ICK_Derived_To_Base: + if (CheckDerivedToBaseConversion(From->getType(), + ToType.getNonReferenceType(), + From->getLocStart(), + From->getSourceRange())) + return true; + ImpCastExprToType(From, ToType.getNonReferenceType(), + CastExpr::CK_DerivedToBase); + break; + default: assert(false && "Improper second standard conversion"); break; @@ -1312,7 +1322,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, CastExpr::CK_NoOp, ToType->isLValueReferenceType()); break; - + default: assert(false && "Improper second standard conversion"); break; diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp index 94f352efc76c..3a0bf3008d6c 100644 --- a/clang/test/SemaCXX/overload-call.cpp +++ b/clang/test/SemaCXX/overload-call.cpp @@ -278,3 +278,16 @@ float& db_rebind(Z&); void db_rebind_test(Z2 z2) { float& f1 = db_rebind(z2); } + +class string { }; +class opt : public string { }; + +struct SR { + SR(const string&); +}; + +void f(SR) { } + +void g(opt o) { + f(o); +} diff --git a/clang/utils/C++Tests/LLVM-Syntax/lit.local.cfg b/clang/utils/C++Tests/LLVM-Syntax/lit.local.cfg index 8375f0920d3d..5c19c4df167d 100644 --- a/clang/utils/C++Tests/LLVM-Syntax/lit.local.cfg +++ b/clang/utils/C++Tests/LLVM-Syntax/lit.local.cfg @@ -12,8 +12,11 @@ root = getRoot(config) # testFormat: The test format to use to interpret tests. config.test_format = lit.formats.SyntaxCheckTest(compiler=root.clang, dir='%s/include/llvm' % root.llvm_src_root, - recursive=False, + recursive=True, pattern='^(.*\\.h|[^.]*)$', + excludes=['DAGISelHeader.h', + 'AIXDataTypesFix.h', + 'Solaris.h'], extra_cxx_args=['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-Wno-sign-compare',