1 // RUN: %clang_cc1 -std=c++98 %s -Wno-unused -verify
2 // RUN: %clang_cc1 -std=c++11 %s -Wno-unused -verify
3 // RUN: %clang_cc1 -std=c++2a %s -Wno-unused -verify
8 const int a
= 1; // expected-note {{here}}
10 #if __cplusplus >= 201103L
11 constexpr int arr
[3] = {1, 2, 3}; // expected-note 2{{here}}
13 struct S
{ int x
; int f() const; };
14 constexpr S s
= {0}; // expected-note 3{{here}}
15 constexpr S
*ps
= nullptr;
16 S
*const &psr
= ps
; // expected-note 2{{here}}
24 #if __cplusplus >= 201103L
25 // subscripting operation with an array operand
28 use((+arr
)[i
]); // expected-error {{reference to local variable}}
29 use(i
[+arr
]); // expected-error {{reference to local variable}}
31 // class member access naming non-static data member
33 use(s
.f()); // expected-error {{reference to local variable}}
34 use((&s
)->x
); // expected-error {{reference to local variable}}
35 use(ps
->x
); // ok (lvalue-to-rvalue conversion applied to id-expression)
36 use(psr
->x
); // expected-error {{reference to local variable}}
38 // class member access naming a static data member
39 // FIXME: How to test this?
41 // pointer-to-member expression
43 use((s
.*&S::f
)()); // expected-error {{reference to local variable}}
44 use(ps
->*&S::x
); // ok (lvalue-to-rvalue conversion applied to id-expression)
45 use(psr
->*&S::x
); // expected-error {{reference to local variable}}
50 #if __cplusplus >= 201103L
54 // glvalue conditional expression
60 // FIXME: This is not an odr-use because it is a discarded-value
61 // expression applied to an expression whose potential result is 'a'.
62 use((a
, a
)); // expected-error {{reference to local variable}}
64 // (and combinations thereof)
66 #if __cplusplus >= 201103L
67 use(a
? (i
, a
) : arr
[a
? s
.x
: arr
[a
]]);
73 // FIXME: Test that this behaves properly.
74 namespace std_example
{
75 struct S
{ static const int x
= 0, y
= 0; };
76 const int &f(const int &r
);