diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-21 22:21:19 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-05-21 22:21:19 +0000 |
| commit | f44d2a8a3e05ef27e72ea8f2e07e1a7266e4b4c9 (patch) | |
| tree | 7648de300006ecec53720d665e0a627c0d5910d0 /clang/test | |
| parent | c6c7e4a67cf02e9daec3a7071fd50bcf0cb59d82 (diff) | |
| download | bcm5719-llvm-f44d2a8a3e05ef27e72ea8f2e07e1a7266e4b4c9.tar.gz bcm5719-llvm-f44d2a8a3e05ef27e72ea8f2e07e1a7266e4b4c9.zip | |
PR16094: I should have known Obj-C init-capture disambiguation couldn't be
*that* easy...
Try a bit harder to disambiguate. This is mostly straightforward, but for
=-style initializers, we actually need to know where an expression ends:
[foo = bar baz]
is a message send, whereas
[foo = bar + baz]
is a lambda-introducer. Handle this by parsing the expression eagerly, and
replacing it with an annotation token. By chance, we use the *exact same*
parsing rules in both cases (except that we need to assume we're inside a
message send for the parse, to turn off various forms of inapplicable
error recovery).
llvm-svn: 182432
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Parser/objcxx0x-lambda-expressions.mm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/test/Parser/objcxx0x-lambda-expressions.mm b/clang/test/Parser/objcxx0x-lambda-expressions.mm index b2a75f2edbb..905bd6b1e8b 100644 --- a/clang/test/Parser/objcxx0x-lambda-expressions.mm +++ b/clang/test/Parser/objcxx0x-lambda-expressions.mm @@ -1,9 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s class C { + id get(int); void f() { - int foo, bar; + int foo, bar, baz; // fail to parse as a lambda introducer, so we get objc message parsing errors instead [foo,+] {}; // expected-error {{expected expression}} @@ -24,9 +25,18 @@ class C { [foo = {bar}] () {}; // expected-error {{<initializer_list>}} [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}} + [foo(bar), baz] () {}; // ok - // FIXME: These are some appalling diagnostics. - [foo = bar baz]; // expected-error {{missing '['}} expected-warning 2{{receiver type 'int'}} expected-warning 2{{instance method '-baz'}} + [foo = bar baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + + [get(bar) baz]; // expected-warning {{instance method '-baz'}} + [get(bar), baz]; // expected-error {{expected body of lambda}} + + [foo = bar ++ baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + [foo = bar + baz]; // expected-error {{expected body of lambda}} + [foo = { bar, baz }]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}} + [foo = { bar } baz ]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + [foo = { bar }, baz ]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}} } }; |

