tests/lint: add test for type mismatch in initialization

Copied and adapted from d_c99_init.c.
This commit is contained in:
rillig 2021-03-18 21:20:21 +00:00
parent d254ff0ed7
commit 79d8eaa978
2 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,19 @@
/* $NetBSD: msg_185.c,v 1.3 2021/02/22 15:09:50 rillig Exp $ */
/* $NetBSD: msg_185.c,v 1.4 2021/03/18 21:20:21 rillig Exp $ */
# 3 "msg_185.c"
// Test for message: initialization type mismatch (%s) and (%s) [185]
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
typedef struct any {
const void *value;
} any;
void use(const void *);
void
initialization_with_redundant_braces(any arg)
{
any local = { 3.0 }; /* expect: 185 */
use(&arg);
}
// TODO: message 185 needs to be reworded to "cannot initialize '%s' from '%s'".

View File

@ -1 +1 @@
msg_185.c(6): syntax error ':' [249]
msg_185.c(15): initialization type mismatch (pointer to const void) and (double) [185]