File: stdckdint-2.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (95 lines) | stat: -rw-r--r-- 4,675 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
/* Test C23 Checked Integer Arithmetic macros in <stdckdint.h>.  */
/* { dg-do compile } */
/* { dg-options "-std=c23" } */

#include <stdckdint.h>

int
main ()
{
  char a;
  bool b;
  enum E { E1, E2 } c = E1;
  int d;
  int *e;
  float f;
  double g;
  long double h;
  const int v = 42;
  volatile const short w = 5;
  ckd_add (&a, 1, 1);
  ckd_sub (&a, 1, 1);
  ckd_mul (&a, 1, 1);
  ckd_add (&b, 1, 1);		/* { dg-error "has pointer to boolean type" } */
  ckd_sub (&b, 1, 1);		/* { dg-error "has pointer to boolean type" } */
  ckd_mul (&b, 1, 1);		/* { dg-error "has pointer to boolean type" } */
  ckd_add (&c, 1, 1);		/* { dg-error "has pointer to enumerated type" } */
  ckd_sub (&c, 1, 1);		/* { dg-error "has pointer to enumerated type" } */
  ckd_mul (&c, 1, 1);		/* { dg-error "has pointer to enumerated type" } */
  ckd_add (&d, (char) 1, 1);
  ckd_sub (&d, (char) 1, 1);
  ckd_mul (&d, (char) 1, 1);
  ckd_add (&d, false, 1);
  ckd_sub (&d, false, 1);
  ckd_mul (&d, false, 1);
  ckd_add (&d, true, 1);
  ckd_sub (&d, true, 1);
  ckd_mul (&d, true, 1);
  ckd_add (&d, c, 1);
  ckd_sub (&d, c, 1);
  ckd_mul (&d, c, 1);
  ckd_add (&d, 1, (char) 1);
  ckd_sub (&d, 1, (char) 1);
  ckd_mul (&d, 1, (char) 1);
  ckd_add (&d, 1, false);
  ckd_sub (&d, 1, false);
  ckd_mul (&d, 1, false);
  ckd_add (&d, 1, true);
  ckd_sub (&d, 1, true);
  ckd_mul (&d, 1, true);
  ckd_add (&d, 1, c);
  ckd_sub (&d, 1, c);
  ckd_mul (&d, 1, c);
  ckd_add (&e, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_sub (&e, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_mul (&e, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_add (&f, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_sub (&f, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_mul (&f, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_add (&g, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_sub (&g, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_mul (&g, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_add (&h, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_sub (&h, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_mul (&h, 1, 1);		/* { dg-error "does not have pointer to integral type" } */
  ckd_add (&d, 1.0f, 1);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1.0f, 1);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1.0f, 1);	/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1.0, 1);		/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1.0, 1);		/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1.0, 1);		/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1.0L, 1);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1.0L, 1);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1.0L, 1);	/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1, 1.0f);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1, 1.0f);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1, 1.0f);	/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1, 1.0);		/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1, 1.0);		/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1, 1.0);		/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1, 1.0L);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1, 1.0L);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1, 1.0L);	/* { dg-error "does not have integral type" } */
  ckd_add (&d, (int *) 0, 1);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, (int *) 0, 1);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, (int *) 0, 1);	/* { dg-error "does not have integral type" } */
  ckd_add (&d, 1, (int *) 0);	/* { dg-error "does not have integral type" } */
  ckd_sub (&d, 1, (int *) 0);	/* { dg-error "does not have integral type" } */
  ckd_mul (&d, 1, (int *) 0);	/* { dg-error "does not have integral type" } */
  ckd_add (&v, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
  ckd_sub (&v, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
  ckd_mul (&v, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
  ckd_add (&w, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
  ckd_sub (&w, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
  ckd_mul (&w, 1, 1);		/* { dg-error "has pointer to 'const' type" } */
}