Implement more reasonable local value name lookup:

- Allow forward references.
  - Diagnose redefinitions.
  - Diagnose cases where the use/def of a value mismatch type.

While I'm at it, this fixes a bug where tuple parsing wasn't parsing
the separating commas.


Swift SVN r5343
This commit is contained in:
Chris Lattner
2013-05-25 18:42:38 +00:00
parent 7383d09a36
commit 2e69c61f71
5 changed files with 102 additions and 31 deletions

View File

@@ -1,17 +1,37 @@
// RUN: %swift %s -emit-sil | FileCheck %s
// CHECK: sil clang_thunk @prototype : $() -> ()
sil clang_thunk @prototype : $() -> ()
var dummy : Int
// Linkage types.
// CHECK: sil clang_thunk @clang_thunk : $() -> ()
sil clang_thunk @clang_thunk : $() -> ()
// CHECK: sil internal @internal_fn : $() -> Int
sil internal @internal_fn : $() -> Int
// Type references
// Some cyclic type references between SIL function bodies.
class Class1 { var a : Class2 }
class Class2 { var b : Class1 }
sil @test2 : $(a : Class1) -> () { // CHECK: sil @test2 : $(a : Class1) -> ()
sil @type_ref1 : $(a : Class1, b : Int) -> () // CHECK: $(a : Class1, b : Int64)
// Instructions
sil @test1 : $() -> () { // CHECK: sil @test1 : $() -> ()
bb0: // CHECK: bb0:
%0 = tuple () // CHECK: %0 = tuple ()
%1 = return %0 : $() // CHECK: %1 = return %0 : $()
}
// CHECK: sil internal @internal_fn : $() -> Int
sil internal @internal_fn : $() -> Int
// Forward referenced values.
// TODO: Use control flow to avoid building incorrect SSA.
sil @test2 : $() -> () { // CHECK: sil @test2 : $() -> ()
bb0: // CHECK: bb0:
%1 = return %0 : $() // CHECK: %0 = return %1 : $()
%0 = tuple () // CHECK: %1 = tuple ()
}