1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Check that "::new" and "::delete" in member initializer list are diagnosed
4 // correctly and don't lead to infinite loop on parsing.
6 // Error: X() (initializer on non-constructor), "::new" is skipped.
7 void f1() : X() ::new{}; // expected-error{{only constructors take base initializers}}
9 // Errors: first "::delete" and initializer on non-constructor, others skipped.
10 void f2() : ::delete, ::new, X() ::new ::delete{} // expected-error{{expected class member or base class name}}
11 // expected-error@-1{{only constructors take base initializers}}
13 // Errors: the '::' token, "::delete" and initializer on non-constructor, others skipped.
14 void f3() : ::, ::delete X(), ::new {}; // expected-error2{{expected class member or base class name}}
15 // expected-error@-1{{only constructors take base initializers}}
20 Base1(T a1
) : x1(a1
) {}
26 Base2(T a2
) : x2(a2
) {}
29 struct S
: public Base1
<int>, public Base2
<float> {
32 // 1-st initializer is correct (just missing ','), 2-nd incorrect, skip other.
33 S() : ::Base1
<int>(0) ::new, ::Base2
<float>(1.0) ::delete x(2) {} // expected-error{{expected class member or base class name}}
34 // expected-error@-1{{missing ',' between base or member initializers}}
36 // 1-st and 2-nd are correct, errors: '::' and "::new", others skipped.
37 S(int a
) : Base1
<int>(a
), ::Base2
<float>(1.0), ::, // expected-error{{expected class member or base class name}}
38 ::new, ! ::delete, ::Base2
<() x(3) {} // expected-error{{expected class member or base class name}}
40 // All initializers are correct, nothing to skip, diagnose 2 missing commas.
41 S(const S
&) : Base1
<int>(0) ::Base2
<float>(1.0) x(2) {} // expected-error2{{missing ',' between base or member initializers}}