summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/mips/mips16-attributes.c
blob: 28bb9aae7fa23efe2514b987d5b5e874a7311ce8 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Verify that mips16 and nomips16 attributes work, checking all combinations
   of calling a nomips16/mips16/default function from a nomips16/mips16/default
   function.  */
/* { dg-do run } */
/* { dg-options "(-mips16)" } */

#include <stdlib.h>

#define ATTR1 __attribute__ ((nomips16))
#define ATTR2 __attribute__ ((mips16))
#define ATTR3

double ATTR1
f1 (int i, float f, double d)
{
  return i + f + d;
}

double ATTR2
f2 (int i, float f, double d)
{
  return i + f + d;
}

double ATTR3
f3 (int i, float f, double d)
{
  return i + f + d;
}

void ATTR1
g1 (int i, float f, double d)
{
  double r = i + f + d;

  if (f1 (i, f, d) != r)
    abort ();
  if (f2 (i+1, f+1, d+1) != r + 3)
    abort ();
  if (f3 (i+2, f+2, d+2) != r + 6)
    abort ();
}

void ATTR2
g2 (int i, float f, double d)
{
  double r = i + f + d;

  if (f1 (i, f, d) != r)
    abort ();
  if (f2 (i+1, f+1, d+1) != r + 3)
    abort ();
  if (f3 (i+2, f+2, d+2) != r + 6)
    abort ();
}

void ATTR3
g3 (int i, float f, double d)
{
  double r = i + f + d;

  if (f1 (i, f, d) != r)
    abort ();
  if (f2 (i+1, f+1, d+1) != r + 3)
    abort ();
  if (f3 (i+2, f+2, d+2) != r + 6)
    abort ();
}

int ATTR3
main (void)
{
  int i = 1;
  float f = -2.0;
  double d = 3.0;

  g1 (i, f, d);
  g2 (i, f, d);
  g3 (i, f, d);

  exit (0);
}