Skip to content

Commit abfe192

Browse files
committed
When determining whether the two types involved in reference binding
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
1 parent 8eb662e commit abfe192

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/Sema/SemaOverload.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2289,8 +2289,7 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
22892289
// T1 is a base class of T2.
22902290
if (UnqualT1 == UnqualT2)
22912291
DerivedToBase = false;
2292-
else if (!RequireCompleteType(Loc, OrigT1, PDiag()) &&
2293-
!RequireCompleteType(Loc, OrigT2, PDiag()) &&
2292+
else if (!RequireCompleteType(Loc, OrigT2, PDiag()) &&
22942293
IsDerivedFrom(UnqualT2, UnqualT1))
22952294
DerivedToBase = true;
22962295
else

test/SemaTemplate/instantiate-complete.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,23 @@ namespace TemporaryObjectCopy {
9999

100100
template void f(int);
101101
}
102+
103+
namespace PR7080 {
104+
template <class T, class U>
105+
class X
106+
{
107+
typedef char true_t;
108+
class false_t { char dummy[2]; };
109+
static true_t dispatch(U);
110+
static false_t dispatch(...);
111+
static T trigger();
112+
public:
113+
enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
114+
};
115+
116+
template <class T>
117+
class rv : public T
118+
{ };
119+
120+
bool x = X<int, rv<int>&>::value;
121+
}

0 commit comments

Comments
 (0)