OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [format/] [ms_array-1.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Test for format checking of constant arrays.  */
2
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3
/* { dg-do compile { target { *-*-mingw* } } } */
4
/* { dg-options "-std=gnu99 -Wformat=2" } */
5
 
6
#define USE_SYSTEM_FORMATS
7
#include "format.h"
8
 
9
const char a1[] = "foo";
10
const char a2[] = "foo%d";
11
const char b1[3] = "foo";
12
const char b2[1] = "1";
13
static const char c1[] = "foo";
14
static const char c2[] = "foo%d";
15
char d[] = "foo";
16
volatile const char e[] = "foo";
17
 
18
void
19
foo (int i, long l)
20
{
21
  const char p1[] = "bar";
22
  const char p2[] = "bar%d";
23
  static const char q1[] = "bar";
24
  static const char q2[] = "bar%d";
25
  printf (a1);
26
  printf (a2, i);
27
  printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
28
  printf (b1); /* { dg-warning "unterminated" "unterminated array" } */
29
  printf (b2); /* { dg-warning "unterminated" "unterminated array" } */
30
  printf (c1);
31
  printf (c2, i);
32
  printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
33
  printf (p1);
34
  printf (p2, i);
35
  printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
36
  printf (q1);
37
  printf (q2, i);
38
  printf (q2, l); /* { dg-warning "format" "wrong type with array" } */
39
  /* Volatile or non-constant arrays must not be checked.  */
40
  printf (d); /* { dg-warning "not a string literal" "non-const" } */
41
  printf ((const char *)e); /* { dg-warning "not a string literal" "volatile" } */
42
}

powered by: WebSVN 2.1.0

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