comparison clang/test/SemaTemplate/instantiate-member-initializers.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
comparison
equal deleted inserted replaced
147:c2174574ed3a 150:1d019706d866
1 // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
2
3 template<typename T> struct A {
4 A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
5
6 T a;
7 };
8
9 A<int> a0;
10 A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
11
12 template<typename T> struct B {
13 B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
14 a(2) { }
15
16 int a;
17 int b;
18 };
19
20 B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
21
22 template <class T> struct AA { AA(int); };
23 template <class T> class BB : public AA<T> {
24 public:
25 BB() : AA<T>(1) {}
26 };
27 BB<int> x;
28
29 struct X {
30 X();
31 };
32 template<typename T>
33 struct Y {
34 Y() : x() {}
35 X x;
36 };
37 Y<int> y;
38
39 template<typename T> struct Array {
40 int a[3];
41 Array() : a() {}
42 };
43 Array<int> s;