lint: fix segmentation fault when checking returned enum types (211)
This commit is contained in:
parent
d4b0f2fea7
commit
e93292def1
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1004 2020/12/31 18:51:28 rillig Exp $
|
||||
# $NetBSD: mi,v 1.1005 2021/01/01 01:07:07 rillig Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -5798,6 +5798,8 @@
|
||||
./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_return_type.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_return_type.exp tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf
|
||||
./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.22 2020/12/31 18:51:28 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.23 2021/01/01 01:07:08 rillig Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
@ -66,6 +66,8 @@ FILES+= d_long_double_int.exp
|
||||
FILES+= d_nested_structs.c
|
||||
FILES+= d_nolimit_init.c
|
||||
FILES+= d_packed_structs.c
|
||||
FILES+= d_return_type.c
|
||||
FILES+= d_return_type.exp
|
||||
FILES+= d_shift_to_narrower_type.c
|
||||
FILES+= d_struct_init_nested.c
|
||||
FILES+= d_struct_init_nested.exp
|
||||
|
15
tests/usr.bin/xlint/lint1/d_return_type.c
Normal file
15
tests/usr.bin/xlint/lint1/d_return_type.c
Normal file
@ -0,0 +1,15 @@
|
||||
# 2
|
||||
|
||||
enum A {
|
||||
A
|
||||
};
|
||||
|
||||
enum B {
|
||||
B
|
||||
};
|
||||
|
||||
enum A
|
||||
func(enum B arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
1
tests/usr.bin/xlint/lint1/d_return_type.exp
Normal file
1
tests/usr.bin/xlint/lint1/d_return_type.exp
Normal file
@ -0,0 +1 @@
|
||||
(14): warning: return value type mismatch (enum A) and (enum B) [211]
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: t_integration.sh,v 1.15 2020/12/31 18:51:28 rillig Exp $
|
||||
# $NetBSD: t_integration.sh,v 1.16 2021/01/01 01:07:08 rillig Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
@ -76,6 +76,7 @@ test_case cast_typeof
|
||||
test_case decl_old_style_arguments
|
||||
test_case fold_test
|
||||
test_case gcc_extension
|
||||
test_case return_type
|
||||
test_case type_question_colon
|
||||
test_case typefun
|
||||
test_case typename_as_var
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tree.c,v 1.108 2021/01/01 00:00:24 rillig Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.109 2021/01/01 01:07:08 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.108 2021/01/01 00:00:24 rillig Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.109 2021/01/01 01:07:08 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
@ -1369,6 +1369,7 @@ static void
|
||||
check_enum_type_mismatch(op_t op, int arg, tnode_t *ln, tnode_t *rn)
|
||||
{
|
||||
mod_t *mp;
|
||||
char lbuf[128], rbuf[128];
|
||||
|
||||
mp = &modtab[op];
|
||||
|
||||
@ -1384,7 +1385,8 @@ check_enum_type_mismatch(op_t op, int arg, tnode_t *ln, tnode_t *rn)
|
||||
break;
|
||||
case RETURN:
|
||||
/* return value type mismatch (%s) and (%s) */
|
||||
warning(211);
|
||||
warning(211, tyname(lbuf, sizeof(lbuf), ln->tn_type),
|
||||
tyname(rbuf, sizeof(rbuf), rn->tn_type));
|
||||
break;
|
||||
default:
|
||||
/* enum type mismatch, op %s */
|
||||
|
Loading…
Reference in New Issue
Block a user