Files
swift-mirror/test/SIL/Parser/errors.sil
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

62 lines
2.0 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 @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 : $()
}