1 // Contributed by Dodji Seketeli <dodji@redhat.com>
2 // Origin PR debug/30161
3 // { dg-do compile { target c++11 } }
4 // { dg-options "-g -dA" }
5 //
6 // In theory the compiler instantiates count<int, char, long>,
7 // count<char, long> and count<long>. In practice, only
8 // count<int, char, long> is emitted, thanks to constant folding.
9 // So in theory, each of the 3 instances of count yields a
10 // DW_TAG_GNU_template_parameter_pack DIE, but in practise, there is only one
11 // DW_TAG_GNU_template_parameter_pack as there is only count<int, char, long>
12 // is emitted.
13 // { dg-final { scan-assembler-times "DIE \\(0x\[^\n\]*\\) DW_TAG_GNU_template_parameter_pack" 1} }
14 // { dg-final { scan-assembler-times "DIE \\(0x\[^\n\]*\\) DW_TAG_template_type_param" 3} }
15 
16 
17 template <typename... Args> struct count;
18 
19 template <>
20 struct count<>
21 {
22   static const int value = 0;
23 };
24 
25 template <typename T, typename... Args>
26 struct count<T, Args...>
27 {
28   static const int value = 1 + count<Args...>::value;
29 };
30 
31 template<typename... P>
32 int
33 do_count()
34 {
35   return count<P...>::value;
36 }
37 
38 int c = do_count<int, char, long>();
39 
40