]> granicus.if.org Git - clang/commitdiff
When determining whether the two types involved in reference binding
authorDouglas Gregor <dgregor@apple.com>
Fri, 7 May 2010 00:28:31 +0000 (00:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 7 May 2010 00:28:31 +0000 (00:28 +0000)
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion.

Fixes PR7080.

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

lib/Sema/SemaOverload.cpp
test/SemaTemplate/instantiate-complete.cpp

index 531ca39a996d0b8aae89bde45c5498be62f8bc4a..dec9854c72ebef73e862187b14f0ff6af577b3eb 100644 (file)
@@ -2289,8 +2289,7 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
   //   T1 is a base class of T2.
   if (UnqualT1 == UnqualT2)
     DerivedToBase = false;
-  else if (!RequireCompleteType(Loc, OrigT1, PDiag()) &&
-           !RequireCompleteType(Loc, OrigT2, PDiag()) &&
+  else if (!RequireCompleteType(Loc, OrigT2, PDiag()) &&
            IsDerivedFrom(UnqualT2, UnqualT1))
     DerivedToBase = true;
   else
index d854c9e6aacc83a0858e7a694d9fb4220debb981..a2cb0491732795f1e5d13ccc9312a6307a54674b 100644 (file)
@@ -99,3 +99,23 @@ namespace TemporaryObjectCopy {
 
   template void f(int);
 }
+
+namespace PR7080 {
+  template <class T, class U>
+  class X
+  {
+    typedef char true_t;
+    class false_t { char dummy[2]; };
+    static true_t dispatch(U);
+    static false_t dispatch(...);
+    static T trigger();
+  public:
+    enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
+  };
+
+  template <class T>
+  class rv : public T
+  { };
+
+  bool x = X<int, rv<int>&>::value;
+}