1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=both,expected -std=c++98 %s
2 // RUN: %clang_cc1 -verify=both,ref -std=c++98 %s
8 const int &p
= k
; // both-note {{declared here}}
9 template<int n
> struct S
{};
10 S
<p
> s
; // both-error {{not an integral constant expression}} \
11 // both-note {{read of variable 'p' of non-integral, non-enumeration type 'const int &'}}
15 template <int> struct C
{};
16 template struct C
<cval
>;
19 /// FIXME: This example does not get properly diagnosed in the new interpreter.
20 extern const int recurse1
;
21 const int recurse2
= recurse1
; // both-note {{declared here}}
22 const int recurse1
= 1;
24 int array2
[recurse2
]; // ref-warning 2{{variable length array}} \
25 // both-note {{initializer of 'recurse2' is not a constant expression}} \
26 // expected-warning {{variable length array}} \
27 // expected-error {{variable length array}}
29 int NCI
; // both-note {{declared here}}
30 int NCIA
[NCI
]; // both-warning {{variable length array}} \
31 // both-error {{variable length array}} \\
32 // both-note {{read of non-const variable 'NCI'}}
37 banana
V() : c("i") {} // both-error {{unknown type name 'banana'}} \
38 // both-error {{constructor cannot have a return type}}
40 _Static_assert(V().c
[0], ""); // both-error {{is not an integral constant expression}}
43 template<typename U
> static U Data
; // both-warning {{C++14 extension}}
44 template<typename U
> static const U Data
<U
*> = U();
46 const int c0_test
= C0::Data
<int*>;
47 _Static_assert(c0_test
== 0, "");
50 int a
= 0; // both-note {{declared here}}
51 _Static_assert(a
== 0, ""); // both-error {{static assertion expression is not an integral constant expression}} \
52 // both-note {{read of non-const variable 'a' is not allowed in a constant expression}}
54 struct SelfReference
{ SelfReference
&r
; };
55 extern SelfReference self_reference_1
;
56 SelfReference self_reference_2
= {self_reference_1
};
60 } const PR65784
[] = {(int *)""};
61 PR65784s
PR65784f() { return *PR65784
; }