1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c++11 %s
3 // Make sure we handle contexts correctly with sizeof
4 template<typename T
> void f(T n
) {
6 [] { int x
= sizeof(sizeof(buffer
)); }();
12 // Make sure we handle references to non-static data members in unevaluated
13 // contexts in class template methods correctly. Previously we assumed these
14 // would be valid MemberRefExprs, but they have no 'this' so we need to form a
15 // DeclRefExpr to the FieldDecl instead.
19 M() {}; // expected-note {{in instantiation of default member initializer 'M<S>::m' requested here}}
20 int m
= *T::x
; // expected-error {{invalid use of non-static data member 'x'}}
23 static_assert(sizeof(T::x
) == 8, "ptr");
24 static_assert(sizeof(*T::x
) == 4, "int");
28 template struct M
<S
>; // expected-note {{in instantiation of member function 'M<S>::M' requested here}}
30 // Similar test case for PR26893.
31 template <typename T
=void>
33 struct foo
{ int array
[10]; };
34 int baz() { return sizeof(foo::array
); }
36 template struct bar
<>;