2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / guality / pr68037-1.c
blob44cab58659f96e3c91632dac0a3e931e20cf820c
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 ERROR 0x12345670
9 #define IP 0x12345671
10 #define CS 0x12345672
11 #define FLAGS 0x12345673
12 #define SP 0x12345674
13 #define SS 0x12345675
15 #define STRING(x) XSTRING(x)
16 #define XSTRING(x) #x
17 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
18 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname
20 struct interrupt_frame
22 uword_t ip;
23 uword_t cs;
24 uword_t flags;
25 uword_t sp;
26 uword_t ss;
29 __attribute__((interrupt, used))
30 void
31 fn (struct interrupt_frame *frame, uword_t error)
33 if (ERROR != error) /* BREAK */
34 __builtin_abort ();
35 if (IP != frame->ip)
36 __builtin_abort ();
37 if (CS != frame->cs)
38 __builtin_abort ();
39 if (FLAGS != frame->flags)
40 __builtin_abort ();
41 if (SP != frame->sp)
42 __builtin_abort ();
43 if (SS != frame->ss)
44 __builtin_abort ();
46 exit (0);
49 int
50 main ()
52 asm ("push $" STRING (SS) "; \
53 push $" STRING (SP) "; \
54 push $" STRING (FLAGS) "; \
55 push $" STRING (CS) "; \
56 push $" STRING (IP) "; \
57 push $" STRING (ERROR) "; \
58 jmp " ASMNAME ("fn"));
59 return 0;
62 /* { dg-final { gdb-test 33 "error" "0x12345670" } } */
63 /* { dg-final { gdb-test 33 "frame->ip" "0x12345671" } } */
64 /* { dg-final { gdb-test 33 "frame->cs" "0x12345672" } } */
65 /* { dg-final { gdb-test 33 "frame->flags" "0x12345673" } } */
66 /* { dg-final { gdb-test 33 "frame->sp" "0x12345674" } } */
67 /* { dg-final { gdb-test 33 "frame->ss" "0x12345675" } } */