1 // RUN: %clang_cc1 -std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both %s
2 // RUN: %clang_cc1 -std=c++2a -fsyntax-only -fcxx-exceptions -verify=expected,both %s -fexperimental-new-constant-interpreter
6 S() requires (N
==1) = default;
7 S() requires (N
==2) {} // both-note {{declared here}}
8 consteval
S() requires (N
==3) = default;
11 consteval
int aConstevalFunction() { // both-error {{consteval function never produces a constant expression}}
12 S
<2> s4
; // both-note {{non-constexpr constructor 'S' cannot be used in a constant expression}}
15 /// We're NOT calling the above function. The diagnostics should appear anyway.
19 virtual constexpr char f() const { return 'Z'; }
26 virtual const A
*f() const;
29 struct Covariant3
: Covariant1
{
30 constexpr virtual const D
*f() const { return &this->d
; }
33 constexpr Covariant3 cb
;
34 constexpr const Covariant1
*cb1
= &cb
;
35 static_assert(cb1
->f()->a
== 'Z');
42 constexpr void operator+=(char c
) { buf
[n
++] = c
; }
43 constexpr bool operator==(const char *str
) const {
47 for (int i
= 0; i
< n
; ++i
) {
53 return __builtin_memcmp(str
, buf
, n
) == 0;
55 constexpr bool operator!=(const char *str
) const { return !operator==(str
); }
59 constexpr A(Buf
&buf
, char c
) : buf(buf
), c(c
) { buf
+= c
; }
60 constexpr ~A() { buf
+= (c
- 32);}
61 constexpr operator bool() const { return true; }
66 constexpr void abnormal_termination(Buf
&buf
) {
67 struct Indestructible
{
68 constexpr ~Indestructible(); // not defined
74 for (A
&&c
= A(buf
, 'c'); A d
= A(buf
, 'd'); A(buf
, 'e')) {
75 switch (A
f(buf
, 'f'); A g
= A(buf
, 'g')) { // both-warning {{boolean}}
94 Indestructible indest
;
97 A j
= (A(buf
, 'i'), A(buf
, 'j'));
101 constexpr bool check_abnormal_termination() {
103 abnormal_termination(buf
);
106 "dfgh" /*break*/ "HGFijIJeED"
107 "dfgh" /*continue*/ "HGFeED"
108 "dfgh" /*return*/ "HGFD"
111 static_assert(check_abnormal_termination());