1 /* This testcase is part of GDB, the GNU debugger.
2 
3    Copyright 2014-2020 Free Software Foundation, Inc.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17 
18 /* Sizeof tests for rvalue references, based on cpsizeof.cc.  */
19 
20 #include <utility>
21 
22 struct Class
23 {
24   int a;
25   char b;
26   long c;
27 
ClassClass28   Class () : a (1), b ('2'), c (3) { }
29 };
30 
31 union Union
32 {
33   Class *kp;
34   char a;
35   int b;
36   long c;
37 };
38 
39 enum Enum { A, B, C, D };
40 
41 typedef unsigned char a4[4];
42 typedef unsigned char a8[8];
43 typedef unsigned char a12[12];
44 typedef Class c4[4];
45 typedef Union u8[8];
46 typedef Enum e12[12];
47 
48 #define T(N)					\
49   N N ## obj;					\
50   N&& N ## _rref = std::move (N ## obj);        \
51   N* N ## p = &(N ## obj);			\
52   N*&& N ## p_rref = std::move (N ## p);        \
53   int size_ ## N = sizeof (N ## _rref);		\
54   int size_ ## N ## p = sizeof (N ## p_rref);	\
55 
56 int
main()57 main ()
58 {
59   T (char);
60   T (int);
61   T (long);
62   T (float);
63   T (double);
64   T (a4);
65   T (a8);
66   T (a12);
67   T (Class);
68   T (Union);
69   T (Enum);
70   T (c4);
71   T (u8);
72   T (e12);
73 
74   return 0; /* break here */
75 }
76