blob: 95651436eb791f5a46c8c1f680934f7eaed08e66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// P0892R2
// { dg-do compile }
// Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'.
// { dg-options "-std=c++2a" }
int foo() { return 42; }
int g;
struct S {
explicit(foo()) S(int); // { dg-error "call to" }
explicit(int) S(int, int); // { dg-error "expected" }
explicit(false ? 1 : throw 1) S(int, int, int); // { dg-error "not a constant" }
};
struct S2 {
explicit(true) S2();
explicit(false) S2(); // { dg-error "cannot be overloaded" }
};
int
main ()
{
S s1 = { 1 };
S s2 = { 1, 2 }; // { dg-error "could not convert" }
S s3 = { 1, 2, 3 };
}
|