2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / guality / pr68037-2.c
blobc3cd73d2a651179966531f9df7d2f56e6adae567
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__((interrupt, used))
29 void
30 fn (struct interrupt_frame *frame)
32 if (IP != frame->ip) /* BREAK */
33 __builtin_abort ();
34 if (CS != frame->cs)
35 __builtin_abort ();
36 if (FLAGS != frame->flags)
37 __builtin_abort ();
38 if (SP != frame->sp)
39 __builtin_abort ();
40 if (SS != frame->ss)
41 __builtin_abort ();
43 exit (0);
46 int
47 main ()
49 asm ("push $" STRING (SS) "; \
50 push $" STRING (SP) "; \
51 push $" STRING (FLAGS) "; \
52 push $" STRING (CS) "; \
53 push $" STRING (IP) "; \
54 jmp " ASMNAME ("fn"));
55 return 0;
58 /* { dg-final { gdb-test 30 "frame->ip" "0x12345671" } } */
59 /* { dg-final { gdb-test 30 "frame->cs" "0x12345672" } } */
60 /* { dg-final { gdb-test 30 "frame->flags" "0x12345673" } } */
61 /* { dg-final { gdb-test 30 "frame->sp" "0x12345674" } } */
62 /* { dg-final { gdb-test 30 "frame->ss" "0x12345675" } } */