Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: expect complete messag...
details: https://anonhg.NetBSD.org/src/rev/cacb7fd705af
branches: trunk
changeset: 359646:cacb7fd705af
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 15 14:22:03 2022 +0000
description:
tests/lint: expect complete messages in feature tests
Previously, the tests contained many comments like /* expect: 123 */,
which were useless to a casual reader since nobody is expected to learn
lint's message IDs by heart. Replace these with the complete
diagnostics, to show what lint is complaining about.
The tests named msg_*.c have been left unmodified since they mention the
full message text in their header comment.
No functional change.
diffstat:
tests/usr.bin/xlint/lint1/c11_generic_expression.c | 5 +-
tests/usr.bin/xlint/lint1/c11_generic_expression.exp | 4 +-
tests/usr.bin/xlint/lint1/c99_init_designator.c | 5 +-
tests/usr.bin/xlint/lint1/c99_init_designator.exp | 2 +-
tests/usr.bin/xlint/lint1/d_c99_bool.c | 35 +-
tests/usr.bin/xlint/lint1/d_c99_bool.exp | 16 +-
tests/usr.bin/xlint/lint1/d_c99_bool_strict.c | 472 ++++++++++----
tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp | 344 +++++-----
tests/usr.bin/xlint/lint1/d_c99_complex_split.c | 5 +-
tests/usr.bin/xlint/lint1/d_c99_complex_split.exp | 2 +-
tests/usr.bin/xlint/lint1/d_c99_init.c | 44 +-
tests/usr.bin/xlint/lint1/d_c99_init.exp | 56 +-
tests/usr.bin/xlint/lint1/d_constant_conv1.c | 5 +-
tests/usr.bin/xlint/lint1/d_constant_conv1.exp | 2 +-
tests/usr.bin/xlint/lint1/d_constant_conv2.c | 5 +-
tests/usr.bin/xlint/lint1/d_constant_conv2.exp | 2 +-
tests/usr.bin/xlint/lint1/d_cvt_constant.c | 5 +-
tests/usr.bin/xlint/lint1/d_cvt_constant.exp | 2 +-
tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c | 10 +-
tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp | 12 +-
tests/usr.bin/xlint/lint1/d_fold_test.c | 26 +-
tests/usr.bin/xlint/lint1/d_fold_test.exp | 28 +-
tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c | 11 +-
tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.exp | 6 +-
tests/usr.bin/xlint/lint1/d_incorrect_array_size.c | 5 +-
tests/usr.bin/xlint/lint1/d_incorrect_array_size.exp | 2 +-
tests/usr.bin/xlint/lint1/d_init_array_using_string.c | 8 +-
tests/usr.bin/xlint/lint1/d_init_array_using_string.exp | 6 +-
tests/usr.bin/xlint/lint1/d_init_pop_member.c | 5 +-
tests/usr.bin/xlint/lint1/d_init_pop_member.exp | 2 +-
tests/usr.bin/xlint/lint1/d_lint_assert.c | 5 +-
tests/usr.bin/xlint/lint1/d_lint_assert.exp | 2 +-
tests/usr.bin/xlint/lint1/d_long_double_int.c | 5 +-
tests/usr.bin/xlint/lint1/d_long_double_int.exp | 2 +-
tests/usr.bin/xlint/lint1/d_pr_22119.c | 5 +-
tests/usr.bin/xlint/lint1/d_pr_22119.exp | 2 +-
tests/usr.bin/xlint/lint1/d_return_type.c | 5 +-
tests/usr.bin/xlint/lint1/d_return_type.exp | 2 +-
tests/usr.bin/xlint/lint1/d_struct_init_nested.c | 5 +-
tests/usr.bin/xlint/lint1/d_struct_init_nested.exp | 2 +-
tests/usr.bin/xlint/lint1/d_type_conv1.c | 5 +-
tests/usr.bin/xlint/lint1/d_type_conv1.exp | 2 +-
tests/usr.bin/xlint/lint1/d_type_conv2.c | 5 +-
tests/usr.bin/xlint/lint1/d_type_conv2.exp | 2 +-
tests/usr.bin/xlint/lint1/d_type_conv3.c | 6 +-
tests/usr.bin/xlint/lint1/d_type_conv3.exp | 4 +-
tests/usr.bin/xlint/lint1/decl_struct_member.c | 8 +-
tests/usr.bin/xlint/lint1/decl_struct_member.exp | 8 +-
tests/usr.bin/xlint/lint1/emit.c | 11 +-
tests/usr.bin/xlint/lint1/emit.exp | 6 +-
tests/usr.bin/xlint/lint1/emit.exp-ln | 94 +-
tests/usr.bin/xlint/lint1/expr_range.c | 8 +-
tests/usr.bin/xlint/lint1/expr_range.exp | 2 +-
tests/usr.bin/xlint/lint1/feat_stacktrace.c | 5 +-
tests/usr.bin/xlint/lint1/feat_stacktrace.exp | 2 +-
tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c | 5 +-
tests/usr.bin/xlint/lint1/gcc_attribute_aligned.exp | 2 +-
tests/usr.bin/xlint/lint1/gcc_bit_field_types.c | 5 +-
tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp | 2 +-
tests/usr.bin/xlint/lint1/lex_floating.c | 5 +-
tests/usr.bin/xlint/lint1/lex_floating.exp | 2 +-
tests/usr.bin/xlint/lint1/op_colon.c | 47 +-
tests/usr.bin/xlint/lint1/op_colon.exp | 26 +-
tests/usr.bin/xlint/lint1/stmt_for.c | 5 +-
tests/usr.bin/xlint/lint1/stmt_for.exp | 4 +-
65 files changed, 851 insertions(+), 587 deletions(-)
diffs (truncated from 2485 to 300 lines):
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/c11_generic_expression.c
--- a/tests/usr.bin/xlint/lint1/c11_generic_expression.c Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/c11_generic_expression.c Sat Jan 15 14:22:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: c11_generic_expression.c,v 1.10 2021/08/01 21:12:31 rillig Exp $ */
+/* $NetBSD: c11_generic_expression.c,v 1.11 2022/01/15 14:22:03 rillig Exp $ */
# 3 "c11_generic_expression.c"
/*
@@ -69,7 +69,8 @@
const int *
comma_expression(char first, double second)
{
- return _Generic(first, second, /* expect: syntax error 'second' */
+ /* expect+1: error: syntax error 'second' [249] */
+ return _Generic(first, second,
char: "first",
double: 2.0
);
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/c11_generic_expression.exp
--- a/tests/usr.bin/xlint/lint1/c11_generic_expression.exp Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/c11_generic_expression.exp Sat Jan 15 14:22:03 2022 +0000
@@ -2,5 +2,5 @@
c11_generic_expression.c(21): warning: argument 'var' unused in function 'classify_type_without_default' [231]
c11_generic_expression.c(37): warning: argument 'var' unused in function 'classify_type_with_default' [231]
c11_generic_expression.c(53): warning: argument 'c' unused in function 'classify_char' [231]
-c11_generic_expression.c(72): error: syntax error 'second' [249]
-c11_generic_expression.c(77): warning: function comma_expression falls off bottom without returning value [217]
+c11_generic_expression.c(73): error: syntax error 'second' [249]
+c11_generic_expression.c(78): warning: function comma_expression falls off bottom without returning value [217]
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/c99_init_designator.c
--- a/tests/usr.bin/xlint/lint1/c99_init_designator.c Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_init_designator.c Sat Jan 15 14:22:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: c99_init_designator.c,v 1.1 2021/06/20 18:09:48 rillig Exp $ */
+/* $NetBSD: c99_init_designator.c,v 1.2 2022/01/15 14:22:03 rillig Exp $ */
# 3 "c99_init_designator.c"
/*
@@ -21,7 +21,8 @@
*/
struct point origin = {
.x = 0,
- ->y = 0, /* expect: syntax error '->' */
+ /* expect+1: error: syntax error '->' [249] */
+ ->y = 0,
};
/* Ensure that the parser can recover from the parse error. */
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/c99_init_designator.exp
--- a/tests/usr.bin/xlint/lint1/c99_init_designator.exp Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_init_designator.exp Sat Jan 15 14:22:03 2022 +0000
@@ -1,1 +1,1 @@
-c99_init_designator.c(24): error: syntax error '->' [249]
+c99_init_designator.c(25): error: syntax error '->' [249]
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/d_c99_bool.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool.c Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool.c Sat Jan 15 14:22:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_bool.c,v 1.7 2021/03/30 14:25:28 rillig Exp $ */
+/* $NetBSD: d_c99_bool.c,v 1.8 2022/01/15 14:22:03 rillig Exp $ */
# 3 "d_c99_bool.c"
/*
@@ -12,19 +12,24 @@
/* Below, each false statement produces "negative array dimension" [20]. */
int int_0_converts_to_false[(_Bool)0 ? -1 : 1];
-int int_0_converts_to_true_[(_Bool)0 ? 1 : -1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int int_0_converts_to_true_[(_Bool)0 ? 1 : -1];
-int int_1_converts_to_false[(_Bool)1 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int int_1_converts_to_false[(_Bool)1 ? -1 : 1];
int int_1_converts_to_true_[(_Bool)1 ? 1 : -1];
-int int_2_converts_to_false[(_Bool)2 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int int_2_converts_to_false[(_Bool)2 ? -1 : 1];
int int_2_converts_to_true_[(_Bool)2 ? 1 : -1];
-int int_256_converts_to_false[(_Bool)256 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int int_256_converts_to_false[(_Bool)256 ? -1 : 1];
int int_256_converts_to_true_[(_Bool)256 ? 1 : -1];
int null_pointer_converts_to_false[(_Bool)(void *)0 ? -1 : 1];
-int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int null_pointer_converts_to_true_[(_Bool)(void *)0 ? 1 : -1];
/*
* XXX: lint does not treat the address of a global variable as a constant
@@ -38,23 +43,29 @@
int nonnull_pointer_converts_to_false[(_Bool)&ch ? -1 : 1];
int nonnull_pointer_converts_to_true_[(_Bool)&ch ? 1 : -1];
-int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_minus_1_0_converts_to_false[(_Bool)-1.0 ? -1 : 1];
int double_minus_1_0_converts_to_true_[(_Bool)-1.0 ? 1 : -1];
-int double_minus_0_5_converts_to_false[(_Bool)-0.5 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_minus_0_5_converts_to_false[(_Bool)-0.5 ? -1 : 1];
int double_minus_0_5_converts_to_true_[(_Bool)-0.5 ? 1 : -1];
int double_minus_0_0_converts_to_false[(_Bool)-0.0 ? -1 : 1];
-int double_minus_0_0_converts_to_true_[(_Bool)-0.0 ? 1 : -1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_minus_0_0_converts_to_true_[(_Bool)-0.0 ? 1 : -1];
int double_0_0_converts_to_false[(_Bool)0.0 ? -1 : 1];
-int double_0_0_converts_to_true_[(_Bool)0.0 ? 1 : -1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_0_0_converts_to_true_[(_Bool)0.0 ? 1 : -1];
/* The C99 rationale explains in 6.3.1.2 why (_Bool)0.5 is true. */
-int double_0_5_converts_to_false[(_Bool)0.5 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_0_5_converts_to_false[(_Bool)0.5 ? -1 : 1];
int double_0_5_converts_to_true_[(_Bool)0.5 ? 1 : -1];
-int double_1_0_converts_to_false[(_Bool)1.0 ? -1 : 1]; /* expect: 20 */
+/* expect+1: error: negative array dimension (-1) [20] */
+int double_1_0_converts_to_false[(_Bool)1.0 ? -1 : 1];
int double_1_0_converts_to_true_[(_Bool)1.0 ? 1 : -1];
_Bool
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/d_c99_bool.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool.exp Sat Jan 15 14:22:03 2022 +0000
@@ -1,11 +1,11 @@
-d_c99_bool.c(15): error: negative array dimension (-1) [20]
-d_c99_bool.c(17): error: negative array dimension (-1) [20]
-d_c99_bool.c(20): error: negative array dimension (-1) [20]
+d_c99_bool.c(16): error: negative array dimension (-1) [20]
+d_c99_bool.c(19): error: negative array dimension (-1) [20]
d_c99_bool.c(23): error: negative array dimension (-1) [20]
d_c99_bool.c(27): error: negative array dimension (-1) [20]
-d_c99_bool.c(41): error: negative array dimension (-1) [20]
-d_c99_bool.c(44): error: negative array dimension (-1) [20]
-d_c99_bool.c(48): error: negative array dimension (-1) [20]
+d_c99_bool.c(32): error: negative array dimension (-1) [20]
+d_c99_bool.c(47): error: negative array dimension (-1) [20]
d_c99_bool.c(51): error: negative array dimension (-1) [20]
-d_c99_bool.c(54): error: negative array dimension (-1) [20]
-d_c99_bool.c(57): error: negative array dimension (-1) [20]
+d_c99_bool.c(56): error: negative array dimension (-1) [20]
+d_c99_bool.c(60): error: negative array dimension (-1) [20]
+d_c99_bool.c(64): error: negative array dimension (-1) [20]
+d_c99_bool.c(68): error: negative array dimension (-1) [20]
diff -r a4186eb0b3ba -r cacb7fd705af tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sat Jan 15 12:35:18 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sat Jan 15 14:22:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_bool_strict.c,v 1.35 2021/11/20 17:27:46 rillig Exp $ */
+/* $NetBSD: d_c99_bool_strict.c,v 1.36 2022/01/15 14:22:03 rillig Exp $ */
# 3 "d_c99_bool_strict.c"
/*
@@ -124,29 +124,38 @@
{
accept_bool(__lint_false);
accept_bool(__lint_true);
- accept_bool(0); /* expect: 334 */
- accept_bool(1); /* expect: 334 */
- accept_bool(2); /* expect: 334 */
+ /* expect+1: error: argument #1 expects '_Bool', gets passed 'int' [334] */
+ accept_bool(0);
+ /* expect+1: error: argument #1 expects '_Bool', gets passed 'int' [334] */
+ accept_bool(1);
+ /* expect+1: error: argument #1 expects '_Bool', gets passed 'int' [334] */
+ accept_bool(2);
}
enum strict_bool_constant_expressions {
/* Ok: __lint_false is a boolean constant expression. */
- FALSE = __lint_false ? 100 : 101, /* expect: 161 */
+ /* expect+1: warning: constant in conditional context [161] */
+ FALSE = __lint_false ? 100 : 101,
/* Ok: __lint_true is a boolean constant expression. */
- TRUE = __lint_true ? 100 : 101, /* expect: 161 */
+ /* expect+1: warning: constant in conditional context [161] */
+ TRUE = __lint_true ? 100 : 101,
/* Not ok: an integer is not a boolean constant expression. */
- INT0 = 0 ? 100 : 101, /* expect: 331 */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ INT0 = 0 ? 100 : 101,
/* Not ok: an integer is not a boolean constant expression. */
- INT1 = 1 ? 100 : 101, /* expect: 331 */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ INT1 = 1 ? 100 : 101,
/* Not ok: 2 is not a boolean constant. */
- INT2 = 2 ? 100 : 101, /* expect: 331 */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ INT2 = 2 ? 100 : 101,
/* Not ok: compound integer expressions are not bool. */
- ARITH = (2 - 2) ? 100 : 101, /* expect: 331 */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ ARITH = (2 - 2) ? 100 : 101,
/*
* Without strict bool mode, these two variants of an expression can
@@ -156,32 +165,48 @@
* In strict bool mode, the resulting expression can be compared
* against 0 to achieve the same effect (so +0 != 0 or 1 + 0 != 0).
*/
- BINARY_PLUS = (1 + 0) ? 100 : 101, /* expect: 331 */
- UNARY_PLUS = (+0) ? 100 : 101, /* expect: 331 */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ BINARY_PLUS = (1 + 0) ? 100 : 101,
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ UNARY_PLUS = (+0) ? 100 : 101,
/* The main operator '>' has return type bool. */
- Q1 = (13 > 12) ? 100 : 101, /* expect: 161 */
+ /* expect+1: warning: constant in conditional context [161] */
+ Q1 = (13 > 12) ? 100 : 101,
/*
* The parenthesized expression has type int and thus cannot be
* used as the controlling expression in the '?:' operator.
*/
- Q2 = (13 > 12 ? 1 : 7) ? 100 : 101, /* expect: 161 *//* expect: 331 */
+ /* expect+2: warning: constant in conditional context [161] */
+ /* expect+1: error: left operand of '?' must be bool, not 'int' [331] */
+ Q2 = (13 > 12 ? 1 : 7) ? 100 : 101,
- BINAND_BOOL = __lint_false & __lint_true, /* expect: 55 */
+ /* expect+1: error: integral constant expression expected [55] */
+ BINAND_BOOL = __lint_false & __lint_true,
BINAND_INT = 0 & 1,
- BINXOR_BOOL = __lint_false ^ __lint_true, /* expect: 55 */
+ /* expect+1: error: integral constant expression expected [55] */
+ BINXOR_BOOL = __lint_false ^ __lint_true,
BINXOR_INT = 0 ^ 1,
- BINOR_BOOL = __lint_false | __lint_true, /* expect: 55 */
+ /* expect+1: error: integral constant expression expected [55] */
+ BINOR_BOOL = __lint_false | __lint_true,
BINOR_INT = 0 | 1,
- LOGOR_BOOL = __lint_false || __lint_true, /* expect: 161 *//* expect: 55 */
- LOGOR_INT = 0 || 1, /* expect: 331 *//* expect: 332 */
+ /* expect+2: warning: constant in conditional context [161] */
+ /* expect+1: error: integral constant expression expected [55] */
+ LOGOR_BOOL = __lint_false || __lint_true,
+ /* expect+2: error: left operand of '||' must be bool, not 'int' [331] */
+ /* expect+1: error: right operand of '||' must be bool, not 'int' [332] */
+ LOGOR_INT = 0 || 1,
- LOGAND_BOOL = __lint_false && __lint_true, /* expect: 161 *//* expect: 55 */
- LOGAND_INT = 0 && 1, /* expect: 331 *//* expect: 332 */
+ /* expect+2: warning: constant in conditional context [161] */
+ /* expect+1: error: integral constant expression expected [55] */
+ LOGAND_BOOL = __lint_false && __lint_true,
+ /* expect+2: error: left operand of '&&' must be bool, not 'int' [331] */
+ /* expect+1: error: right operand of '&&' must be bool, not 'int' [332] */
+ LOGAND_INT = 0 && 1,
};
/*
@@ -201,14 +226,18 @@
bool b;
b = flags.bool_flag;
- b = flags.uint_flag; /* expect: 107 */
+ /* expect+1: error: operands of '=' have incompatible types (_Bool != unsigned int) [107] */
+ b = flags.uint_flag;
flags.bool_flag = b;
- flags.uint_flag = b; /* expect: 107 */
+ /* expect+1: error: operands of '=' have incompatible types (unsigned int != _Bool) [107] */
+ flags.uint_flag = b;
b = flags_ptr->bool_flag;
- b = flags_ptr->uint_flag; /* expect: 107 */
+ /* expect+1: error: operands of '=' have incompatible types (_Bool != unsigned int) [107] */
+ b = flags_ptr->uint_flag;
flags_ptr->bool_flag = b;
- flags_ptr->uint_flag = b; /* expect: 107 */
+ /* expect+1: error: operands of '=' have incompatible types (unsigned int != _Bool) [107] */
+ flags_ptr->uint_flag = b;
}
void
@@ -250,37 +279,44 @@
bool
strict_bool_conversion_return_0(void)
{
- return 0; /* expect: 211 */
+ /* expect+1: error: return value type mismatch (_Bool) and (int) [211] */
+ return 0;
Home |
Main Index |
Thread Index |
Old Index