mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 506728 - Ref-qualified conversion operator
Change-Id: Ic5e1650bdd1235fd953ab79e44f801c0b52badf3
This commit is contained in:
parent
4fa9706ea8
commit
b6bda6636c
2 changed files with 22 additions and 2 deletions
|
@ -1749,6 +1749,21 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
assertSame(oper, conv);
|
||||
}
|
||||
|
||||
// struct S {
|
||||
// operator int() &;
|
||||
// operator int() &&;
|
||||
// };
|
||||
//
|
||||
// void waldo(int);
|
||||
//
|
||||
// int main() {
|
||||
// S s;
|
||||
// waldo(s); // ERROR
|
||||
// }
|
||||
public void testOverloadedRefQualifiedConversionOperators_506728() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// namespace A { int x; }
|
||||
// namespace B = A;
|
||||
// int f(){ B::x; }
|
||||
|
|
|
@ -856,7 +856,8 @@ public class Conversions {
|
|||
if (isExplicitConversion /** && !direct **/)
|
||||
continue;
|
||||
|
||||
final IType returnType = op.getType().getReturnType();
|
||||
ICPPFunctionType functionType = op.getType();
|
||||
final IType returnType = functionType.getReturnType();
|
||||
IType uqReturnType= getNestedType(returnType, TDEF | ALLCVQ);
|
||||
Cost c2= checkImplicitConversionSequence(target, uqReturnType, valueCategoryFromReturnType(uqReturnType), UDCMode.FORBIDDEN, Context.ORDINARY, point);
|
||||
if (c2.converts()) {
|
||||
|
@ -866,7 +867,11 @@ public class Conversions {
|
|||
final Cost udcCost = isReferenceCompatible(getNestedType(implicitType, TDEF | REF), source, true, point);
|
||||
if (udcCost != null) {
|
||||
// Make sure top-level cv-qualifiers are compared
|
||||
udcCost.setReferenceBinding(ReferenceBinding.LVALUE_REF);
|
||||
if (functionType.hasRefQualifier() && functionType.isRValueReference()) {
|
||||
udcCost.setReferenceBinding(ReferenceBinding.RVALUE_REF_BINDS_RVALUE);
|
||||
} else {
|
||||
udcCost.setReferenceBinding(ReferenceBinding.LVALUE_REF);
|
||||
}
|
||||
FunctionCost c1= new FunctionCost(op, udcCost, point);
|
||||
int cmp= c1.compareTo(null, cost1);
|
||||
if (cmp <= 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue