Richard Smith | c7a05a9 | 2016-06-29 21:17:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++1z -verify %s -Wno-vexing-parse |
| 2 | |
| 3 | int g, h; |
| 4 | typedef int T; |
| 5 | int f() { |
| 6 | // init-statement declarations |
| 7 | if (T n = 0; n != 0) {} // expected-error {{not yet supported}} |
| 8 | if (T f(); f()) {} // expected-error {{not yet supported}} |
| 9 | if (T(f()); f()) {} // expected-error {{not yet supported}} |
| 10 | if (T(f()), g, h; f()) {} // expected-error {{not yet supported}} |
| 11 | if (T f(); f()) {} // expected-error {{not yet supported}} |
| 12 | if (T f(), g, h; f()) {} // expected-error {{not yet supported}} |
Richard Smith | b8c414c | 2016-06-30 20:24:30 +0000 | [diff] [blame^] | 13 | if (T(n) = 0; n) {} // expected-error {{not yet supported}} |
Richard Smith | c7a05a9 | 2016-06-29 21:17:59 +0000 | [diff] [blame] | 14 | |
| 15 | // init-statement expressions |
| 16 | if (T{f()}; f()) {} // expected-error {{not yet supported}} |
| 17 | if (T{f()}, g, h; f()) {} // expected-error {{not yet supported}} expected-warning 2{{unused}} |
| 18 | if (T(f()), g, h + 1; f()) {} // expected-error {{not yet supported}} expected-warning 2{{unused}} |
| 19 | |
| 20 | // condition declarations |
| 21 | if (T(n){g}) {} |
| 22 | if (T f()) {} // expected-error {{function type}} |
| 23 | if (T f(), g, h) {} // expected-error {{function type}} |
Richard Smith | b8c414c | 2016-06-30 20:24:30 +0000 | [diff] [blame^] | 24 | if (T(n) = 0) {} |
Richard Smith | c7a05a9 | 2016-06-29 21:17:59 +0000 | [diff] [blame] | 25 | |
| 26 | // condition expressions |
| 27 | if (T(f())) {} |
| 28 | if (T{f()}) {} |
| 29 | if (T(f()), g, h) {} // expected-warning 2{{unused}} |
| 30 | if (T{f()}, g, h) {} // expected-warning 2{{unused}} |
| 31 | |
Richard Smith | b8c414c | 2016-06-30 20:24:30 +0000 | [diff] [blame^] | 32 | // none of the above, disambiguated as expression (can't be a declaration) |
| 33 | if (T(n)(g)) {} // expected-error {{undeclared identifier 'n'}} |
| 34 | if (T(n)(int())) {} // expected-error {{undeclared identifier 'n'}} |
Richard Smith | c7a05a9 | 2016-06-29 21:17:59 +0000 | [diff] [blame] | 35 | |
| 36 | // Likewise for 'switch' |
| 37 | switch (int n; n) {} // expected-error {{not yet supported}} |
| 38 | switch (g; int g = 5) {} // expected-error {{not yet supported}} |
| 39 | |
| 40 | if (int a, b; int c = a) { // expected-error {{not yet supported}} expected-note 6{{previous}} |
| 41 | int a; // expected-error {{redefinition}} |
| 42 | int b; // expected-error {{redefinition}} |
| 43 | int c; // expected-error {{redefinition}} |
| 44 | } else { |
| 45 | int a; // expected-error {{redefinition}} |
| 46 | int b; // expected-error {{redefinition}} |
| 47 | int c; // expected-error {{redefinition}} |
| 48 | } |
| 49 | } |