Files
swift-mirror/test/SIL/Parser/errors.sil
Erik Eckstein 09b26e897d SILParser: don't accept instructions after "unreachable"
All instructions after an "unreachable" were not added to the function anyway and were leaking.
2020-09-11 11:09:29 +02:00

67 lines
2.2 KiB
Plaintext

// RUN: %target-swift-frontend %s -emit-sil -verify
sil_stage canonical
sil_stage raw // expected-error {{sil_stage declared multiple times}}
import Swift
sil [ossa] @block_errors : $() -> () {
bb0:
%0 = tuple ()
return %0 : $()
bb0: // expected-error {{redefinition of basic block 'bb0'}}
return %0 : $()
}
sil [ossa] @local_value_errors : $() -> () {
bb0:
%0 = tuple ()
%0 = tuple () // expected-error {{redefinition of value '%0'}}
%1 = tuple (%0 : $(), %0 : $(Int)) // expected-error {{value '%0' defined with mismatching type '()'}}
%2 = tuple (%199 : $()) // expected-error {{use of undefined value '%199'}}
}
sil [ossa] @local_value_errors2 : $() -> () {
bb0:
%0 = builtin "cmp_eq_Int1"(%0 : $() // expected-error @+1 {{expected ')' or ',' in SIL instruction}}
}
sil [ossa] @global_value_errors : $() -> () {
bb0:
%0 = function_ref @global_value_errors : $ () -> ((), ()) // expected-error {{defined with mismatching type}}
%1 = function_ref @not_defined : $ () -> () // expected-error {{use of undefined value 'not_defined'}}
%2 = tuple ()
return %2 : $()
}
sil [ossa] @global_value_errors : $() -> () { // expected-error {{redefinition of value 'global_value_errors'}}
bb0:
%1 = function_ref @wrong_type : $() -> ((), ()) // expected-note {{prior reference was here}}
}
sil [ossa] @wrong_type : $() -> () { // expected-error {{value 'wrong_type' defined with mismatching type '() -> ((), ())' (expected '@convention(thin) () -> ()')}}
bb0:
%1 = tuple ()
}
sil_stage nonsense // expected-error {{expected 'raw' or 'canonical' after 'sil_stage'}}
sil [ossa] @missing_type : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
br bb3(%0) // expected-error {{expected ':' before type in SIL value reference}}
}
sil @test_formal_substituted_type : $@convention(thin) <X> (@owned Array<@substituted <Z> (Z) -> (Z) for <X>>) -> () {
// expected-error@-1 {{substitutions cannot be provided on a formal function type}}
entry(%0 : $Array<X>):
return undef : $()
}
sil @instructions_after_terminator : $@convention(thin) () -> () {
bb0:
unreachable
%0 = tuple () // expected-error {{expected basic block name or '}'}}
return %0 : $()
}