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
This commit is contained in:
Douglas Gregor 2009-11-06 01:02:41 +00:00
parent eec642f8ab
commit 02ba0ea461
3 changed files with 28 additions and 2 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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',