2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / ext / asm1.C
blobdd4aede2424cce6878a182463930ed8b7f239113
1 // Check that the 3.1 named operand syntax can be used in template functions.
3 struct arg1 {
4   int value;
5   static const int info = 99;
6 };
8 struct arg2 {
9   int value;
10   static const int info = 11;
13 template<int j>
14 int foo (void)
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;
25 template<class TYPE>
26 TYPE bar (TYPE t)
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;
35 template<class TYPE>
36 struct S {
37   static void frob (TYPE t)
38   {
39     asm ("# frob on %[arg]" :: [arg] "i" (t.info));
40   }
43 void test ()
45   arg1 x;
46   arg2 y;
48   foo<42> ();
49   bar (x);
50   bar (y);
51   S<arg1>::frob (x);
54 // { dg-final { scan-assembler "foo on" } }
55 // { dg-final { scan-assembler "bar on" } }
56 // { dg-final { scan-assembler "frob on" } }