aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/builtin-has-attribute.c
blob: 2de1ba3a7f96ef2259d2b269ddf5bd2f8b7e6d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Verify __builtin_has_attribute return value for i386 function attributes.
   { dg-do compile }
   { dg-options "-Wall -ftrack-macro-expansion=0" }
   { dg-options "-Wall -Wno-narrowing -Wno-unused -ftrack-macro-expansion=0" { target c++ } }  */

#define ATTR(...) __attribute__ ((__VA_ARGS__))

#define A(expect, sym, attr)						\
  typedef int Assert [1 - 2 * !(__builtin_has_attribute (sym, attr) == expect)]

void fnone (void);


ATTR (interrupt) void finterrupt (void*);
ATTR (interrupt, naked) void fnaked_interrupt (void*);

A (0, fnone, interrupt);
A (1, finterrupt, interrupt);
A (1, fnaked_interrupt, interrupt);
A (1, fnaked_interrupt, naked);


ATTR (naked) void fnaked (void);

A (0, fnone, naked);
A (1, fnaked, naked);


ATTR (no_caller_saved_registers) void fnsr (int);

A (0, fnone, no_caller_saved_registers);
A (1, fnsr, no_caller_saved_registers);


ATTR (target ("abm")) void ftarget_abm (void);
ATTR (target ("mmx")) void ftarget_mmx (void);
ATTR (target ("mmx"), target ("sse")) void ftarget_mmx_sse (void);

A (0, fnone, target);
A (0, fnone, target ("abm"));
A (0, fnone, target ("mmx"));

A (1, ftarget_abm, target);
A (0, ftarget_abm, target ("no-abm"));
A (1, ftarget_abm, target ("abm"));

A (1, ftarget_mmx, target);
A (0, ftarget_mmx, target ("no-mmx"));
A (1, ftarget_mmx, target ("mmx"));

A (1, ftarget_mmx_sse, target);
A (0, ftarget_mmx_sse, target ("no-mmx"));
A (1, ftarget_mmx_sse, target ("mmx"));
A (1, ftarget_mmx_sse, target ("sse"));