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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [strify2.c] - Blame information for rev 328

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

Line No. Rev Author Line
1 298 jeremybenn
/* Copyright (C) 2000 Free Software Foundation, Inc.  */
2
 
3
/* { dg-do run } */
4
/* { dg-options "-std=c99 -pedantic-errors" } */
5
 
6
/* Tests a whole bunch of things are correctly stringified.  */
7
 
8
extern int strcmp (const char *, const char *);
9
extern int puts (const char *);
10
extern void abort (void);
11
#define err(str) do { puts(str); abort(); } while (0)
12
 
13
#define str(x) #x
14
#define xstr(x) str(x)
15
#define strvar(...) #__VA_ARGS__
16
 
17
#define glibc_str(x) glibc_str2 (w, x)
18
#define glibc_str2(w, x) #x
19
#define ver GLIBC_2.2
20
 
21
int main (int argc, char *argv[])
22
{
23
  str (\);              /* { dg-warning "valid string" "str(\\)" } */
24
  str (\\);             /* OK.  */
25
  str (\\\);            /* { dg-warning "valid string" "str(\\\\\\)" } */
26
 
27
  /* This also serves as a useful test of the value of __INCLUDE_LEVEL.  */
28
  if (strcmp (xstr (__INCLUDE_LEVEL__), "0"))
29
    err ("macro expansion");
30
 
31
  if (strcmp(str (__INCLUDE_LEVEL__), "__INCLUDE_LEVEL__"))
32
    err ("macro name");
33
 
34
  if (strcmp(str(), "") || strcmp(str( ), ""))
35
    err ("empty string");
36
 
37
  if (strcmp(str ("s\n"), "\"s\\n\""))
38
    err ("quoted string");
39
 
40
  if (strcmp (str (a € b), "a \200 b"))
41
    err ("unprintable char");
42
 
43
  if (strcmp (str (     a    b@ c   ), "a b@ c"))
44
    err ("internal whitespace");
45
 
46
  if (strcmp (str(a \n), "a \n"))
47
    err ("backslash token");
48
 
49
  if (strcmp (strvar (foo, bar), "foo, bar"))
50
    err ("variable arguments");
51
 
52
  if (strcmp (glibc_str (ver), "GLIBC_2.2"))
53
    err ("whitespace");
54
 
55
  return 0;
56
}

powered by: WebSVN 2.1.0

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