1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
27a614d8380297fcd2bc23986241905d97222948cRichard Smith
37a614d8380297fcd2bc23986241905d97222948cRichard Smith// Make sure we don't run off the end of the stream when parsing a deferred
47a614d8380297fcd2bc23986241905d97222948cRichard Smith// initializer.
57a614d8380297fcd2bc23986241905d97222948cRichard Smithint a; // expected-note {{previous}}
67a614d8380297fcd2bc23986241905d97222948cRichard Smithstruct S {
77a614d8380297fcd2bc23986241905d97222948cRichard Smith  int n = 4 + ; // expected-error {{expected expression}}
87a614d8380297fcd2bc23986241905d97222948cRichard Smith} a; // expected-error {{redefinition}}
97a614d8380297fcd2bc23986241905d97222948cRichard Smith
107a614d8380297fcd2bc23986241905d97222948cRichard Smith// Make sure we use all of the tokens.
117a614d8380297fcd2bc23986241905d97222948cRichard Smithstruct T {
127a614d8380297fcd2bc23986241905d97222948cRichard Smith  int a = 1 // expected-error {{expected ';' at end of declaration list}}
137a614d8380297fcd2bc23986241905d97222948cRichard Smith  int b = 2;
147a614d8380297fcd2bc23986241905d97222948cRichard Smith  int c = b; // expected-error {{undeclared identifier}}
157a614d8380297fcd2bc23986241905d97222948cRichard Smith};
16a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl
17a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl// Test recovery for bad constructor initializers
18a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl
19a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redlstruct R1 {
20a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl  int a;
21a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl  R1() : a {}
22a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl}; // expected-error {{expected '{' or ','}}
23a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl
24a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl// Test correct parsing.
25a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl
26a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redlstruct V1 {
27a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl  int a, b;
28a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl  V1() : a(), b{} {}
29a891a32d3762ee641a29c091d286f2a7432671a5Sebastian Redl};
309bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith
319bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smithtemplate <typename, typename> struct T1 { enum {V};};
329bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smithtemplate <int, int> struct T2 { enum {V};};
339bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smithstruct A {
349bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith  T1<int, int> a1 = T1<int, int>(), *a2 = new T1<int,int>;
359bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith  T2<0,0> b1 = T2<0,0>(), b2 = T2<0,0>(), b3;
369bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith  bool c1 = 1 < 2, c2 = 2 < 1, c3 = false;
379bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith  bool d1 = T1<int, T1<int, int>>::V < 3, d2;
389bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith  T1<int, int()> e = T1<int, int()>();
399bd3cdc3b78653275a36f15df81e1def3b2db8dbRichard Smith};
40c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines
41c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesstruct PR19993 {
42c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines  static int n = delete; // expected-error {{only functions can have deleted definitions}}
43c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines};
44