]> granicus.if.org Git - clang/commitdiff
When we encounter a derived-to-base conversion when performing an
authorDouglas Gregor <dgregor@apple.com>
Fri, 6 Nov 2009 01:02:41 +0000 (01:02 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 6 Nov 2009 01:02:41 +0000 (01:02 +0000)
implicit conversion sequence, check the validity of this conversion
and then perform it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86210 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/overload-call.cpp
utils/C++Tests/LLVM-Syntax/lit.local.cfg

index c4fd39be6c2f3e82416eb18f91a8f941447a8d59..4188905fddec182179d3fb938da8626ce4a59f19 100644 (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;
index 94f352efc76c10b42c31257f2fef296d4e95849b..3a0bf3008d6cb1e3b40d0670e5751b3fa35ffb0a 100644 (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);
+}
index 8375f0920d3d30d9dd9931fc9654c8788a1792d8..5c19c4df167db56f9c83f10a2c1ffaae426c7e08 100644 (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',