blob: 27a53bd93f575ad7041715079d97bb6168e47098 [file] [log] [blame]
Chris Lattner3e59f082018-07-14 23:06:24 -07001// TODO(andydavis) Resolve relative path issue w.r.t invoking mlir-opt in RUN
2// statements (perhaps through using lit config substitutions).
3//
4// RUN: %S/../../mlir-opt %s -o - -check-parser-errors
Jacques Pienaarbae40512018-06-24 09:10:36 -07005
Chris Lattner3e59f082018-07-14 23:06:24 -07006// Check different error cases.
7// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -07008
Chris Lattner3e59f082018-07-14 23:06:24 -07009extfunc @illegaltype(i) // expected-error {{expected type}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070010
Chris Lattner3e59f082018-07-14 23:06:24 -070011// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070012
Chris Lattner3e59f082018-07-14 23:06:24 -070013extfunc @nestedtensor(tensor<tensor<i8>>) -> () // expected-error {{expected type}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070014
Chris Lattner3e59f082018-07-14 23:06:24 -070015// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070016
Jacques Pienaarbae40512018-06-24 09:10:36 -070017cfgfunc @foo()
Chris Lattner3e59f082018-07-14 23:06:24 -070018cfgfunc @bar() // expected-error {{expected '{' in CFG function}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070019
Chris Lattner3e59f082018-07-14 23:06:24 -070020// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070021
Chris Lattner3e59f082018-07-14 23:06:24 -070022extfunc missingsigil() -> (i1, affineint, f32) // expected-error {{expected a function identifier like}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070023
24
Chris Lattner3e59f082018-07-14 23:06:24 -070025// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -070026
27cfgfunc @bad_branch() {
28bb42:
Chris Lattner3e59f082018-07-14 23:06:24 -070029 br missing // expected-error {{reference to an undefined basic block 'missing'}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070030}
31
Chris Lattner3e59f082018-07-14 23:06:24 -070032// -----
Chris Lattnerf6d80a02018-06-24 11:18:29 -070033
34cfgfunc @block_redef() {
35bb42:
36 return
Chris Lattner3e59f082018-07-14 23:06:24 -070037bb42: // expected-error {{redefinition of block 'bb42'}}
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070038 return
39}
40
Chris Lattner3e59f082018-07-14 23:06:24 -070041// -----
Jacques Pienaarca4c4a02018-06-25 08:10:46 -070042
43cfgfunc @no_terminator() {
44bb40:
45 return
46bb41:
Chris Lattner3e59f082018-07-14 23:06:24 -070047bb42: // expected-error {{expected operation name}}
Chris Lattnerf6d80a02018-06-24 11:18:29 -070048 return
49}
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070050
Chris Lattner3e59f082018-07-14 23:06:24 -070051// -----
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070052
53mlfunc @foo()
Chris Lattner3e59f082018-07-14 23:06:24 -070054mlfunc @bar() // expected-error {{expected '{' in ML function}}
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070055
Chris Lattner3e59f082018-07-14 23:06:24 -070056// -----
Tatiana Shpeismanc96b5872018-06-28 17:02:32 -070057
58mlfunc @no_return() {
Chris Lattner3e59f082018-07-14 23:06:24 -070059} // expected-error {{ML function must end with return statement}}
Chris Lattnered65a732018-06-28 20:45:33 -070060
Chris Lattner3e59f082018-07-14 23:06:24 -070061// -----
Chris Lattnered65a732018-06-28 20:45:33 -070062
Chris Lattner3e59f082018-07-14 23:06:24 -070063" // expected-error {{expected}}
Chris Lattnered65a732018-06-28 20:45:33 -070064"
65
Chris Lattner3e59f082018-07-14 23:06:24 -070066// -----
Chris Lattnered65a732018-06-28 20:45:33 -070067
Chris Lattner3e59f082018-07-14 23:06:24 -070068" // expected-error {{expected}}
Chris Lattnered65a732018-06-28 20:45:33 -070069
Chris Lattner3e59f082018-07-14 23:06:24 -070070// -----
Chris Lattnered65a732018-06-28 20:45:33 -070071
72cfgfunc @no_terminator() {
73bb40:
74 "foo"()
Chris Lattner3e59f082018-07-14 23:06:24 -070075 ""() // expected-error {{empty operation name is invalid}}
Chris Lattnered65a732018-06-28 20:45:33 -070076 return
77}
Chris Lattnerf958bbe2018-06-29 22:08:05 -070078
Chris Lattner3e59f082018-07-14 23:06:24 -070079// -----
Chris Lattnerf958bbe2018-06-29 22:08:05 -070080
Chris Lattner3e59f082018-07-14 23:06:24 -070081extfunc @illegaltype(i0) // expected-error {{invalid integer width}}
Chris Lattnerf958bbe2018-06-29 22:08:05 -070082
Chris Lattner3e59f082018-07-14 23:06:24 -070083// -----
Chris Lattnerf958bbe2018-06-29 22:08:05 -070084
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -070085mlfunc @incomplete_for() {
86 for
Chris Lattner3e59f082018-07-14 23:06:24 -070087} // expected-error {{expected '{' before statement list}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -070088
Chris Lattner3e59f082018-07-14 23:06:24 -070089// -----
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -070090
91mlfunc @non_statement() {
Chris Lattner3e59f082018-07-14 23:06:24 -070092 asd // expected-error {{expected statement}}
Tatiana Shpeismanbf079c92018-07-03 17:51:28 -070093}
Chris Lattner7121b802018-07-04 20:45:39 -070094
Chris Lattner3e59f082018-07-14 23:06:24 -070095// -----
Chris Lattner7121b802018-07-04 20:45:39 -070096
Chris Lattner21e67f62018-07-06 10:46:19 -070097cfgfunc @malformed_dim() {
98bb42:
Chris Lattner3e59f082018-07-14 23:06:24 -070099 "dim"(){index: "xyz"} // expected-error {{'dim' op requires an integer attribute named 'index'}}
Chris Lattner21e67f62018-07-06 10:46:19 -0700100 return
101}
102
Chris Lattner3e59f082018-07-14 23:06:24 -0700103// -----
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700104
Chris Lattner3e59f082018-07-14 23:06:24 -0700105#map = (d0) -> (% // expected-error {{invalid SSA name}}
Jacques Pienaar0bffd862018-07-11 13:26:23 -0700106
Chris Lattner3e59f082018-07-14 23:06:24 -0700107// -----