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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 689 jeremybenn
/* Test for strfmon format checking.  */
2
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3
/* { dg-do compile } */
4
/* { dg-options "-std=gnu99 -Wformat" } */
5
 
6
#include "format.h"
7
 
8
void
9
foo (char *s, size_t m, double d, long double ld)
10
{
11
  /* Examples of valid formats from Austin Group draft 7.  */
12
  strfmon (s, m, "%n", d);
13
  strfmon (s, m, "%11n", d);
14
  strfmon (s, m, "%#5n", d);
15
  strfmon (s, m, "%=*#5n", d);
16
  strfmon (s, m, "%=0#5n", d);
17
  strfmon (s, m, "%^#5n", d);
18
  strfmon (s, m, "%^#5.0n", d);
19
  strfmon (s, m, "%^#5.4n", d);
20
  strfmon (s, m, "%(#5n", d);
21
  strfmon (s, m, "%!(#5n", d);
22
  strfmon (s, m, "%-14#5.4n", d);
23
  strfmon (s, m, "%14#5.4n", d);
24
  /* Some more valid formats, including the GNU L length extension.  */
25
  strfmon (s, m, "abc%-11ndef%==i%%", d, d);
26
  strfmon (s, m, "%%abc%-11ndef%==Li%=%i", d, ld, d);
27
  strfmon (s, m, "%Li", ld);
28
  strfmon (s, m, "%11Li", ld);
29
  strfmon (s, m, "%#5Li", ld);
30
  strfmon (s, m, "%=*#5Li", ld);
31
  strfmon (s, m, "%=0#5Li", ld);
32
  strfmon (s, m, "%^#5Li", ld);
33
  strfmon (s, m, "%^#5.0Li", ld);
34
  strfmon (s, m, "%^#5.4Li", ld);
35
  strfmon (s, m, "%(#5Li", ld);
36
  strfmon (s, m, "%!(#5Li", ld);
37
  strfmon (s, m, "%-14#5.4Li", ld);
38
  strfmon (s, m, "%14#5.4Li", ld);
39
  /* Formats with the wrong types used.  */
40
  strfmon (s, m, "%Ln", d); /* { dg-warning "format" "wrong type" } */
41
  strfmon (s, m, "%n", ld); /* { dg-warning "format" "wrong type" } */
42
  /* The + and ( flags cannot be used together.  */
43
  strfmon (s, m, "%+(i", d); /* { dg-warning "flag" "+ and ( flags" } */
44
  strfmon (s, m, "%(+i", d); /* { dg-warning "flag" "+ and ( flags" } */
45
  /* Although empty precision is OK for printf, it isn't here.  */
46
  strfmon (s, m, "%#.5n", d); /* { dg-warning "empty" "empty left precision" } */
47
  strfmon (s, m, "%#5.n", d); /* { dg-warning "empty" "empty right precision" } */
48
  /* However, zero is a valid value for width and precisions.  */
49
  strfmon (s, m, "%0#0.0n", d);
50
  /* Test bogus %% constructions.  */
51
  strfmon (s, m, "%^%"); /* { dg-warning "format" "bogus %%" } */
52
  strfmon (s, m, "%!%\n"); /* { dg-warning "format" "bogus %%" } */
53
  strfmon (s, m, "%5%\n"); /* { dg-warning "format" "bogus %%" } */
54
  strfmon (s, m, "%.5%\n"); /* { dg-warning "format" "bogus %%" } */
55
  strfmon (s, m, "%#5%\n"); /* { dg-warning "format" "bogus %%" } */
56
  /* Miscellaneous bogus formats.  */
57
  strfmon (s, m, "%n%n", d); /* { dg-warning "matching" "too few args" } */
58
  strfmon (s, m, ""); /* { dg-warning "zero-length" "empty" } */
59
  strfmon (s, m, NULL); /* { dg-warning "null" "null format string" } */
60
  strfmon (s, m, "%"); /* { dg-warning "trailing" "tailing %" } */
61
  strfmon (s, m, "%n\0", d); /* { dg-warning "embedded" "embedded NUL" } */
62
  strfmon (s, m, "%^^n", d); /* { dg-warning "repeated" "repeated flag" } */
63
}

powered by: WebSVN 2.1.0

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