lint: add tests for several messages
This commit is contained in:
parent
6fceff0a4e
commit
af03d2a051
@ -1,7 +1,13 @@
|
||||
/* $NetBSD: msg_050.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_050.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_050.c"
|
||||
|
||||
// Test for message: a function is declared as an argument: %s [50]
|
||||
/* Test for message: a function is declared as an argument: %s [50] */
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-flags: -Stw */
|
||||
|
||||
typedef void (function)();
|
||||
|
||||
void example(f)
|
||||
function f;
|
||||
{
|
||||
}
|
||||
|
@ -1 +1,9 @@
|
||||
msg_050.c(6): syntax error ':' [249]
|
||||
(1): warning: 'long double' is illegal in traditional C [266]
|
||||
(1): warning: function prototypes are illegal in traditional C [270]
|
||||
(2): warning: 'long double' is illegal in traditional C [266]
|
||||
(2): warning: function prototypes are illegal in traditional C [270]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_050.c(11): warning: a function is declared as an argument: f [50]
|
||||
msg_050.c(10): warning: argument f unused in function example [231]
|
||||
|
@ -1,7 +1,13 @@
|
||||
/* $NetBSD: msg_051.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_051.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_051.c"
|
||||
|
||||
// Test for message: parameter mismatch: %d declared, %d defined [51]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(int, int);
|
||||
|
||||
void
|
||||
example(a, b, c)
|
||||
int a, b, c;
|
||||
{
|
||||
}
|
||||
|
@ -1 +1,4 @@
|
||||
msg_051.c(6): syntax error ':' [249]
|
||||
msg_051.c(12): parameter mismatch: 2 declared, 3 defined [51]
|
||||
msg_051.c(10): warning: argument a unused in function example [231]
|
||||
msg_051.c(10): warning: argument b unused in function example [231]
|
||||
msg_051.c(10): warning: argument c unused in function example [231]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_054.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_054.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_054.c"
|
||||
|
||||
// Test for message: trailing ',' prohibited in enum declaration [54]
|
||||
/* Test for message: trailing ',' prohibited in enum declaration [54] */
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-flags: -tw */
|
||||
|
||||
enum color {
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
};
|
||||
|
@ -1 +1,8 @@
|
||||
msg_054.c(6): syntax error ':' [249]
|
||||
(1): warning: 'long double' is illegal in traditional C [266]
|
||||
(1): warning: function prototypes are illegal in traditional C [270]
|
||||
(2): warning: 'long double' is illegal in traditional C [266]
|
||||
(2): warning: function prototypes are illegal in traditional C [270]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_054.c(12): warning: trailing ',' prohibited in enum declaration [54]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_055.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_055.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_055.c"
|
||||
|
||||
// Test for message: integral constant expression expected [55]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
enum color {
|
||||
WHITE = 1.0
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
msg_055.c(6): syntax error ':' [249]
|
||||
msg_055.c(8): integral constant expression expected [55]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_056.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_056.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_056.c"
|
||||
|
||||
// Test for message: integral constant too large [56]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
enum color {
|
||||
WHITE = 0xFFFFFFFFFFFFFFFFFFFF
|
||||
};
|
||||
|
@ -1 +1,2 @@
|
||||
msg_056.c(6): syntax error ':' [249]
|
||||
msg_056.c(7): warning: integer constant out of range [252]
|
||||
msg_056.c(8): warning: integral constant too large [56]
|
||||
|
@ -1,7 +1,14 @@
|
||||
/* $NetBSD: msg_057.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_057.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_057.c"
|
||||
|
||||
// Test for message: enumeration constant hides parameter: %s [57]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
long
|
||||
rgb(int red, int green, int blue)
|
||||
{
|
||||
enum color {
|
||||
red, green, blue
|
||||
};
|
||||
|
||||
return red + green + blue;
|
||||
}
|
||||
|
@ -1 +1,6 @@
|
||||
msg_057.c(6): syntax error ':' [249]
|
||||
msg_057.c(10): warning: enumeration constant hides parameter: red [57]
|
||||
msg_057.c(10): warning: enumeration constant hides parameter: green [57]
|
||||
msg_057.c(11): warning: enumeration constant hides parameter: blue [57]
|
||||
msg_057.c(7): warning: argument red unused in function rgb [231]
|
||||
msg_057.c(7): warning: argument green unused in function rgb [231]
|
||||
msg_057.c(7): warning: argument blue unused in function rgb [231]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_060.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_060.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_060.c"
|
||||
|
||||
// Test for message: void must be sole parameter [60]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void example_1(void);
|
||||
void example_2(int, void);
|
||||
void example_3(void, void, void);
|
||||
|
@ -1 +1,4 @@
|
||||
msg_060.c(6): syntax error ':' [249]
|
||||
msg_060.c(7): void must be sole parameter [60]
|
||||
msg_060.c(8): void must be sole parameter [60]
|
||||
msg_060.c(8): void must be sole parameter [60]
|
||||
msg_060.c(8): void must be sole parameter [60]
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* $NetBSD: msg_061.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_061.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_061.c"
|
||||
|
||||
// Test for message: void parameter cannot have name: %s [61]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void example(void arg);
|
||||
|
@ -1 +1 @@
|
||||
msg_061.c(6): syntax error ':' [249]
|
||||
msg_061.c(6): void parameter cannot have name: arg [61]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_066.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_066.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_066.c"
|
||||
|
||||
// Test for message: syntax requires ';' after last struct/union member [66]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct number {
|
||||
int value
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
msg_066.c(6): syntax error ':' [249]
|
||||
msg_066.c(8): warning: syntax requires ';' after last struct/union member [66]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_068.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_068.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_068.c"
|
||||
|
||||
// Test for message: typedef already qualified with '%s' [68]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
typedef const char const_char;
|
||||
|
||||
const const_char twice_const;
|
||||
|
@ -1 +1 @@
|
||||
msg_068.c(6): syntax error ':' [249]
|
||||
msg_068.c(8): warning: typedef already qualified with 'const' [68]
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* $NetBSD: msg_075.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_075.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_075.c"
|
||||
|
||||
// Test for message: overflow in hex escape [75]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
char str[] = "\x12345678123456781234567812345678";
|
||||
|
@ -1 +1 @@
|
||||
msg_075.c(6): syntax error ':' [249]
|
||||
msg_075.c(6): warning: overflow in hex escape [75]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_081.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_081.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_081.c"
|
||||
|
||||
// Test for message: \a undefined in traditional C [81]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-flags: -Stw */
|
||||
|
||||
char str[] = "The bell\a rings";
|
||||
|
@ -1 +1,8 @@
|
||||
msg_081.c(6): syntax error ':' [249]
|
||||
(1): warning: 'long double' is illegal in traditional C [266]
|
||||
(1): warning: function prototypes are illegal in traditional C [270]
|
||||
(2): warning: 'long double' is illegal in traditional C [266]
|
||||
(2): warning: function prototypes are illegal in traditional C [270]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_081.c(8): warning: \a undefined in traditional C [81]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_082.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_082.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_082.c"
|
||||
|
||||
// Test for message: \x undefined in traditional C [82]
|
||||
/* Test for message: \x undefined in traditional C [82] */
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-flags: -Stw */
|
||||
|
||||
char str[] = "A he\x78 escape";
|
||||
|
@ -1 +1,8 @@
|
||||
msg_082.c(6): syntax error ':' [249]
|
||||
(1): warning: 'long double' is illegal in traditional C [266]
|
||||
(1): warning: function prototypes are illegal in traditional C [270]
|
||||
(2): warning: 'long double' is illegal in traditional C [266]
|
||||
(2): warning: function prototypes are illegal in traditional C [270]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_082.c(8): warning: \x undefined in traditional C [82]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_083.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_083.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_083.c"
|
||||
|
||||
// Test for message: storage class after type is obsolescent [83]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(void)
|
||||
{
|
||||
int register x;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_083.c(6): syntax error ':' [249]
|
||||
msg_083.c(9): warning: storage class after type is obsolescent [83]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_084.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_084.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_084.c"
|
||||
|
||||
// Test for message: ANSI C requires formal parameter before '...' [84]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void only_ellipsis(...)
|
||||
{
|
||||
}
|
||||
|
||||
void ok_ellipsis(const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
msg_084.c(6): syntax error ':' [249]
|
||||
msg_084.c(6): warning: ANSI C requires formal parameter before '...' [84]
|
||||
msg_084.c(10): warning: argument fmt unused in function ok_ellipsis [231]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_089.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_089.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_089.c"
|
||||
|
||||
// Test for message: typedef redeclared: %s [89]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
typedef int number;
|
||||
typedef int number;
|
||||
typedef double number;
|
||||
|
@ -1 +1,2 @@
|
||||
msg_089.c(6): syntax error ':' [249]
|
||||
msg_089.c(7): typedef redeclared: number [89]
|
||||
msg_089.c(8): typedef redeclared: number [89]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_100.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_100.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_100.c"
|
||||
|
||||
// Test for message: unary + is illegal in traditional C [100]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
/* lint1-flags: -Stw */
|
||||
|
||||
int
|
||||
unary_plus(int x)
|
||||
{
|
||||
return +x;
|
||||
}
|
||||
|
@ -1 +1,9 @@
|
||||
msg_100.c(6): syntax error ':' [249]
|
||||
(1): warning: 'long double' is illegal in traditional C [266]
|
||||
(1): warning: function prototypes are illegal in traditional C [270]
|
||||
(2): warning: 'long double' is illegal in traditional C [266]
|
||||
(2): warning: function prototypes are illegal in traditional C [270]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: 'long double' is illegal in traditional C [266]
|
||||
(3): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_100.c(10): warning: function prototypes are illegal in traditional C [270]
|
||||
msg_100.c(11): warning: unary + is illegal in traditional C [100]
|
||||
|
@ -1,7 +1,14 @@
|
||||
/* $NetBSD: msg_101.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_101.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_101.c"
|
||||
|
||||
// Test for message: undefined struct/union member: %s [101]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct point {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
int
|
||||
get_z(const struct point *p)
|
||||
{
|
||||
return p.z;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_101.c(6): syntax error ':' [249]
|
||||
msg_101.c(13): undefined struct/union member: z [101]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_109.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_109.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_109.c"
|
||||
|
||||
// Test for message: void type illegal in expression [109]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
example(int arg)
|
||||
{
|
||||
return arg + (void)4;
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
msg_109.c(6): syntax error ':' [249]
|
||||
msg_109.c(9): void type illegal in expression [109]
|
||||
msg_109.c(9): warning: function example expects to return value [214]
|
||||
msg_109.c(7): warning: argument arg unused in function example [231]
|
||||
|
@ -1,7 +1,13 @@
|
||||
/* $NetBSD: msg_114.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_114.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_114.c"
|
||||
|
||||
// Test for message: %soperand of '%s' must be lvalue [114]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(int a)
|
||||
{
|
||||
3++;
|
||||
// FIXME: lint error: ../common/tyname.c, 190: tspec_name(0)
|
||||
// "string"++;
|
||||
(a + a)++;
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
msg_114.c(6): syntax error ':' [249]
|
||||
msg_114.c(9): operand of 'x++' must be lvalue [114]
|
||||
msg_114.c(12): operand of 'x++' must be lvalue [114]
|
||||
msg_114.c(7): warning: argument a unused in function example [231]
|
||||
|
@ -1,7 +1,16 @@
|
||||
/* $NetBSD: msg_115.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_115.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_115.c"
|
||||
|
||||
// Test for message: %soperand of '%s' must be modifiable lvalue [115]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(const int *const_ptr)
|
||||
{
|
||||
|
||||
*const_ptr = 3;
|
||||
*const_ptr += 1;
|
||||
*const_ptr -= 4;
|
||||
*const_ptr *= 1;
|
||||
*const_ptr /= 5;
|
||||
*const_ptr %= 9;
|
||||
}
|
||||
|
@ -1 +1,6 @@
|
||||
msg_115.c(6): syntax error ':' [249]
|
||||
msg_115.c(10): warning: left operand of '=' must be modifiable lvalue [115]
|
||||
msg_115.c(11): warning: left operand of '+=' must be modifiable lvalue [115]
|
||||
msg_115.c(12): warning: left operand of '-=' must be modifiable lvalue [115]
|
||||
msg_115.c(13): warning: left operand of '*=' must be modifiable lvalue [115]
|
||||
msg_115.c(14): warning: left operand of '/=' must be modifiable lvalue [115]
|
||||
msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_116.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_116.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_116.c"
|
||||
|
||||
// Test for message: illegal pointer subtraction [116]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
unsigned long
|
||||
example(int *a, double *b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_116.c(6): syntax error ':' [249]
|
||||
msg_116.c(9): illegal pointer subtraction [116]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_121.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_121.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_121.c"
|
||||
|
||||
// Test for message: negative shift [121]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
example(int x)
|
||||
{
|
||||
return x << (3 - 5);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_121.c(6): syntax error ':' [249]
|
||||
msg_121.c(9): warning: negative shift [121]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_122.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_122.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_122.c"
|
||||
|
||||
// Test for message: shift greater than size of object [122]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
example(int x)
|
||||
{
|
||||
return x << 129;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_122.c(6): syntax error ':' [249]
|
||||
msg_122.c(9): warning: shift greater than size of object [122]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_126.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_126.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_126.c"
|
||||
|
||||
// Test for message: incompatible types in conditional [126]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
max(int cond, void *ptr, double dbl)
|
||||
{
|
||||
return cond ? ptr : dbl;
|
||||
}
|
||||
|
@ -1 +1,5 @@
|
||||
msg_126.c(6): syntax error ':' [249]
|
||||
msg_126.c(9): incompatible types in conditional [126]
|
||||
msg_126.c(9): warning: function max expects to return value [214]
|
||||
msg_126.c(7): warning: argument cond unused in function max [231]
|
||||
msg_126.c(7): warning: argument ptr unused in function max [231]
|
||||
msg_126.c(7): warning: argument dbl unused in function max [231]
|
||||
|
@ -1,7 +1,18 @@
|
||||
/* $NetBSD: msg_130.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_130.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_130.c"
|
||||
|
||||
// Test for message: enum type mismatch, op %s [130]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
enum color {
|
||||
RED, GREEN, BLUE
|
||||
};
|
||||
|
||||
enum daytime {
|
||||
NIGHT, MORNING, NOON, EVENING
|
||||
};
|
||||
|
||||
int
|
||||
example(_Bool cond)
|
||||
{
|
||||
return cond ? GREEN : MORNING;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_130.c(6): syntax error ':' [249]
|
||||
msg_130.c(17): warning: enum type mismatch, op : [130]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_133.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_133.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_133.c"
|
||||
|
||||
// Test for message: conversion of pointer to '%s' loses bits [133]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
char
|
||||
to_char(void *ptr)
|
||||
{
|
||||
return (char)ptr;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_133.c(6): syntax error ':' [249]
|
||||
msg_133.c(9): warning: conversion of pointer to 'char' loses bits [133]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_136.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_136.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_136.c"
|
||||
|
||||
// Test for message: cannot do pointer arithmetic on operand of unknown size [136]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct incomplete;
|
||||
|
||||
const struct incomplete *
|
||||
example(const struct incomplete *ptr)
|
||||
{
|
||||
return ptr + 5;
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
msg_136.c(6): syntax error ':' [249]
|
||||
msg_136.c(11): cannot do pointer arithmetic on operand of unknown size [136]
|
||||
msg_136.c(6): warning: struct incomplete never defined [233]
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* $NetBSD: msg_142.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_142.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_142.c"
|
||||
|
||||
// Test for message: floating point overflow detected, op %s [142]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
double dbl = 1e100 * 1e100 * 1e100 * 1e100 * 1e100;
|
||||
|
@ -1 +1,2 @@
|
||||
msg_142.c(6): syntax error ':' [249]
|
||||
msg_142.c(6): warning: floating point overflow detected, op * [142]
|
||||
msg_142.c(6): warning: floating point overflow detected, op * [142]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_143.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_143.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_143.c"
|
||||
|
||||
// Test for message: cannot take size/alignment of incomplete type [143]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct incomplete;
|
||||
|
||||
unsigned long
|
||||
sizeof_incomplete(void)
|
||||
{
|
||||
return sizeof(struct incomplete);
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
msg_143.c(6): syntax error ':' [249]
|
||||
msg_143.c(11): cannot take size/alignment of incomplete type [143]
|
||||
msg_143.c(6): warning: struct incomplete never defined [233]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_144.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_144.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_144.c"
|
||||
|
||||
// Test for message: cannot take size/alignment of function [144]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
unsigned long
|
||||
example(void)
|
||||
{
|
||||
return sizeof example;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_144.c(6): syntax error ':' [249]
|
||||
msg_144.c(9): cannot take size/alignment of function [144]
|
||||
|
@ -1,7 +1,25 @@
|
||||
/* $NetBSD: msg_145.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_145.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_145.c"
|
||||
|
||||
// Test for message: cannot take size/alignment of bit-field [145]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct bits {
|
||||
unsigned one: 1;
|
||||
unsigned eight: 8;
|
||||
};
|
||||
|
||||
unsigned long
|
||||
sizeof_one(void)
|
||||
{
|
||||
struct bits local_bits;
|
||||
|
||||
return sizeof(local_bits.one);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
sizeof_eight(void)
|
||||
{
|
||||
struct bits local_bits;
|
||||
|
||||
return sizeof(local_bits.eight);
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
msg_145.c(6): syntax error ':' [249]
|
||||
msg_145.c(16): cannot take size/alignment of bit-field [145]
|
||||
msg_145.c(24): cannot take size/alignment of bit-field [145]
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: msg_146.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_146.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_146.c"
|
||||
|
||||
// Test for message: cannot take size/alignment of void [146]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(void *ptr)
|
||||
{
|
||||
return sizeof(*ptr);
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
msg_146.c(6): syntax error ':' [249]
|
||||
msg_146.c(9): cannot take size/alignment of void [146]
|
||||
msg_146.c(9): void function example cannot return value [213]
|
||||
|
@ -1,7 +1,13 @@
|
||||
/* $NetBSD: msg_150.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_150.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_150.c"
|
||||
|
||||
// Test for message: argument mismatch: %d arg%s passed, %d expected [150]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int
|
||||
add2(int, int);
|
||||
|
||||
int
|
||||
example(void)
|
||||
{
|
||||
return add2(2, 3, 5, 7);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_150.c(6): syntax error ':' [249]
|
||||
msg_150.c(12): argument mismatch: 4 args passed, 2 expected [150]
|
||||
|
@ -1,7 +1,25 @@
|
||||
/* $NetBSD: msg_156.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_156.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_156.c"
|
||||
|
||||
// Test for message: enum type mismatch, arg #%d [156]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
enum color {
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE
|
||||
};
|
||||
|
||||
enum size {
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE
|
||||
};
|
||||
|
||||
void
|
||||
print_color(enum color);
|
||||
|
||||
void
|
||||
example(void)
|
||||
{
|
||||
print_color(MEDIUM);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_156.c(6): syntax error ':' [249]
|
||||
msg_156.c(24): warning: enum type mismatch, arg #1 [156]
|
||||
|
@ -1,7 +1,14 @@
|
||||
/* $NetBSD: msg_164.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_164.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_164.c"
|
||||
|
||||
// Test for message: assignment of negative constant to unsigned type [164]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(void)
|
||||
{
|
||||
unsigned char uch = -3;
|
||||
|
||||
uch = -5;
|
||||
uch += -7;
|
||||
uch *= -1;
|
||||
}
|
||||
|
@ -1 +1,4 @@
|
||||
msg_164.c(6): syntax error ':' [249]
|
||||
msg_164.c(9): warning: assignment of negative constant to unsigned type [164]
|
||||
msg_164.c(11): warning: assignment of negative constant to unsigned type [164]
|
||||
msg_164.c(12): warning: conversion of negative constant to unsigned type [222]
|
||||
msg_164.c(13): warning: conversion of negative constant to unsigned type [222]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_165.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_165.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_165.c"
|
||||
|
||||
// Test for message: constant truncated by assignment [165]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(void)
|
||||
{
|
||||
unsigned char ch;
|
||||
|
||||
ch = 0x1234;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_165.c(6): syntax error ':' [249]
|
||||
msg_165.c(11): warning: constant truncated by assignment [165]
|
||||
|
@ -1,7 +1,18 @@
|
||||
/* $NetBSD: msg_167.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_167.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_167.c"
|
||||
|
||||
// Test for message: array subscript cannot be negative: %ld [167]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(int *ptr)
|
||||
{
|
||||
int arr[6];
|
||||
|
||||
arr[-3] = 13;
|
||||
|
||||
/*
|
||||
* Since the pointer may have been initialized with "arr + 3",
|
||||
* subtracting from its address is allowed.
|
||||
*/
|
||||
ptr[-3] = 13;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_167.c(6): syntax error ':' [249]
|
||||
msg_167.c(11): warning: array subscript cannot be negative: -3 [167]
|
||||
|
@ -1,7 +1,14 @@
|
||||
/* $NetBSD: msg_170.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_170.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_170.c"
|
||||
|
||||
// Test for message: first operand must have scalar type, op ? : [170]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct number {
|
||||
int value;
|
||||
};
|
||||
|
||||
_Bool
|
||||
example(const struct number *num)
|
||||
{
|
||||
return *num ? 1 : 0;
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
msg_170.c(6): syntax error ':' [249]
|
||||
msg_170.c(13): first operand must have scalar type, op ? : [170]
|
||||
msg_170.c(13): warning: function example expects to return value [214]
|
||||
msg_170.c(11): warning: argument num unused in function example [231]
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* $NetBSD: msg_172.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_172.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_172.c"
|
||||
|
||||
// Test for message: too many struct/union initializers [172]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
struct color {
|
||||
unsigned int red: 8;
|
||||
unsigned int green: 8;
|
||||
unsigned int blue: 8;
|
||||
};
|
||||
|
||||
struct color white = { 255, 255, 255, 255 };
|
||||
|
@ -1 +1 @@
|
||||
msg_172.c(6): syntax error ':' [249]
|
||||
msg_172.c(12): too many struct/union initializers [172]
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: msg_173.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_173.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_173.c"
|
||||
|
||||
// Test for message: too many array initializers, expected %d [173]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
int arr_limited[3] = { 1, 2, 3, 4 };
|
||||
int arr_unlimited[] = { 1, 2, 3, 4 };
|
||||
int arr_too_few[] = { 1, 2 };
|
||||
|
@ -1 +1 @@
|
||||
msg_173.c(6): syntax error ':' [249]
|
||||
msg_173.c(6): too many array initializers, expected 3 [173]
|
||||
|
@ -1,7 +1,16 @@
|
||||
/* $NetBSD: msg_174.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_174.c,v 1.2 2021/01/08 21:25:03 rillig Exp $ */
|
||||
# 3 "msg_174.c"
|
||||
|
||||
// Test for message: too many initializers [174]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
void
|
||||
example(void)
|
||||
{
|
||||
/* A single pair of braces is always allowed. */
|
||||
int n = { 13 };
|
||||
|
||||
int too_many = { 17, 19 };
|
||||
|
||||
/* XXX: Double-check with C99, this might be allowed. */
|
||||
int too_few = {};
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
msg_174.c(6): syntax error ':' [249]
|
||||
msg_174.c(12): too many initializers [174]
|
||||
|
Loading…
Reference in New Issue
Block a user