1// Check that the 3.1 named operand syntax can be used in template functions.
2
3struct arg1 {
4  int value;
5  static const int info = 99;
6};
7
8struct arg2 {
9  int value;
10  static const int info = 11;
11};
12
13template<int j>
14int foo (void)
15{
16  int i;
17  asm ("# foo on %[third] %[second] %[fourth] %[first]"
18       : [first] "=r" (i)
19       : [second] "i" (j),
20         [third] "i" (j + 2),
21         [fourth] "i" (100));
22  return i;
23}
24
25template<class TYPE>
26TYPE bar (TYPE t)
27{
28  asm ("# bar on %[first] %[second] %[third]"
29       : [first] "=r" (t.value)
30       : [second] "i[first]" (t.value),
31         [third] "i" (t.info));
32  return t;
33}
34
35template<class TYPE>
36struct S {
37  static void frob (TYPE t)
38  {
39    asm ("# frob on %[arg]" :: [arg] "i" (t.info));
40  }
41};
42
43void test ()
44{
45  arg1 x;
46  arg2 y;
47
48  foo<42> ();
49  bar (x);
50  bar (y);
51  S<arg1>::frob (x);
52}
53
54// { dg-final { scan-assembler "foo on" } }
55// { dg-final { scan-assembler "bar on" } }
56// { dg-final { scan-assembler "frob on" } }
57