blob: 7ca1f0e4513e4740b1629ed61762f72c5d643bfd (
plain) (
blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++0x -Wall %s
struct Bitfield {
int n : 3 = 7; // expected-error {{bitfield member cannot have an in-class initializer}}
};
int a;
class NoWarning {
int &n = a;
public:
int &GetN() { return n; }
};
bool b();
int k;
struct Recurse {
int &n = b() ? Recurse().n : k; // ok
};
struct UnknownBound {
int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
int bs[4] = { 4, 5, 6, 7 };
int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
};
template<int n> struct T { static const int B; };
template<> struct T<2> { template<int C, int D> using B = int; };
const int C = 0, D = 0;
struct S {
int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
T<sizeof(as) / sizeof(int)> x; // expected-error {{requires a type specifier}}
};
struct ThrowCtor { ThrowCtor(int) noexcept(false); };
struct NoThrowCtor { NoThrowCtor(int) noexcept(true); };
struct Throw { ThrowCtor tc = 42; };
struct NoThrow { NoThrowCtor tc = 42; };
static_assert(!noexcept(Throw()), "incorrect exception specification");
static_assert(noexcept(NoThrow()), "incorrect exception specification");
struct CheckExcSpec {
CheckExcSpec() noexcept(true) = default;
int n = 0;
};
struct CheckExcSpecFail {
CheckExcSpecFail() noexcept(true) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}}
ThrowCtor tc = 123;
};
struct TypedefInit {
typedef int A = 0; // expected-error {{illegal initializer}}
};
|