You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: toolchain/check/testdata/interop/cpp/function/operators.carbon
+55-13Lines changed: 55 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -761,27 +761,49 @@ fn F() {
761
761
class Incomplete;
762
762
class Complete {};
763
763
764
-
auto operator+(Complete lhs, Incomplete rhs) ->Complete;
764
+
auto CreateIncomplete() ->Incomplete* _Nonnull;
765
765
766
-
auto foo(Complete complete) -> void;
766
+
// --- fail_import_incomplete_unary.carbon
767
767
768
-
// --- fail_import_incomplete.carbon
768
+
library "[[@TEST_NAME]]";
769
+
770
+
importCpp library "incomplete.h";
771
+
772
+
fnF() {
773
+
// CHECK:STDERR: fail_import_incomplete_unary.carbon:[[@LINE+11]]:27: error: looking up a C++ operator with incomplete operand type `Cpp.Incomplete` [IncompleteOperandTypeInCppOperatorLookup]
774
+
// CHECK:STDERR: let result_unary: i32 = -*Cpp.CreateIncomplete();
775
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
776
+
// CHECK:STDERR: fail_import_incomplete_unary.carbon:[[@LINE-6]]:10: in file included here [InCppInclude]
777
+
// CHECK:STDERR: ./incomplete.h:2:7: note: class was forward declared here [ClassForwardDeclaredHere]
778
+
// CHECK:STDERR: class Incomplete;
779
+
// CHECK:STDERR: ^
780
+
// CHECK:STDERR: fail_import_incomplete_unary.carbon:[[@LINE+4]]:27: note: in `Cpp` operator `Negate` lookup [InCppOperatorLookup]
781
+
// CHECK:STDERR: let result_unary: i32 = -*Cpp.CreateIncomplete();
782
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
783
+
// CHECK:STDERR:
784
+
let result_unary: i32=-*Cpp.CreateIncomplete();
785
+
}
786
+
787
+
// --- fail_import_incomplete_binary.carbon
769
788
770
789
library "[[@TEST_NAME]]";
771
790
772
791
importCpp library "incomplete.h";
773
792
774
793
fnF() {
775
-
var c1: Cpp.Complete= Cpp.Complete.Complete();
776
-
// CHECK:STDERR: fail_import_incomplete.carbon:[[@LINE+8]]:40: error: invalid use of incomplete type `Cpp.Incomplete` [IncompleteTypeInConversion]
777
-
// CHECK:STDERR: let c3: Cpp.Complete = Cpp.foo(c1 + ({} as Cpp.Incomplete));
778
-
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
779
-
// CHECK:STDERR: fail_import_incomplete.carbon:[[@LINE-7]]:10: in file included here [InCppInclude]
794
+
var complete: Cpp.Complete= Cpp.Complete.Complete();
795
+
// CHECK:STDERR: fail_import_incomplete_binary.carbon:[[@LINE+11]]:28: error: looking up a C++ operator with incomplete operand type `Cpp.Incomplete` [IncompleteOperandTypeInCppOperatorLookup]
796
+
// CHECK:STDERR: let result_binary: i32 = complete + *Cpp.CreateIncomplete();
// CHECK:STDERR: let result: i32 = -Cpp.unsupported;
863
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
864
+
// CHECK:STDERR: fail_import_unsupported_in_instantiation_unary.carbon:[[@LINE+7]]:21: note: while completing C++ type `Cpp.Unsupported` [InCppTypeCompletion]
865
+
// CHECK:STDERR: let result: i32 = -Cpp.unsupported;
866
+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
867
+
// CHECK:STDERR: fail_import_unsupported_in_instantiation_unary.carbon:[[@LINE+4]]:21: note: in `Cpp` operator `Negate` lookup [InCppOperatorLookup]
868
+
// CHECK:STDERR: let result: i32 = -Cpp.unsupported;
// CHECK:STDERR: let result: i32 = supported + Cpp.unsupported;
842
884
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
843
-
// CHECK:STDERR: fail_import_unsupported_in_instantiation.carbon:[[@LINE+7]]:21: note: while completing C++ type `Cpp.Unsupported` [InCppTypeCompletion]
885
+
// CHECK:STDERR: fail_import_unsupported_in_instantiation_binary.carbon:[[@LINE+7]]:21: note: while completing C++ type `Cpp.Unsupported` [InCppTypeCompletion]
844
886
// CHECK:STDERR: let result: i32 = supported + Cpp.unsupported;
845
887
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
846
-
// CHECK:STDERR: fail_import_unsupported_in_instantiation.carbon:[[@LINE+4]]:21: note: in `Cpp` operator `AddWith` lookup [InCppOperatorLookup]
888
+
// CHECK:STDERR: fail_import_unsupported_in_instantiation_binary.carbon:[[@LINE+4]]:21: note: in `Cpp` operator `AddWith` lookup [InCppOperatorLookup]
847
889
// CHECK:STDERR: let result: i32 = supported + Cpp.unsupported;
0 commit comments