lint: document where to fix the wrong warning for '\xff'

This commit is contained in:
rillig 2021-06-29 14:19:51 +00:00
parent b468abca3b
commit 1abf4d0075
3 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex_char_uchar.c,v 1.1 2021/06/29 13:58:13 rillig Exp $ */
/* $NetBSD: lex_char_uchar.c,v 1.2 2021/06/29 14:19:51 rillig Exp $ */
# 3 "lex_char_uchar.c"
/*
@ -11,6 +11,7 @@
/*
* FIXME: The warning is bogus; it must be possible to initialize a char
* variable with a character constant.
* See tree.c, function convert_constant.
*/
/* expect+1: conversion of 'int' to 'char' is out of range [119] */
char ch = '\xff';

View File

@ -1 +1 @@
lex_char_uchar.c(16): warning: conversion of 'int' to 'char' is out of range [119]
lex_char_uchar.c(17): warning: conversion of 'int' to 'char' is out of range [119]

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.295 2021/06/29 10:12:35 rillig Exp $ */
/* $NetBSD: tree.c,v 1.296 2021/06/29 14:19:51 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: tree.c,v 1.295 2021/06/29 10:12:35 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.296 2021/06/29 14:19:51 rillig Exp $");
#endif
#include <float.h>
@ -2410,6 +2410,11 @@ convert_constant(op_t op, int arg, const type_t *tp, val_t *nv, val_t *v)
case LCOMPLEX:
break;
default:
/*
* FIXME: There must be no sign extension when converting
* from int to char on a platform where char == unsigned
* char. See test lex_char_uchar.c.
*/
sz = tp->t_bitfield ? tp->t_flen : size_in_bits(nt);
nv->v_quad = xsign(nv->v_quad, nt, sz);
break;