mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:51:16 +01:00
Map Carbon value expressions to const-qualified C++ prvalues. (#6880)
In C++ overload resolution, when mapping a Carbon value expression into a C++ argument, produce a const-qualified argument where possible. This has two effects: * Overload resolution does not consider non-const-qualified member functions to be viable for a prvalue self any more. This is desirable since such functions are not actually callable with a prvalue self, and permits overload resolution to pick a const-qualified overload instead. * Overload resolution does not allow a Carbon value expression to be passed to a C++ `T&&` parameter any more. This is desirable since it's not correct to move from a value expression. Previously we allowed this and moved from the value!
This commit is contained in:
@@ -283,7 +283,7 @@ void operator+(C, short);
|
||||
''';
|
||||
|
||||
fn Test(c: Cpp.C) {
|
||||
// CHECK:STDERR: fail_ambiguous.carbon:[[@LINE+10]]:5: error: use of overloaded operator '+' is ambiguous (with operand types 'C' and 'int') [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_ambiguous.carbon:[[@LINE+10]]:5: error: use of overloaded operator '+' is ambiguous (with operand types 'const C' and 'int') [CppInteropParseError]
|
||||
// CHECK:STDERR: 21 | c + 1;
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR: fail_ambiguous.carbon:[[@LINE-8]]:6: note: candidate function [CppInteropParseNote]
|
||||
|
||||
Reference in New Issue
Block a user