2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / ext / asmspecValid.C
blob98d98b46f9370ce78d671dc2935c9c9ee11cd5a5
1 // tests that the asm directive is correctly handled for static fields
2 // in structures and classes.  This only applies to C++; such
3 // directives generate errors in C.  Assembler directives for local
4 // variables should be tested by the C test suite.  
5 //
6 // Contributed by Robert Bowdidge (bowdidge@apple.com) 14 Oct 2003
8 // { dg-do compile }
10 struct Foo {
11   // This should reference a variable called bar
12   static int i __asm__("bar"); 
16 class Bar {
17 public:
18   static int i __asm__("theRealI");
19   static int j __asm__("theRealJ");
20   int boof;
23 class Baz : public Bar { 
24 public:
25    static char *ptr __asm__ ("theRealString");
28 int main (int argc, char **argv) {
29   struct Foo myFoo;
30   Bar b;
31   myFoo.i = 1;
32   Foo::i = 2;
33   Baz::j = 10;
34   Baz::ptr = 0;
35   b.i = 1;
36   return (b.i);
40 /* { dg-final {scan-assembler "bar"} } */
41 /* { dg-final {scan-assembler "theRealString"} } */
42 /* { dg-final {scan-assembler "theRealI" } } */
43 /* { dg-final {scan-assembler "theRealJ" } } */