annotate gcc/testsuite/g++.dg/template/qualttp19.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 }
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 // Copyright (C) 2001 Free Software Foundation, Inc.
kono
parents:
diff changeset
4 // Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 // PR 2645
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 template <typename T>
kono
parents:
diff changeset
9 struct call_traits
kono
parents:
diff changeset
10 {
kono
parents:
diff changeset
11 public:
kono
parents:
diff changeset
12 typedef T type_less_spec;
kono
parents:
diff changeset
13 };
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 template <typename T>
kono
parents:
diff changeset
16 struct call_traits<T&>
kono
parents:
diff changeset
17 {
kono
parents:
diff changeset
18 typedef T type_more_spec;
kono
parents:
diff changeset
19 };
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 int main()
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 int num;
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 // Two typedefs lead to the instant. of the less spec. ("wrong") template
kono
parents:
diff changeset
27 typedef int& r_type;
kono
parents:
diff changeset
28 typedef const r_type cr_type;
kono
parents:
diff changeset
29 call_traits<cr_type>::type_less_spec var = num; // { dg-error "" }
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 // The explicit type leads to the instantiation of the "correct" one
kono
parents:
diff changeset
32 call_traits<const int&>::type_more_spec var2 = num;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 // As happen with a single typedef!
kono
parents:
diff changeset
35 typedef const int& std_cr_type;
kono
parents:
diff changeset
36 call_traits<std_cr_type>::type_more_spec var3 = num;
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 // As happen, indeed, without the cv-qualifier
kono
parents:
diff changeset
40 call_traits<r_type>::type_more_spec var4;
kono
parents:
diff changeset
41 }