mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:54:41 +01:00
Fix indirect import handling for functions. (#4258)
The particular test this focused on is indirect_two_file in toolchain/check/testdata/function/definition/no_prelude/extern_library.carbon. This removes `parent_scope_id_for_new_inst` because I think it's returning unhelpful results. The use was at the root of incorrect results for the indirect import chain. `name_id_for_new_inst` is actually wrapping a union, so it's more important. The merging of `is_extern` and `first_owning_decl_id` in `handle_function.cpp` feels like it's less correct with the changes that've been made to `extern`. This ripples in tests, because the error recovery shifts. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
2a7c2c5df2
commit
bed5fdcbbe
+16
-13
@@ -88,6 +88,16 @@ import library "extern";
|
||||
// CHECK:STDERR:
|
||||
fn A();
|
||||
|
||||
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+10]]:1: ERROR: Redeclarations of `fn A` must match use of `extern`.
|
||||
// CHECK:STDERR: fn A() {}
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE-17]]:1: In import.
|
||||
// CHECK:STDERR: import library "extern";
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
// CHECK:STDERR: extern.carbon:4:1: Previously declared here.
|
||||
// CHECK:STDERR: extern fn A();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn A() {}
|
||||
|
||||
// --- fail_mix_extern_decl.carbon
|
||||
@@ -96,7 +106,7 @@ library "mix_extern_decl";
|
||||
|
||||
import library "fns";
|
||||
|
||||
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+10]]:1: ERROR: Redeclarations of `fn D` must match use of `extern`.
|
||||
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+9]]:1: ERROR: Redeclarations of `fn D` must match use of `extern`.
|
||||
// CHECK:STDERR: extern fn D();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE-5]]:1: In import.
|
||||
@@ -105,15 +115,8 @@ import library "fns";
|
||||
// CHECK:STDERR: fns.carbon:7:1: Previously declared here.
|
||||
// CHECK:STDERR: fn D();
|
||||
// CHECK:STDERR: ^~~~~~~
|
||||
// CHECK:STDERR:
|
||||
extern fn D();
|
||||
|
||||
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+6]]:1: ERROR: Redeclarations of `fn D` must match use of `extern`.
|
||||
// CHECK:STDERR: fn D() {}
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE-5]]:1: Previously declared here.
|
||||
// CHECK:STDERR: extern fn D();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
fn D() {}
|
||||
|
||||
// CHECK:STDOUT: --- fns.carbon
|
||||
@@ -430,10 +433,10 @@ fn D() {}
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %default.import = import <invalid>
|
||||
// CHECK:STDOUT: %A.decl.loc16: %A.type = fn_decl @A [template = constants.%A] {}
|
||||
// CHECK:STDOUT: %A.decl.loc18: %A.type = fn_decl @A [template = constants.%A] {}
|
||||
// CHECK:STDOUT: %A.decl.loc28: %A.type = fn_decl @A [template = constants.%A] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @A() {
|
||||
// CHECK:STDOUT: extern fn @A() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
@@ -467,13 +470,13 @@ fn D() {}
|
||||
// CHECK:STDOUT: .A = imports.%import_ref.1
|
||||
// CHECK:STDOUT: .B = imports.%import_ref.2
|
||||
// CHECK:STDOUT: .C = imports.%import_ref.3
|
||||
// CHECK:STDOUT: .D = %D.decl.loc24
|
||||
// CHECK:STDOUT: .D = %D.decl.loc15
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %default.import = import <invalid>
|
||||
// CHECK:STDOUT: %D.decl.loc16: %D.type = fn_decl @D [template = constants.%D] {}
|
||||
// CHECK:STDOUT: %D.decl.loc24: %D.type = fn_decl @D [template = constants.%D] {}
|
||||
// CHECK:STDOUT: %D.decl.loc15: %D.type = fn_decl @D [template = constants.%D] {}
|
||||
// CHECK:STDOUT: %D.decl.loc17: %D.type = fn_decl @D [template = constants.%D] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @D() {
|
||||
|
||||
Reference in New Issue
Block a user