summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtins-error.c
blob: 0f41700ba1a081c5d4ef5ef051f89383a89a065f (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
/* { dg-do compile } */

struct X { int x; };

int test1(struct X x)
{
  if (x.x ==  1) return __builtin_fpclassify(1,2,3,4,5,x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  2) return __builtin_isfinite(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  3) return __builtin_isinf_sign(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  4) return __builtin_isinf(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  5) return __builtin_isnan(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  6) return __builtin_isnormal(x); /* { dg-error "non-floating-point argument" } */
  if (x.x ==  7) return __builtin_isgreater(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x ==  8) return __builtin_isgreaterequal(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x ==  9) return __builtin_isless(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 10) return __builtin_islessequal(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 11) return __builtin_islessgreater(x, x); /* { dg-error "non-floating-point arguments" } */
  if (x.x == 12) return __builtin_isunordered(x, x); /* { dg-error "non-floating-point arguments" } */

  return 0;
}

int test2(double x)
{
  if (x ==  1) return __builtin_fpclassify(1,2,3,4,5); /* { dg-error "not enough arguments" } */
  if (x ==  2) return __builtin_isfinite(); /* { dg-error "not enough arguments" } */
  if (x ==  3) return __builtin_isinf_sign(); /* { dg-error "not enough arguments" } */
  if (x ==  4) return __builtin_isinf(); /* { dg-error "not enough arguments" } */
  if (x ==  5) return __builtin_isnan(); /* { dg-error "not enough arguments" } */
  if (x ==  6) return __builtin_isnormal(); /* { dg-error "not enough arguments" } */
  if (x ==  7) return __builtin_isgreater(x); /* { dg-error "not enough arguments" } */
  if (x ==  8) return __builtin_isgreaterequal(x); /* { dg-error "not enough arguments" } */
  if (x ==  9) return __builtin_isless(x); /* { dg-error "not enough arguments" } */
  if (x == 10) return __builtin_islessequal(x); /* { dg-error "not enough arguments" } */
  if (x == 11) return __builtin_islessgreater(x); /* { dg-error "not enough arguments" } */
  if (x == 12) return __builtin_isunordered(x); /* { dg-error "not enough arguments" } */
  return 0;
}

int test3(double x)
{
  if (x ==  1) return __builtin_fpclassify(1,2,3,4,5,x,x); /* { dg-error "too many arguments" } */
  if (x ==  2) return __builtin_isfinite(x, x); /* { dg-error "too many arguments" } */
  if (x ==  3) return __builtin_isinf_sign(x, x); /* { dg-error "too many arguments" } */
  if (x ==  4) return __builtin_isinf(x, x); /* { dg-error "too many arguments" } */
  if (x ==  5) return __builtin_isnan(x, x); /* { dg-error "too many arguments" } */
  if (x ==  6) return __builtin_isnormal(x, x); /* { dg-error "too many arguments" } */
  if (x ==  7) return __builtin_isgreater(x, x, x); /* { dg-error "too many arguments" } */
  if (x ==  8) return __builtin_isgreaterequal(x, x, x); /* { dg-error "too many arguments" } */
  if (x ==  9) return __builtin_isless(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 10) return __builtin_islessequal(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 11) return __builtin_islessgreater(x, x, x); /* { dg-error "too many arguments" } */
  if (x == 12) return __builtin_isunordered(x, x, x); /* { dg-error "too many arguments" } */
  return 0;
}

int test4(int i, double x)
{
  if (x ==  1) return __builtin_fpclassify(i,2,3,4,5,x); /* { dg-error "non-const integer argument" } */
  if (x ==  2) return __builtin_fpclassify(1,i,3,4,5,x); /* { dg-error "non-const integer argument" } */
  if (x ==  3) return __builtin_fpclassify(1,2,i,4,5,x); /* { dg-error "non-const integer argument" } */
  if (x ==  4) return __builtin_fpclassify(1,2,3,i,5,x); /* { dg-error "non-const integer argument" } */
  if (x ==  5) return __builtin_fpclassify(1,2,3,4,i,x); /* { dg-error "non-const integer argument" } */
  return 0;
}