mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:21:06 +01:00
Add more extern "C" tests (#6232)
Add tests in `check`. Add overload set tests in `lower`. Part of #6233.
This commit is contained in:
@@ -28,6 +28,24 @@ fn MyF() {
|
||||
Cpp.foo();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Overload set of extern "C" function and a C++ function
|
||||
// ============================================================================
|
||||
|
||||
// --- extern_c_function_with_cpp_overload_set.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline '''
|
||||
extern "C" void foo();
|
||||
void foo(int x);
|
||||
''';
|
||||
|
||||
fn MyF() {
|
||||
Cpp.foo();
|
||||
Cpp.foo(5);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// extern "C" variable
|
||||
// ============================================================================
|
||||
@@ -112,6 +130,38 @@ fn MyF() {
|
||||
// CHECK:STDOUT: !9 = !{}
|
||||
// CHECK:STDOUT: !10 = !DILocation(line: 7, column: 3, scope: !7)
|
||||
// CHECK:STDOUT: !11 = !DILocation(line: 6, column: 1, scope: !7)
|
||||
// CHECK:STDOUT: ; ModuleID = 'extern_c_function_with_cpp_overload_set.carbon'
|
||||
// CHECK:STDOUT: source_filename = "extern_c_function_with_cpp_overload_set.carbon"
|
||||
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define void @_CMyF.Main() !dbg !7 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @foo(), !dbg !10
|
||||
// CHECK:STDOUT: call void @_Z3fooi(i32 5), !dbg !11
|
||||
// CHECK:STDOUT: ret void, !dbg !12
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @foo()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare void @_Z3fooi(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
|
||||
// CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
|
||||
// CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
|
||||
// CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !6 = !DIFile(filename: "extern_c_function_with_cpp_overload_set.carbon", directory: "")
|
||||
// CHECK:STDOUT: !7 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !6, line: 9, type: !8, spFlags: DISPFlagDefinition, unit: !5)
|
||||
// CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
|
||||
// CHECK:STDOUT: !9 = !{}
|
||||
// CHECK:STDOUT: !10 = !DILocation(line: 10, column: 3, scope: !7)
|
||||
// CHECK:STDOUT: !11 = !DILocation(line: 11, column: 3, scope: !7)
|
||||
// CHECK:STDOUT: !12 = !DILocation(line: 9, column: 1, scope: !7)
|
||||
// CHECK:STDOUT: ; ModuleID = 'import_extern_c_variable.carbon'
|
||||
// CHECK:STDOUT: source_filename = "import_extern_c_variable.carbon"
|
||||
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
|
||||
Reference in New Issue
Block a user