OSDN Git Service

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