summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format/dfp-scanf-1.c
blob: ffa12a803ec33f23507db8ad660d44e1e652213e (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* Test for scanf formats for Decimal Floating Point types.  */

/* { dg-do compile } */
/* { dg-require-effective-target dfp } */
/* { dg-options "-Wformat" } */
/* { dg-skip-if "No scanf/printf dfp support" { *-*-mingw* } } */

#include "format.h"

void
voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j,
     double *d, char **p)
{
  /* See ISO/IEC DTR 24732 subclause 9.3 (currently Working Draft 5 from
      2005-03-06).  */
  /* Formatted input/output specifiers.  */

  /* Check lack of warnings for valid usage.  */

  scanf ("%Hf", x);
  scanf ("%HF", x);
  scanf ("%He", x);
  scanf ("%HE", x);
  scanf ("%Hg", x);
  scanf ("%HG", x);

  scanf ("%Df", y);
  scanf ("%DF", y);
  scanf ("%De", y);
  scanf ("%DE", y);
  scanf ("%Dg", y);
  scanf ("%DG", y);

  scanf ("%DDf", z);
  scanf ("%DDF", z);
  scanf ("%DDe", z);
  scanf ("%DDE", z);
  scanf ("%DDg", z);
  scanf ("%DDG", z);

  scanf ("%DG%DDE%HF%DDe%He%HE%DF%DDF%De%DDG%HG%Df%Hg%DE%DDf%Dg%DDg%Hf\n",
           y, z, x, z, x, x, y, z, y, z, x, y, x, y, z, y, z, x);

  /* Check warnings for type mismatches.  */

  scanf ("%Hf", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HF", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%He", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HE", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%Hg", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HG", y);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%Hf", z);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HF", z);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%He", z);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HE", z);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%Hg", z);	/* { dg-warning "expects argument" "bad use of %H" } */
  scanf ("%HG", z);	/* { dg-warning "expects argument" "bad use of %H" } */

  scanf ("%Df", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DF", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%De", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DE", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%Dg", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DG", x);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%Df", z);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DF", z);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%De", z);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DE", z);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%Dg", z);	/* { dg-warning "expects argument" "bad use of %D" } */
  scanf ("%DG", z);	/* { dg-warning "expects argument" "bad use of %D" } */

  scanf ("%DDf", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDF", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDe", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDE", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDg", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDG", x);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDf", y);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDF", y);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDe", y);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDE", y);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDg", y);	/* { dg-warning "expects argument" "bad use of %DD" } */
  scanf ("%DDG", y);	/* { dg-warning "expects argument" "bad use of %DD" } */

  /* Check for warnings for bad use of H, D, and DD length specifiers.  */

  scanf ("%Hd\n", i);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hi\n", i);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Ho\n", j);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hu\n", j);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hx\n", j);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%HX\n", j);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Ha\n", d);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%HA\n", d);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hc\n", i);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hs\n", p);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hp\n", p);	/* { dg-warning "length" "bad use of %H" } */
  scanf ("%Hn\n", p);	/* { dg-warning "length" "bad use of %H" } */
}