Home | History | Annotate | Line # | Download | only in lint1
lex_string.c revision 1.5
      1 /*	$NetBSD: lex_string.c,v 1.5 2022/06/17 18:54:53 rillig Exp $	*/
      2 # 3 "lex_string.c"
      3 
      4 /*
      5  * Test lexical analysis of string constants.
      6  *
      7  * C99 6.4.5 "String literals"
      8  */
      9 
     10 void sink(const char *);
     11 
     12 void
     13 test(void)
     14 {
     15 	sink("");
     16 
     17 	sink("hello, world\n");
     18 
     19 	sink("\0");
     20 
     21 	sink("\0\0\0\0");
     22 
     23 	/* expect+1: error: no hex digits follow \x [74] */
     24 	sink("\x");		/* unfinished */
     25 
     26 	/* expect+1: warning: dubious escape \y [79] */
     27 	sink("\y");		/* unknown escape sequence */
     28 
     29 	sink("first" "second");
     30 
     31 	/* expect+1: error: cannot concatenate wide and regular string literals [292] */
     32 	sink("plain" L"wide");
     33 }
     34 
     35 /* TODO: test digraphs inside string literals */
     36 /* TODO: test trigraphs inside string literals */
     37