1 // { dg-do compile { target c++14 } }
2 // { dg-options "-Wno-return-local-addr" }
4 template<class,class> struct same_type;
5 template<class T> struct same_type<T,T> {};
10 decltype(auto) g() { return f(); }
11 decltype(auto) h1() { return i; }
12 decltype(auto) h2() { return (i); }
13 decltype(auto) h2a() { return 0,i; }
18 decltype(auto) h3() { return a.i; }
19 decltype(auto) h4() { return (a.i); }
22 decltype(auto) h5(T t) { return t.i; }
24 decltype(auto) h6(T t) { return (t.i); }
26 decltype(auto) h7(T t) { return (i); }
30 decltype(auto) i = f();
31 same_type<decltype(i),int&>();
32 decltype(auto) i2 = i;
33 same_type<decltype(i2),int&>();
34 decltype(auto) i3 = ::i;
35 same_type<decltype(i3),int>();
36 decltype(auto) i4 = (::i);
37 same_type<decltype(i4),int&>();
38 decltype(auto) i5 = a.i;
39 same_type<decltype(i5),int>();
40 decltype(auto) i6 = (a.i);
41 same_type<decltype(i6),int&>();
42 decltype(auto) i7 = true ? ::i : ::i;
43 same_type<decltype(i7),int&>();
45 same_type<decltype(g()),int&>();
46 same_type<decltype(h1()),int>();
47 same_type<decltype(h2()),int&>();
48 same_type<decltype(h2a()),int&>();
49 same_type<decltype(h3()),int>();
50 same_type<decltype(h4()),int&>();
51 same_type<decltype(h5(a)),int>();
52 same_type<decltype(h6(a)),int&>();
53 same_type<decltype(h7(a)),int&>();