head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.10
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.4
	perseant-exfatfs:1.1.1.4.0.8
	perseant-exfatfs-base:1.1.1.4
	netbsd-8-3-RELEASE:1.1.1.3
	netbsd-9-4-RELEASE:1.1.1.3
	netbsd-10-0-RELEASE:1.1.1.4
	netbsd-10-0-RC6:1.1.1.4
	netbsd-10-0-RC5:1.1.1.4
	netbsd-10-0-RC4:1.1.1.4
	netbsd-10-0-RC3:1.1.1.4
	netbsd-10-0-RC2:1.1.1.4
	netbsd-10-0-RC1:1.1.1.4
	netbsd-10:1.1.1.4.0.6
	netbsd-10-base:1.1.1.4
	netbsd-9-3-RELEASE:1.1.1.3
	cjep_sun2x:1.1.1.4.0.4
	cjep_sun2x-base:1.1.1.4
	cjep_staticlib_x-base1:1.1.1.4
	netbsd-9-2-RELEASE:1.1.1.3
	cjep_staticlib_x:1.1.1.4.0.2
	cjep_staticlib_x-base:1.1.1.4
	netbsd-9-1-RELEASE:1.1.1.3
	phil-wifi-20200421:1.1.1.4
	phil-wifi-20200411:1.1.1.4
	phil-wifi-20200406:1.1.1.4
	netbsd-8-2-RELEASE:1.1.1.3
	netbsd-9-0-RELEASE:1.1.1.3
	netbsd-9-0-RC2:1.1.1.3
	netbsd-9-0-RC1:1.1.1.3
	netbsd-9:1.1.1.3.0.16
	netbsd-9-base:1.1.1.3
	phil-wifi-20190609:1.1.1.3
	netbsd-8-1-RELEASE:1.1.1.3
	netbsd-8-1-RC1:1.1.1.3
	pgoyette-compat-merge-20190127:1.1.1.3
	pgoyette-compat-20190127:1.1.1.3
	pgoyette-compat-20190118:1.1.1.3
	pgoyette-compat-1226:1.1.1.3
	pgoyette-compat-1126:1.1.1.3
	pgoyette-compat-1020:1.1.1.3
	pgoyette-compat-0930:1.1.1.3
	pgoyette-compat-0906:1.1.1.3
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.3
	clang-337282:1.1.1.3
	netbsd-8-0-RELEASE:1.1.1.3
	phil-wifi:1.1.1.3.0.14
	phil-wifi-base:1.1.1.3
	pgoyette-compat-0625:1.1.1.3
	netbsd-8-0-RC2:1.1.1.3
	pgoyette-compat-0521:1.1.1.3
	pgoyette-compat-0502:1.1.1.3
	pgoyette-compat-0422:1.1.1.3
	netbsd-8-0-RC1:1.1.1.3
	pgoyette-compat-0415:1.1.1.3
	pgoyette-compat-0407:1.1.1.3
	pgoyette-compat-0330:1.1.1.3
	pgoyette-compat-0322:1.1.1.3
	pgoyette-compat-0315:1.1.1.3
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.3.0.12
	pgoyette-compat-base:1.1.1.3
	netbsd-7-1-1-RELEASE:1.1.1.2
	clang-319952:1.1.1.3
	matt-nb8-mediatek:1.1.1.3.0.10
	matt-nb8-mediatek-base:1.1.1.3
	clang-309604:1.1.1.3
	perseant-stdc-iso10646:1.1.1.3.0.8
	perseant-stdc-iso10646-base:1.1.1.3
	netbsd-8:1.1.1.3.0.6
	netbsd-8-base:1.1.1.3
	prg-localcount2-base3:1.1.1.3
	prg-localcount2-base2:1.1.1.3
	prg-localcount2-base1:1.1.1.3
	prg-localcount2:1.1.1.3.0.4
	prg-localcount2-base:1.1.1.3
	pgoyette-localcount-20170426:1.1.1.3
	bouyer-socketcan-base1:1.1.1.3
	pgoyette-localcount-20170320:1.1.1.3
	netbsd-7-1:1.1.1.2.0.12
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	clang-294123:1.1.1.3
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.3.0.2
	bouyer-socketcan-base:1.1.1.3
	clang-291444:1.1.1.3
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.10
	netbsd-7-nhusb-base:1.1.1.2
	clang-280599:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.8
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	clang-261930:1.1.1.2
	netbsd-7-0:1.1.1.2.0.6
	netbsd-7-0-RELEASE:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	clang-237755:1.1.1.2
	clang-232565:1.1.1.2
	clang-227398:1.1.1.2
	tls-maxphys-base:1.1.1.2
	tls-maxphys:1.1.1.2.0.4
	netbsd-7:1.1.1.2.0.2
	netbsd-7-base:1.1.1.2
	clang-215315:1.1.1.2
	clang-209886:1.1.1.1
	yamt-pagecache:1.1.1.1.0.4
	yamt-pagecache-base9:1.1.1.1
	tls-earlyentropy:1.1.1.1.0.2
	tls-earlyentropy-base:1.1.1.1
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.1
	riastradh-drm2-base3:1.1.1.1
	clang-202566:1.1.1.1
	clang-201163:1.1.1.1
	clang-199312:1.1.1.1
	clang-198450:1.1.1.1
	clang-196603:1.1.1.1
	clang-195771:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2013.11.28.14.14.56;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	ow8OybrawrB1f3fx;

1.1.1.1
date	2013.11.28.14.14.56;	author joerg;	state Exp;
branches
	1.1.1.1.4.1;
next	1.1.1.2;
commitid	ow8OybrawrB1f3fx;

1.1.1.2
date	2014.08.10.17.08.43;	author joerg;	state Exp;
branches
	1.1.1.2.4.1
	1.1.1.2.8.1;
next	1.1.1.3;
commitid	N85tXAN6Ex9VZPLx;

1.1.1.3
date	2017.01.11.10.37.49;	author joerg;	state Exp;
branches
	1.1.1.3.14.1;
next	1.1.1.4;
commitid	CNnUNfII1jgNmxBz;

1.1.1.4
date	2019.11.13.22.22.55;	author joerg;	state dead;
branches;
next	;
commitid	QD8YATxuNG34YJKB;

1.1.1.1.4.1
date	2013.11.28.14.14.56;	author yamt;	state dead;
branches;
next	1.1.1.1.4.2;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.1.4.2
date	2014.05.22.16.19.40;	author yamt;	state Exp;
branches;
next	;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.2.4.1
date	2014.08.10.17.08.43;	author tls;	state dead;
branches;
next	1.1.1.2.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.2.4.2
date	2014.08.19.23.49.18;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.2.8.1
date	2017.03.20.06.53.33;	author pgoyette;	state Exp;
branches;
next	;
commitid	jjw7cAwgyKq7RfKz;

1.1.1.3.14.1
date	2020.04.13.07.50.22;	author martin;	state dead;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// C++ [dcl.init.aggr]p2
struct A { 
  int x;
  struct B { 
    int i;
    int j;
  } b; 
} a1 = { 1, { 2, 3 } };

struct NonAggregate {
  NonAggregate();

  int a, b;
};
NonAggregate non_aggregate_test = { 1, 2 }; // expected-error{{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}

NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}


// C++ [dcl.init.aggr]p3
A a_init = A(); 

// C++ [dcl.init.aggr]p4
int x[] = { 1, 3, 5 };
int x_sizecheck[(sizeof(x) / sizeof(int)) == 3? 1 : -1];
int x2[] = { }; // expected-warning{{zero size arrays are an extension}}

// C++ [dcl.init.aggr]p5
struct StaticMemberTest {
  int i;
  static int s;
  int *j;
} smt = { 1, &smt.i };

// C++ [dcl.init.aggr]p6
char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in array initializer}}

// C++ [dcl.init.aggr]p7
struct TooFew { int a; char* b; int c; }; 
TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}}

struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \
                              // expected-note{{declared here}}
  NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}}
};
struct TooFewError { // expected-error{{implicit default constructor for}}
  int a;
  NoDefaultConstructor nodef; // expected-note{{member is declared here}}
};
TooFewError too_few_okay = { 1, 1 };
TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}}

TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}}
TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}}

NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}}

// C++ [dcl.init.aggr]p8
struct Empty { };
struct EmptyTest {
  Empty s;
  int i;
} empty_test = { { }, 3 };

EmptyTest empty_test2 = { 3 }; // expected-error{{initializer for aggregate with no elements requires explicit braces}}

struct NonEmpty { 
  int a;
  Empty empty;
};
struct NonEmptyTest {
  NonEmpty a, b;
} non_empty_test = { { }, { } };

// C++ [dcl.init.aggr]p9
struct HasReference {
  int i;
  int &j; // expected-note{{uninitialized reference member is here}}
};
int global_int;
HasReference r1 = { 1, global_int };
HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}

// C++ [dcl.init.aggr]p10
// Note: the behavior here is identical to C
int xs[2][2] = { 3, 1, 4, 2 };
float y[4][3] = { { 1 }, { 2 }, { 3 }, { 4 } };

// C++ [dcl.init.aggr]p11
// Note: the behavior here is identical to C
float y2[4][3] = { { 1, 3, 5 }, { 2, 4, 6 }, { 3, 5, 7 } };
float same_as_y2[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 };

// C++ [dcl.init.aggr]p12
struct A2 { 
  int i;
  operator int *();
}; 
struct B2 {
  A2 a1, a2; 
  int *z;
}; 
struct C2 {
  operator A2();
};
struct D2 {
  operator int();
};
A2 a2;
C2 c2; 
D2 d2;
B2 b2 = { 4, a2, a2 };
B2 b2_2 = { 4, d2, 0 };
B2 b2_3 = { c2, a2, a2 };

// C++ [dcl.init.aggr]p15:
union u { int a; char* b; }; // expected-note{{candidate constructor (the implicit copy constructor)}}
u u1 = { 1 }; 
u u2 = u1; 
u u3 = 1; // expected-error{{no viable conversion}}
u u4 = { 0, "asdf" };  // expected-error{{excess elements in union initializer}}
u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'const char [5]'}}
@


1.1.1.1
log
@Import Clang 3.4rc1 r195771.
@
text
@@


1.1.1.2
log
@Import clang 3.6svn r215315.
@
text
@d49 1
a49 1
  NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 2{{in implicit initialization of field 'nodef'}}
d57 1
a57 1
NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}} expected-note {{implicit initialization of array element 0}}
@


1.1.1.2.8.1
log
@Sync with HEAD
@
text
@a1 2
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s
a11 4
#if __cplusplus >= 201103L
// expected-note@@-2 3 {{candidate constructor (the implicit copy constructor) not viable}}
// expected-note@@-3 3 {{candidate constructor (the implicit move constructor) not viable}}
#endif
d13 1
a13 3
#if __cplusplus >= 201103L
// expected-note@@-2 3 {{candidate constructor not viable: requires 0 arguments, but 2 were provided}}
#endif
d16 4
a19 13
NonAggregate non_aggregate_test = { 1, 2 };
#if __cplusplus <= 199711L
// expected-error@@-2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}
#else
// expected-error@@-4 {{no matching constructor for initialization of 'NonAggregate'}}
#endif

NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } };
#if __cplusplus <= 199711L
// expected-error@@-2 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}
#else
// expected-error@@-4 2 {{no matching constructor for initialization of 'NonAggregate'}}
#endif
d41 1
a41 28
TooFew too_few = { 1, "asdf" };
#if __cplusplus <= 199711L
// expected-warning@@-2 {{conversion from string literal to 'char *' is deprecated}}
#else
// expected-warning@@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#endif

struct NoDefaultConstructor {
#if __cplusplus <= 199711L
// expected-note@@-2 3 {{candidate constructor (the implicit copy constructor)}}
// expected-note@@-3 {{declared here}}
#else
// expected-note@@-5 4 {{candidate constructor (the implicit copy constructor)}}
// expected-note@@-6 4 {{candidate constructor (the implicit move constructor)}}
#endif

  NoDefaultConstructor(int);
#if __cplusplus <= 199711L
  // expected-note@@-2 3 {{candidate constructor not viable: requires 1 argument, but 0 were provided}}
#else
  // expected-note@@-4 4 {{candidate constructor not viable: requires 1 argument, but 0 were provided}}
#endif

};
struct TooFewError {
#if __cplusplus <= 199711L
// expected-error@@-2 {{implicit default constructor for}}
#endif
d43 5
d49 1
a49 7
  NoDefaultConstructor nodef;
#if __cplusplus <= 199711L
// expected-note@@-2 {{member is declared here}}
// expected-note@@-3 2{{in implicit initialization of field 'nodef' with omitted initializer}}
#else
// expected-note@@-5 3{{in implicit initialization of field 'nodef' with omitted initializer}}
#endif
d54 1
a54 8
TooFewError too_few_okay2[2] = { 1, 1 };
#if __cplusplus <= 199711L
// expected-note@@-2 {{implicit default constructor for 'TooFewError' first required here}}
#else
// expected-error@@-4 {{no matching constructor for initialization of 'NoDefaultConstructor'}}
// expected-note@@-5 {{in implicit initialization of array element 1 with omitted initializer}}
#endif

a118 4
#if __cplusplus >= 201103L
// expected-note@@-2 {{candidate constructor (the implicit move constructor)}}
#endif

@


1.1.1.3
log
@Import Clang pre-4.0.0 r291444.
@
text
@a1 2
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s
a11 4
#if __cplusplus >= 201103L
// expected-note@@-2 3 {{candidate constructor (the implicit copy constructor) not viable}}
// expected-note@@-3 3 {{candidate constructor (the implicit move constructor) not viable}}
#endif
d13 1
a13 3
#if __cplusplus >= 201103L
// expected-note@@-2 3 {{candidate constructor not viable: requires 0 arguments, but 2 were provided}}
#endif
d16 4
a19 13
NonAggregate non_aggregate_test = { 1, 2 };
#if __cplusplus <= 199711L
// expected-error@@-2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}
#else
// expected-error@@-4 {{no matching constructor for initialization of 'NonAggregate'}}
#endif

NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } };
#if __cplusplus <= 199711L
// expected-error@@-2 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}
#else
// expected-error@@-4 2 {{no matching constructor for initialization of 'NonAggregate'}}
#endif
d41 1
a41 28
TooFew too_few = { 1, "asdf" };
#if __cplusplus <= 199711L
// expected-warning@@-2 {{conversion from string literal to 'char *' is deprecated}}
#else
// expected-warning@@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#endif

struct NoDefaultConstructor {
#if __cplusplus <= 199711L
// expected-note@@-2 3 {{candidate constructor (the implicit copy constructor)}}
// expected-note@@-3 {{declared here}}
#else
// expected-note@@-5 4 {{candidate constructor (the implicit copy constructor)}}
// expected-note@@-6 4 {{candidate constructor (the implicit move constructor)}}
#endif

  NoDefaultConstructor(int);
#if __cplusplus <= 199711L
  // expected-note@@-2 3 {{candidate constructor not viable: requires 1 argument, but 0 were provided}}
#else
  // expected-note@@-4 4 {{candidate constructor not viable: requires 1 argument, but 0 were provided}}
#endif

};
struct TooFewError {
#if __cplusplus <= 199711L
// expected-error@@-2 {{implicit default constructor for}}
#endif
d43 5
d49 1
a49 7
  NoDefaultConstructor nodef;
#if __cplusplus <= 199711L
// expected-note@@-2 {{member is declared here}}
// expected-note@@-3 2{{in implicit initialization of field 'nodef' with omitted initializer}}
#else
// expected-note@@-5 3{{in implicit initialization of field 'nodef' with omitted initializer}}
#endif
d54 1
a54 8
TooFewError too_few_okay2[2] = { 1, 1 };
#if __cplusplus <= 199711L
// expected-note@@-2 {{implicit default constructor for 'TooFewError' first required here}}
#else
// expected-error@@-4 {{no matching constructor for initialization of 'NoDefaultConstructor'}}
// expected-note@@-5 {{in implicit initialization of array element 1 with omitted initializer}}
#endif

a118 4
#if __cplusplus >= 201103L
// expected-note@@-2 {{candidate constructor (the implicit move constructor)}}
#endif

@


1.1.1.3.14.1
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.4
log
@Mark old LLVM instance as dead.
@
text
@@


1.1.1.2.4.1
log
@file dcl_init_aggr.cpp was added on branch tls-maxphys on 2014-08-19 23:49:18 +0000
@
text
@d1 123
@


1.1.1.2.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 123
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// C++ [dcl.init.aggr]p2
struct A { 
  int x;
  struct B { 
    int i;
    int j;
  } b; 
} a1 = { 1, { 2, 3 } };

struct NonAggregate {
  NonAggregate();

  int a, b;
};
NonAggregate non_aggregate_test = { 1, 2 }; // expected-error{{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}

NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}


// C++ [dcl.init.aggr]p3
A a_init = A(); 

// C++ [dcl.init.aggr]p4
int x[] = { 1, 3, 5 };
int x_sizecheck[(sizeof(x) / sizeof(int)) == 3? 1 : -1];
int x2[] = { }; // expected-warning{{zero size arrays are an extension}}

// C++ [dcl.init.aggr]p5
struct StaticMemberTest {
  int i;
  static int s;
  int *j;
} smt = { 1, &smt.i };

// C++ [dcl.init.aggr]p6
char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in array initializer}}

// C++ [dcl.init.aggr]p7
struct TooFew { int a; char* b; int c; }; 
TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}}

struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \
                              // expected-note{{declared here}}
  NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}}
};
struct TooFewError { // expected-error{{implicit default constructor for}}
  int a;
  NoDefaultConstructor nodef; // expected-note{{member is declared here}} expected-note 2{{in implicit initialization of field 'nodef'}}
};
TooFewError too_few_okay = { 1, 1 };
TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}}

TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}}
TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}}

NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}} expected-note {{implicit initialization of array element 0}}

// C++ [dcl.init.aggr]p8
struct Empty { };
struct EmptyTest {
  Empty s;
  int i;
} empty_test = { { }, 3 };

EmptyTest empty_test2 = { 3 }; // expected-error{{initializer for aggregate with no elements requires explicit braces}}

struct NonEmpty { 
  int a;
  Empty empty;
};
struct NonEmptyTest {
  NonEmpty a, b;
} non_empty_test = { { }, { } };

// C++ [dcl.init.aggr]p9
struct HasReference {
  int i;
  int &j; // expected-note{{uninitialized reference member is here}}
};
int global_int;
HasReference r1 = { 1, global_int };
HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}

// C++ [dcl.init.aggr]p10
// Note: the behavior here is identical to C
int xs[2][2] = { 3, 1, 4, 2 };
float y[4][3] = { { 1 }, { 2 }, { 3 }, { 4 } };

// C++ [dcl.init.aggr]p11
// Note: the behavior here is identical to C
float y2[4][3] = { { 1, 3, 5 }, { 2, 4, 6 }, { 3, 5, 7 } };
float same_as_y2[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 };

// C++ [dcl.init.aggr]p12
struct A2 { 
  int i;
  operator int *();
}; 
struct B2 {
  A2 a1, a2; 
  int *z;
}; 
struct C2 {
  operator A2();
};
struct D2 {
  operator int();
};
A2 a2;
C2 c2; 
D2 d2;
B2 b2 = { 4, a2, a2 };
B2 b2_2 = { 4, d2, 0 };
B2 b2_3 = { c2, a2, a2 };

// C++ [dcl.init.aggr]p15:
union u { int a; char* b; }; // expected-note{{candidate constructor (the implicit copy constructor)}}
u u1 = { 1 }; 
u u2 = u1; 
u u3 = 1; // expected-error{{no viable conversion}}
u u4 = { 0, "asdf" };  // expected-error{{excess elements in union initializer}}
u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'const char [5]'}}
@


1.1.1.1.4.1
log
@file dcl_init_aggr.cpp was added on branch yamt-pagecache on 2014-05-22 16:19:40 +0000
@
text
@d1 123
@


1.1.1.1.4.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 123
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
// C++ [dcl.init.aggr]p2
struct A { 
  int x;
  struct B { 
    int i;
    int j;
  } b; 
} a1 = { 1, { 2, 3 } };

struct NonAggregate {
  NonAggregate();

  int a, b;
};
NonAggregate non_aggregate_test = { 1, 2 }; // expected-error{{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}

NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}


// C++ [dcl.init.aggr]p3
A a_init = A(); 

// C++ [dcl.init.aggr]p4
int x[] = { 1, 3, 5 };
int x_sizecheck[(sizeof(x) / sizeof(int)) == 3? 1 : -1];
int x2[] = { }; // expected-warning{{zero size arrays are an extension}}

// C++ [dcl.init.aggr]p5
struct StaticMemberTest {
  int i;
  static int s;
  int *j;
} smt = { 1, &smt.i };

// C++ [dcl.init.aggr]p6
char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in array initializer}}

// C++ [dcl.init.aggr]p7
struct TooFew { int a; char* b; int c; }; 
TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}}

struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \
                              // expected-note{{declared here}}
  NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}}
};
struct TooFewError { // expected-error{{implicit default constructor for}}
  int a;
  NoDefaultConstructor nodef; // expected-note{{member is declared here}}
};
TooFewError too_few_okay = { 1, 1 };
TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}}

TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}}
TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}}

NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}}

// C++ [dcl.init.aggr]p8
struct Empty { };
struct EmptyTest {
  Empty s;
  int i;
} empty_test = { { }, 3 };

EmptyTest empty_test2 = { 3 }; // expected-error{{initializer for aggregate with no elements requires explicit braces}}

struct NonEmpty { 
  int a;
  Empty empty;
};
struct NonEmptyTest {
  NonEmpty a, b;
} non_empty_test = { { }, { } };

// C++ [dcl.init.aggr]p9
struct HasReference {
  int i;
  int &j; // expected-note{{uninitialized reference member is here}}
};
int global_int;
HasReference r1 = { 1, global_int };
HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}

// C++ [dcl.init.aggr]p10
// Note: the behavior here is identical to C
int xs[2][2] = { 3, 1, 4, 2 };
float y[4][3] = { { 1 }, { 2 }, { 3 }, { 4 } };

// C++ [dcl.init.aggr]p11
// Note: the behavior here is identical to C
float y2[4][3] = { { 1, 3, 5 }, { 2, 4, 6 }, { 3, 5, 7 } };
float same_as_y2[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 };

// C++ [dcl.init.aggr]p12
struct A2 { 
  int i;
  operator int *();
}; 
struct B2 {
  A2 a1, a2; 
  int *z;
}; 
struct C2 {
  operator A2();
};
struct D2 {
  operator int();
};
A2 a2;
C2 c2; 
D2 d2;
B2 b2 = { 4, a2, a2 };
B2 b2_2 = { 4, d2, 0 };
B2 b2_3 = { c2, a2, a2 };

// C++ [dcl.init.aggr]p15:
union u { int a; char* b; }; // expected-note{{candidate constructor (the implicit copy constructor)}}
u u1 = { 1 }; 
u u2 = u1; 
u u3 = 1; // expected-error{{no viable conversion}}
u u4 = { 0, "asdf" };  // expected-error{{excess elements in union initializer}}
u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'const char [5]'}}
@


