OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [format/] [dfp-printf-1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test for printf formats for Decimal Floating Point types.  */
2
 
3
/* { dg-do compile } */
4
/* { dg-require-effective-target dfp } */
5
/* { dg-options "-Wformat" } */
6
/* { dg-skip-if "No scanf/printf dfp support" { *-*-mingw* } { "*" } { "" } } */
7
 
8
extern int printf (const char *restrict, ...);
9
 
10
void
11
foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j,
12
     double d, char *p)
13
{
14
  /* See ISO/IEC DTR 24732 subclause 9.3 (currently Working Draft 5 from
15
      2005-03-06).  */
16
  /* Formatted input/output specifiers.  */
17
 
18
  /* Check lack of warnings for valid usage.  */
19
 
20
  printf ("%Hf\n", x);
21
  printf ("%HF\n", x);
22
  printf ("%He\n", x);
23
  printf ("%HE\n", x);
24
  printf ("%Hg\n", x);
25
  printf ("%HG\n", x);
26
 
27
  printf ("%Df\n", y);
28
  printf ("%DF\n", y);
29
  printf ("%De\n", y);
30
  printf ("%DE\n", y);
31
  printf ("%Dg\n", y);
32
  printf ("%DG\n", y);
33
 
34
  printf ("%DDf\n", z);
35
  printf ("%DDF\n", z);
36
  printf ("%DDe\n", z);
37
  printf ("%DDE\n", z);
38
  printf ("%DDg\n", z);
39
  printf ("%DDG\n", z);
40
 
41
  printf ("%DG%DDE%HF%DDe%He%HE%DF%DDF%De%DDG%HG%Df%Hg%DE%DDf%Dg%DDg%Hf\n",
42
           y, z, x, z, x, x, y, z, y, z, x, y, x, y, z, y, z, x);
43
 
44
  /* Check warnings for type mismatches.  */
45
 
46
  printf ("%Hf\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
47
  printf ("%HF\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
48
  printf ("%He\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
49
  printf ("%HE\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
50
  printf ("%Hg\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
51
  printf ("%HG\n", y);  /* { dg-warning "expects argument" "bad use of %H" } */
52
  printf ("%Hf\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
53
  printf ("%HF\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
54
  printf ("%He\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
55
  printf ("%HE\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
56
  printf ("%Hg\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
57
  printf ("%HG\n", z);  /* { dg-warning "expects argument" "bad use of %H" } */
58
 
59
  printf ("%Df\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
60
  printf ("%DF\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
61
  printf ("%De\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
62
  printf ("%DE\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
63
  printf ("%Dg\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
64
  printf ("%DG\n", x);  /* { dg-warning "expects argument" "bad use of %D" } */
65
  printf ("%Df\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
66
  printf ("%DF\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
67
  printf ("%De\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
68
  printf ("%DE\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
69
  printf ("%Dg\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
70
  printf ("%DG\n", z);  /* { dg-warning "expects argument" "bad use of %D" } */
71
 
72
  printf ("%DDf\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
73
  printf ("%DDF\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
74
  printf ("%DDe\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
75
  printf ("%DDE\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
76
  printf ("%DDg\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
77
  printf ("%DDG\n", x); /* { dg-warning "expects argument" "bad use of %DD" } */
78
  printf ("%DDf\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
79
  printf ("%DDF\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
80
  printf ("%DDe\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
81
  printf ("%DDE\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
82
  printf ("%DDg\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
83
  printf ("%DDG\n", y); /* { dg-warning "expects argument" "bad use of %DD" } */
84
 
85
  /* Check for warnings for bad use of H, D, and DD length specifiers.  */
86
 
87
  printf ("%Hd\n", i);  /* { dg-warning "length" "bad use of %H" } */
88
  printf ("%Hi\n", i);  /* { dg-warning "length" "bad use of %H" } */
89
  printf ("%Ho\n", j);  /* { dg-warning "length" "bad use of %H" } */
90
  printf ("%Hu\n", j);  /* { dg-warning "length" "bad use of %H" } */
91
  printf ("%Hx\n", j);  /* { dg-warning "length" "bad use of %H" } */
92
  printf ("%HX\n", j);  /* { dg-warning "length" "bad use of %H" } */
93
  printf ("%Ha\n", d);  /* { dg-warning "length" "bad use of %H" } */
94
  printf ("%HA\n", d);  /* { dg-warning "length" "bad use of %H" } */
95
  printf ("%Hc\n", i);  /* { dg-warning "length" "bad use of %H" } */
96
  printf ("%Hs\n", p);  /* { dg-warning "length" "bad use of %H" } */
97
  printf ("%Hp\n", p);  /* { dg-warning "length" "bad use of %H" } */
98
  printf ("%Hn\n", p);  /* { dg-warning "length" "bad use of %H" } */
99
 
100
  /* Sanity checks for flags, field width, and precision in formats for
101
     DFP types.  */
102
 
103
  printf ("%-Hf\n", x);
104
  printf ("%+HF\n", x);
105
  printf ("% He\n", x);
106
  printf ("%#HE\n", x);
107
  printf ("%0Hg\n", x);
108
  printf ("%#0HG\n", x);
109
 
110
  printf ("%0#Df\n", y);
111
  printf ("%0DF\n", y);
112
  printf ("%#De\n", y);
113
  printf ("%-#DE\n", y);
114
  printf ("%-#0Dg\n", y);  /* { dg-warning "flag ignored" "ignore flag" } */
115
  printf ("%0+ DG\n", y);  /* { dg-warning "flag ignored" "ignore flag" } */
116
 
117
  printf ("%DDf\n", z);
118
  printf ("%0DDF\n", z);
119
  printf ("%#0DDe\n", z);
120
  printf ("%+DDE\n", z);
121
  printf ("%0-#DDg\n", z); /* { dg-warning "flag ignored" "ignore flag" } */
122
  printf ("% DDG\n", z);
123
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.