2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / guality / pr25967-2.c
blobc3b59e212515ddc089c93af8a1fe52a95faa381a
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-g -mgeneral-regs-only" } */
4 extern void exit (int);
6 typedef unsigned int uword_t __attribute__ ((mode (__word__)));
8 #define IP 0x12345671
9 #define CS 0x12345672
10 #define FLAGS 0x12345673
11 #define SP 0x12345674
12 #define SS 0x12345675
14 #define STRING(x) XSTRING(x)
15 #define XSTRING(x) #x
16 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
17 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname
19 struct interrupt_frame
21 uword_t ip;
22 uword_t cs;
23 uword_t flags;
24 uword_t sp;
25 uword_t ss;
28 __attribute__((naked, used))
29 void
30 fn (void)
32 register uword_t *sp __asm__("sp");
33 struct interrupt_frame *frame = (struct interrupt_frame *) sp;
34 if (IP != frame->ip) /* BREAK */
35 __builtin_abort ();
36 if (CS != frame->cs)
37 __builtin_abort ();
38 if (FLAGS != frame->flags)
39 __builtin_abort ();
40 if (SP != frame->sp)
41 __builtin_abort ();
42 if (SS != frame->ss)
43 __builtin_abort ();
45 exit (0);
48 int
49 main ()
51 asm ("push $" STRING (SS) "; \
52 push $" STRING (SP) "; \
53 push $" STRING (FLAGS) "; \
54 push $" STRING (CS) "; \
55 push $" STRING (IP) "; \
56 jmp " ASMNAME ("fn"));
57 return 0;
60 /* { dg-final { gdb-test 34 "frame->ip" "0x12345671" } } */
61 /* { dg-final { gdb-test 34 "frame->cs" "0x12345672" } } */
62 /* { dg-final { gdb-test 34 "frame->flags" "0x12345673" } } */
63 /* { dg-final { gdb-test 34 "frame->sp" "0x12345674" } } */
64 /* { dg-final { gdb-test 34 "frame->ss" "0x12345675" } } */