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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [lexstrng.c] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2000 Free Software Foundation, Inc.  */
2
 
3
/* { dg-do run } */
4
/* { dg-options "-trigraphs" } */
5
 
6
/* Test lexing of strings and character constants.  */
7
 
8
#ifndef __WCHAR_TYPE__
9
#define __WCHAR_TYPE__ int
10
#endif
11
typedef __WCHAR_TYPE__ wchar_t;
12
 
13
extern int strcmp (const char *, const char *);
14
extern int puts (const char *);
15
extern void abort (void);
16
#define err(str) do { puts(str); abort(); } while (0)
17
 
18
/* Escaped newlines.  */
19
const char *str1 = "s\
20
t\
21
\
22
r??/
23
  1";
24
 
25
const char x = '\
26
??/
27
b';
28
 
29
/* Test escaped terminators.  */
30
const char *term = "\"\\\"\\";
31
const char termc = '\'';
32
const char *terms = "'";
33
 
34
/* Test wide strings and chars are lexed.  */
35
const wchar_t wchar = L'w';
36
const wchar_t* wstring = L"wide string";
37
 
38
/* Test all 9 trigraphs embedded in a string.  Test trigraphs do not
39
   survive an embedded backslash newline.  Test trigraphs preceded by
40
   a '?' are still noticed.  */
41
const char *t = "??/\??<??>??=??)??\
42
(??(??!??'??-???=???/
43
?-";
44
 
45
int main (int argc, char *argv[])
46
{
47
  if (strcmp (str1, "str  1"))
48
    err ("str1");
49
 
50
  if (x != 'b')
51
    err ("b");
52
 
53
  /* We have to split the string up to avoid trigraph replacement
54
     here.  Split the 2 trigraphs after both 1 and 2 ?s; just doing
55
     this exposed a bug in the initial release of the tokenized lexer.  */
56
  if (strcmp (t, "\\{}#]?" "?([|^~?#??" "-"))
57
    err ("Embedded trigraphs");
58
 
59
  if (term[0] != '"' || term[1] != '\\' || term[2] != '"'
60
      || term[3] != '\\' || term[4] != '\0')
61
    err ("Escaped string terminators");
62
 
63
  if (termc != terms[0])
64
    err ("Escaped character constant terminator");
65
 
66
  return 0;
67
}

powered by: WebSVN 2.1.0

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