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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [format/] [dfp-printf-1.c] - Blame information for rev 826

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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