Richard Smith | 9ca5c42 | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Richard Smith | 938f40b | 2011-06-11 17:19:42 +0000 | [diff] [blame] | 2 | |
| 3 | struct S { |
| 4 | int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}} |
| 5 | int *m = &n; // ok |
| 6 | |
| 7 | int n = f(); // ok |
| 8 | int f(); |
| 9 | }; |
| 10 | |
| 11 | int i = sizeof(S::m); // ok |
| 12 | int j = sizeof(S::m + 42); // ok |
Richard Smith | 764d2fe | 2011-12-20 02:08:33 +0000 | [diff] [blame] | 13 | |
| 14 | |
| 15 | struct T { |
| 16 | int n; |
| 17 | static void f() { |
| 18 | int a[n]; // expected-error {{invalid use of member 'n' in static member function}} |
| 19 | int b[sizeof n]; // ok |
| 20 | } |
| 21 | }; |
Eli Friedman | 7bda7f7 | 2012-01-18 03:53:45 +0000 | [diff] [blame^] | 22 | |
| 23 | // Make sure the rule for unevaluated operands works correctly with typeid. |
| 24 | namespace std { |
| 25 | class type_info; |
| 26 | } |
| 27 | class Poly { virtual ~Poly(); }; |
| 28 | const std::type_info& k = typeid(S::m); |
| 29 | const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of nonstatic data member}} |