1 // PR c++/50618
2 // { dg-options "-fdump-rtl-expand" }
3 // { dg-do run }
4 
5 struct Base
6 {
7     const int text;
BaseBase8     Base():text(1) {}
BaseBase9     Base(int aText)
10     : text(aText) {}
11 };
12 struct SubA : public virtual Base
13 {
14 protected:
15   int x;
16 public:
SubASubA17   SubA(int aX)
18   : x(aX) {}
19 };
20 class SubB : public virtual Base
21 {};
22 struct Diamond : public SubA, public SubB
23 {
DiamondDiamond24     Diamond(int text)
25     : Base(text), SubA(5), SubB() {}
26 
printTextDiamond27     void printText()
28     {
29         if(text != 2)
30           __builtin_abort();
31         if(x!=5)
32           __builtin_abort();
33     }
34 };
35 
main(int,char **)36 int main(int, char**)
37 {
38     Diamond x(2);
39     x.printText();
40 }
41 
42 // Verify that the SubB() mem-initializer is storing 0 directly into
43 // this->D.whatever rather than into a stack temp that is then copied into the
44 // base field.
45 // { dg-final { scan-rtl-dump "set \[^\n\]*\n\[^\n\]*this\[^\n\]*\n\[^\n\]*const_int 0" "expand" { target { i?86-*-* x86_64-*-* } } } }
46