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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [format/] [array-1.c] - Blame information for rev 154

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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