msg_342.c revision 1.1
11.1Srillig/*	$NetBSD: msg_342.c,v 1.1 2021/04/05 02:05:47 rillig Exp $	*/
21.1Srillig# 3 "msg_341.c"
31.1Srillig
41.1Srillig// Test for message: argument to '%s' must be cast to 'unsigned char', not to '%s' [342]
51.1Srillig
61.1Srillig/*
71.1Srillig * Ensure that the functions from <ctype.h> are called with the correct
81.1Srillig * argument.
91.1Srillig */
101.1Srillig
111.1Srillig/* NetBSD 9.99.81, <ctype.h> */
121.1Srilligextern const unsigned short *_ctype_tab_;
131.1Srilligextern const short *_tolower_tab_;
141.1Srilligextern const short *_toupper_tab_;
151.1Srilligint isspace(int);
161.1Srillig
171.1Srilligvoid sink(int);
181.1Srillig
191.1Srilligvoid
201.1Srilligfunction_call_char(char c)
211.1Srillig{
221.1Srillig
231.1Srillig	/* expect+1: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' */
241.1Srillig	(isspace)(c);
251.1Srillig
261.1Srillig	/* This is the only allowed form. */
271.1Srillig	isspace((unsigned char)c);
281.1Srillig
291.1Srillig	/* The cast to 'int' is redundant, it doesn't hurt though. */
301.1Srillig	isspace((int)(unsigned char)c);
311.1Srillig
321.1Srillig	/* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'int' */
331.1Srillig	isspace((int)c);
341.1Srillig
351.1Srillig	/* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' */
361.1Srillig	isspace((unsigned int)c);
371.1Srillig}
381.1Srillig
391.1Srillig/*
401.1Srillig * If the expression starts with type 'unsigned char', it can be cast to any
411.1Srillig * other type.  Chances are low enough that the cast is to 'char', which would
421.1Srillig * be the only bad type.
431.1Srillig */
441.1Srilligvoid
451.1Srilligfunction_call_unsigned_char(unsigned char c)
461.1Srillig{
471.1Srillig
481.1Srillig	(isspace)(c);
491.1Srillig	isspace((unsigned char)c);
501.1Srillig	isspace((int)c);
511.1Srillig	isspace((unsigned int)c);
521.1Srillig}
531.1Srillig
541.1Srillig/* When used in a loop of fgetc, the type is already 'int'.  That's fine. */
551.1Srilligvoid
561.1Srilligfunction_call_int(int c)
571.1Srillig{
581.1Srillig
591.1Srillig	isspace(c);
601.1Srillig}
611.1Srillig
621.1Srilligvoid
631.1Srilligmacro_invocation_NetBSD(char c)
641.1Srillig{
651.1Srillig
661.1Srillig	/* expect+1: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' */
671.1Srillig	sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040)));
681.1Srillig
691.1Srillig	/* This is the only allowed form. */
701.1Srillig	sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040)));
711.1Srillig
721.1Srillig	/* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' */
731.1Srillig	sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040)));
741.1Srillig
751.1Srillig	/* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' */
761.1Srillig	sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040)));
771.1Srillig}
78