1 /* $NetBSD: queries_uchar.c,v 1.2 2024/01/28 08:54:27 rillig Exp $ */ 2 # 3 "queries_uchar.c" 3 4 /* 5 * Tests for queries that are specific to platforms where 'char' has the same 6 * representation as 'unsigned char'. 7 * 8 * See also: 9 * queries.c platform-independent tests 10 * queries_schar.c for platforms where 'char' is signed 11 */ 12 13 /* lint1-only-if: uchar */ 14 /* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 -X 351 */ 15 16 int 17 Q14(char c) 18 { 19 /* expect+6: implicit conversion changes sign from 'char' to 'int' [Q3] */ 20 /* expect+5: implicit conversion changes sign from 'char' to 'int' [Q3] */ 21 /* expect+4: comparison '==' of 'char' with plain integer 92 [Q14] */ 22 /* expect+3: implicit conversion changes sign from 'char' to 'int' [Q3] */ 23 /* expect+2: comparison '==' of 'char' with plain integer 0 [Q14] */ 24 /* expect+1: implicit conversion changes sign from 'char' to 'int' [Q3] */ 25 if (c == 'c' || c == L'w' || c == 92 || c == 0) 26 return 1; 27 return 5; 28 } 29 30 /* 31 * Variables with automatic storage duration often have so small scope that 32 * adding the 'const' qualifier hurts readability more than it helps. 33 */ 34 int 35 /* expect+1: const automatic variable 'const_arg' [Q18] */ 36 Q18(const int const_arg, int arg) 37 { 38 /* expect+1: const automatic variable 'Q18_scalar' [Q18] */ 39 const char Q18_scalar = '1'; 40 const char Q18_array[] = { '1', '2', '3' }; 41 const char Q18_string[] = "123"; 42 const char *Q18_string_pointer = "123"; 43 44 /* expect+5: implicit conversion changes sign from 'char' to 'int' [Q3] */ 45 /* expect+4: implicit conversion changes sign from 'char' to 'int' [Q3] */ 46 /* expect+3: implicit conversion changes sign from 'char' to 'int' [Q3] */ 47 /* expect+2: implicit conversion changes sign from 'char' to 'int' [Q3] */ 48 return const_arg + arg 49 + Q18_scalar + Q18_array[0] + Q18_string[0] + Q18_string_pointer[0]; 50 } 51 52 /* 53 * Since queries do not affect the exit status, force a warning to make this 54 * test conform to the general expectation that a test that produces output 55 * exits non-successfully. 56 */ 57 /* expect+1: warning: static variable 'unused' unused [226] */ 58 static int unused; 59