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
) { // expected-note {{declared here}}
5 int buffer
[n
]; // expected-warning {{variable length arrays in C++ are a Clang extension}} \
6 expected
-note
{{function parameter
'n' with unknown value cannot be used in a constant expression
}} \
7 expected
-note@
#instantiate {{in instantiation of function template specialization 'f<int>' requested here}}
8 [] { int x
= sizeof(sizeof(buffer
)); }();
11 f
<int>(1); // #instantiate
14 // Make sure we handle references to non-static data members in unevaluated
15 // contexts in class template methods correctly. Previously we assumed these
16 // would be valid MemberRefExprs, but they have no 'this' so we need to form a
17 // DeclRefExpr to the FieldDecl instead.
21 M() {}; // expected-note {{in instantiation of default member initializer 'M<S>::m' requested here}}
22 int m
= *T::x
; // expected-error {{invalid use of non-static data member 'x'}}
25 static_assert(sizeof(T::x
) == 8, "ptr");
26 static_assert(sizeof(*T::x
) == 4, "int");
30 template struct M
<S
>; // expected-note {{in instantiation of member function 'M<S>::M' requested here}}
32 // Similar test case for PR26893.
33 template <typename T
=void>
35 struct foo
{ int array
[10]; };
36 int baz() { return sizeof(foo::array
); }
38 template struct bar
<>;