Files
swift-mirror/test/SIL/Parser/errors.sil
John McCall ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00

50 lines
1.7 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 @block_errors : $() -> () {
bb0:
%0 = tuple ()
return %0 : $()
bb0: // expected-error {{redefinition of basic block 'bb0'}}
return %0 : $()
}
sil @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 @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 @global_value_errors : $() -> () { // expected-error {{redefinition of value 'global_value_errors'}}
bb0:
%1 = function_ref @wrong_type : $() -> ((), ()) // expected-note {{prior reference was here}}
}
sil @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 @missing_type : $@convention(thin) (Int) -> () {
bb0(%0 : $Int):
br bb3(%0) // expected-error {{expected ':' before type in SIL value reference}}
// FIXME: The next error is unexpected.
} // expected-error {{extraneous '}' at top level}} {{1-3=}}