blob: 249c976460897a2b0954d27b3f45d2d051ba7671 [file] [log] [blame]
Richard Smith9ca5c422011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Richard Smith938f40b2011-06-11 17:19:42 +00002
3struct 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
11int i = sizeof(S::m); // ok
12int j = sizeof(S::m + 42); // ok
Richard Smith764d2fe2011-12-20 02:08:33 +000013
14
15struct 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 Friedman7bda7f72012-01-18 03:53:45 +000022
23// Make sure the rule for unevaluated operands works correctly with typeid.
24namespace std {
25 class type_info;
26}
27class Poly { virtual ~Poly(); };
28const std::type_info& k = typeid(S::m);
Richard Smithfa0a1f52012-04-05 01:13:04 +000029const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}}
Richard Smitheae99682012-02-25 10:04:07 +000030const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m));
31
32namespace PR11956 {
33 struct X { char a; };
34 struct Y { int f() { return sizeof(X::a); } }; // ok
35
36 struct A { enum E {} E; };
37 struct B { int f() { return sizeof(A::E); } }; // ok
38}