Whitelist flex 2.5.34.
[lestes.git] / runner / examples / comma.cc
blob2a7d989a088da825353915e4b3ce002534833eab
1 /*
2 The lestes compiler suite
3 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
4 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
5 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
6 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
7 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
8 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
9 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; version 2 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 See the full text of the GNU General Public License version 2, and
21 the limitations in the file doc/LICENSE.
23 By accepting the license the licensee waives any and all claims
24 against the copyright holder(s) related in whole or in part to the
25 work, its use, and/or the inability to use it.
29 * Example demonstrating as->ss expressions transformation and overload resolution, specifically
30 * for the comma operator.
32 * As specified in [13.3] and [13.6], there are no builtin candidates for operator comma. So if
33 * lookup fails for user-defined operator comma, the implicit one (for every combination of types of
34 * the expressions in question) must take place.
36 * This example demonstrates that even when the lookup and overload resolution process fails for this
37 * specific operator, the implicit one is used and the structures are built as required.
39 * In the dump of the structures, the important things to note are the connections between sequence
40 * points (comma introduces new sequence point, one level deeper than what the maximum of levels of the
41 * sps in question have) and also the sideeffect of the assign operator, which must not be forgotten
42 * when handling operator comma (generally, when handling comma expression, the left expression is thrown
43 * away completely, up to sideeffects, which are connected to the sequence points in question to be evaluated
44 * later). This implies that the expressions are evaluated in the correct order.
48 //#include <lio.hh>
50 int a=3,b=2;
52 int main(int argc, char *argv[])
54 a = a++, b--;
55 a = a--, b--;
56 a = a+=a, b+=b;
57 /* This returns 6 */
58 return a;