// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/no_prelude/implicit_import.carbon // --- basic.carbon library "[[@TEST_NAME]]"; fn A(); // --- basic.impl.carbon impl library "[[@TEST_NAME]]"; fn A() {} // --- extern_api.carbon library "[[@TEST_NAME]]"; extern fn A(); // --- fail_extern_api.impl.carbon impl library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+12]]:1: error: redeclarations of `fn A` must match use of `extern` // CHECK:STDERR: fn A(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE-5]]:6: in import // CHECK:STDERR: extern_api.carbon:4:1: note: previously declared here // CHECK:STDERR: extern fn A(); // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+4]]:1: error: no definition found for declaration in impl file // CHECK:STDERR: fn A(); // CHECK:STDERR: ^~~~~~~ // CHECK:STDERR: fn A(); // --- extern_impl.carbon library "[[@TEST_NAME]]"; fn A(); // --- fail_extern_impl.impl.carbon impl library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+7]]:1: error: redeclarations of `fn A` must match use of `extern` // CHECK:STDERR: extern fn A(); // CHECK:STDERR: ^~~~~~~~~~~~~~ // CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE-5]]:6: in import // CHECK:STDERR: extern_impl.carbon:4:1: note: previously declared here // CHECK:STDERR: fn A(); // CHECK:STDERR: ^~~~~~~ extern fn A(); // CHECK:STDOUT: --- basic.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A(); // CHECK:STDOUT: // CHECK:STDOUT: --- basic.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref: %A.type = import_ref Main//basic, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- extern_api.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: extern fn @A(); // CHECK:STDOUT: // CHECK:STDOUT: --- fail_extern_api.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_api, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: extern fn @A(); // CHECK:STDOUT: // CHECK:STDOUT: --- extern_impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A(); // CHECK:STDOUT: // CHECK:STDOUT: --- fail_extern_impl.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref: %A.type = import_ref Main//extern_impl, inst+1, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A(); // CHECK:STDOUT: