summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/class-base-member-init.cpp
blob: 7095d92d6852380bb3ac49a9365e997dcfb7007f (plain)
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
// RUN: %clang_cc1 -fsyntax-only -verify %s

class S {
public:
  S (); 
};

struct D : S {
  D() : 
    b1(0), // expected-note {{previous initialization is here}}
    b2(1),
    b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
    S(),   // expected-note {{previous initialization is here}}
    S()    // expected-error {{multiple initializations given for base 'S'}}
    {}
  int b1;
  int b2;
};

struct A {
  struct {
    int a;
    int b; 
  };
  A();
};

A::A() : a(10), b(20) { }

namespace Test1 {
  template<typename T> struct A {};
  template<typename T> struct B : A<T> {

    B() : A<T>(), // expected-note {{previous initialization is here}} 
      A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
  };
}

namespace Test2 {
  template<typename T> struct A : T {
    A() : T(), // expected-note {{previous initialization is here}}
      T() { } // expected-error {{multiple initializations given for base 'T'}}
  };
}

namespace Test3 {
  template<typename T> struct A {
    T t;
    
    A() : t(1), // expected-note {{previous initialization is here}}
      t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
  };
}
OpenPOWER on IntegriCloud