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
16template <typename... Args> struct count;
17
18template <>
19struct count<>
20{
21  static const int value = 0;
22};
23
24template <typename T, typename... Args>
25struct count<T, Args...>
26{
27  static const int value = 1 + count<Args...>::value;
28};
29
30int
31foo ()
32{
33  count<int, char, long> c;
34  int nb = count<int, char, long>::value;
35  return nb;
36}
37
38