Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/pr78890-2.C

raw
1 // PR c++/78890
2 // { dg-do compile { target c++11 } }
3
4 template <typename T>
5 int
6 foo ()
7 {
8 union {
9 int a;
10 int &b = a; // { dg-error "may not have reference type" }
11 };
12 a = 1;
13 auto c = b + 1;
14 return c;
15 }
16
17 template <typename T>
18 T
19 bar ()
20 {
21 union {
22 T a;
23 T &b = a; // { dg-error "may not have reference type" }
24 };
25 a = 1;
26 auto c = b + 1;
27 return c;
28 }
29
30 template <typename T, typename U>
31 T baz()
32 {
33 union {
34 T a;
35 U b = a; // { dg-error "may not have reference type" }
36 };
37 a = 1;
38 auto c = b + 1;
39 return c;
40 }
41
42 int a = foo<int> ();
43 int b = bar<int> ();
44 int c = baz<int, int &> ();