annotate gcc/testsuite/g++.dg/cpp1y/auto-fn15.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do compile { target c++14 } }
kono
parents:
diff changeset
2 // { dg-options "-Wno-return-local-addr" }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 template<class,class> struct same_type;
kono
parents:
diff changeset
5 template<class T> struct same_type<T,T> {};
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 int& f();
kono
parents:
diff changeset
8 int i;
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 decltype(auto) g() { return f(); }
kono
parents:
diff changeset
11 decltype(auto) h1() { return i; }
kono
parents:
diff changeset
12 decltype(auto) h2() { return (i); }
kono
parents:
diff changeset
13 decltype(auto) h2a() { return 0,i; }
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 struct A { int i; };
kono
parents:
diff changeset
16 A a;
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 decltype(auto) h3() { return a.i; }
kono
parents:
diff changeset
19 decltype(auto) h4() { return (a.i); }
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 template <class T>
kono
parents:
diff changeset
22 decltype(auto) h5(T t) { return t.i; }
kono
parents:
diff changeset
23 template <class T>
kono
parents:
diff changeset
24 decltype(auto) h6(T t) { return (t.i); }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
25 template <class T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 decltype(auto) h7(T t) { return (i); }
111
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 int main()
kono
parents:
diff changeset
29 {
kono
parents:
diff changeset
30 decltype(auto) i = f();
kono
parents:
diff changeset
31 same_type<decltype(i),int&>();
kono
parents:
diff changeset
32 decltype(auto) i2 = i;
kono
parents:
diff changeset
33 same_type<decltype(i2),int&>();
kono
parents:
diff changeset
34 decltype(auto) i3 = ::i;
kono
parents:
diff changeset
35 same_type<decltype(i3),int>();
kono
parents:
diff changeset
36 decltype(auto) i4 = (::i);
kono
parents:
diff changeset
37 same_type<decltype(i4),int&>();
kono
parents:
diff changeset
38 decltype(auto) i5 = a.i;
kono
parents:
diff changeset
39 same_type<decltype(i5),int>();
kono
parents:
diff changeset
40 decltype(auto) i6 = (a.i);
kono
parents:
diff changeset
41 same_type<decltype(i6),int&>();
kono
parents:
diff changeset
42 decltype(auto) i7 = true ? ::i : ::i;
kono
parents:
diff changeset
43 same_type<decltype(i7),int&>();
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 same_type<decltype(g()),int&>();
kono
parents:
diff changeset
46 same_type<decltype(h1()),int>();
kono
parents:
diff changeset
47 same_type<decltype(h2()),int&>();
kono
parents:
diff changeset
48 same_type<decltype(h2a()),int&>();
kono
parents:
diff changeset
49 same_type<decltype(h3()),int>();
kono
parents:
diff changeset
50 same_type<decltype(h4()),int&>();
kono
parents:
diff changeset
51 same_type<decltype(h5(a)),int>();
kono
parents:
diff changeset
52 same_type<decltype(h6(a)),int&>();
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 same_type<decltype(h7(a)),int&>();
111
kono
parents:
diff changeset
54 }