summaryrefslogtreecommitdiffstats
path: root/test/Parser/objcxx0x-lambda-expressions.mm
blob: 937464918b6ae6e1d0e9df836b843a81de7d855f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

class C {

  void f() {
    int foo, bar;

    // fail to parse as a lambda introducer, so we get objc message parsing errors instead
    [foo,+] {}; // expected-error {{expected expression}}

    []; // expected-error {{expected body of lambda expression}}
    [=,foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
    [&this] {}; // expected-error {{address expression must be an lvalue}}
    [] {};
    [=] (int i) {};
    [&] (int) mutable -> void {};
    // FIXME: this error occurs because we do not yet handle lambda scopes
    // properly. I did not anticipate it because I thought it was a semantic (not
    // syntactic) check.
    [foo,bar] () { return 3; }; // expected-error {{void function 'f' should not return a value}}
    [=,&foo] () {};
    [this] () {};
  }

};

OpenPOWER on IntegriCloud