Teach reference initialization from the result of a user-defined

conversion to initialize the standard conversion *after* the
user-defined conversion properly. Fixes PR10644.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137608 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2011-08-15 13:59:46 +00:00
Родитель 2fd9a47487
Коммит f20d27288c
2 изменённых файлов: 20 добавлений и 5 удалений

Просмотреть файл

@ -3609,11 +3609,11 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType,
ICS.Standard.ObjCLifetimeConversionBinding = false;
} else if (ICS.isUserDefined()) {
ICS.UserDefined.After.ReferenceBinding = true;
ICS.Standard.IsLvalueReference = !isRValRef;
ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
ICS.Standard.BindsToRvalue = true;
ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
ICS.Standard.ObjCLifetimeConversionBinding = false;
ICS.UserDefined.After.IsLvalueReference = !isRValRef;
ICS.UserDefined.After.BindsToFunctionLvalue = T2->isFunctionType();
ICS.UserDefined.After.BindsToRvalue = true;
ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier = false;
ICS.UserDefined.After.ObjCLifetimeConversionBinding = false;
}
return ICS;

Просмотреть файл

@ -162,3 +162,18 @@ namespace argument_passing {
}
}
namespace pr10644 {
struct string {
string(const char* __s);
};
class map {
int& operator[](const string& __k);
public:
int& operator[](const string&& __k);
};
void foo() {
static map key_map;
key_map["line"];
}
}