mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:51:12 +01:00
When merging functions, detect uses of imports prior to a redecl. (#3836)
LookupNameInDecl is only called from DeclNameStack, but I'm adding mark_imports_used there because it feels more consistent. Not sure if we want a better API boundary. I admit I'm also suspicious of its call to LookupInCurrentScope but maybe it's okay due to how imports work. I was choosing to print multiple diagnostics when a declaration is previously used _and_ doesn't match because I think the "previously used" is more important, but the "doesn't match" may give an additional hint about why it didn't work. The merge.h utility function is because I think we can follow a similar model for identifying errors with other declarations: classes, interfaces, etc.
This commit is contained in:
@@ -204,8 +204,8 @@ fn D() {}
|
||||
// CHECK:STDOUT: .C = %import_ref.3
|
||||
// CHECK:STDOUT: .D = %import_ref.4
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %import_ref.1: <function> = import_ref ir1, inst+1, loc_10 [template = imports.%A]
|
||||
// CHECK:STDOUT: %import_ref.2: <function> = import_ref ir1, inst+6, loc_17 [template = imports.%B]
|
||||
// CHECK:STDOUT: %import_ref.1: <function> = import_ref ir1, inst+1, loaded [template = imports.%A]
|
||||
// CHECK:STDOUT: %import_ref.2: <function> = import_ref ir1, inst+6, loaded [template = imports.%B]
|
||||
// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+20, unloaded
|
||||
// CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+30, unloaded
|
||||
// CHECK:STDOUT: %A: <function> = fn_decl @A [template] {}
|
||||
@@ -235,7 +235,7 @@ fn D() {}
|
||||
// CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+1, unloaded
|
||||
// CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+6, unloaded
|
||||
// CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+20, unloaded
|
||||
// CHECK:STDOUT: %import_ref.4: <function> = import_ref ir1, inst+30, loc_11 [template = imports.%D]
|
||||
// CHECK:STDOUT: %import_ref.4: <function> = import_ref ir1, inst+30, loaded [template = imports.%D]
|
||||
// CHECK:STDOUT: %D.loc6: <function> = fn_decl @D [template] {}
|
||||
// CHECK:STDOUT: %D.loc16: <function> = fn_decl @D [template] {}
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user