Module Name: src
Committed By: rillig
Date: Mon Aug 16 20:27:31 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: expr_promote.c expr_promote.exp-ln
expr_promote_trad.c expr_promote_trad.exp-ln
Log Message:
tests/lint: test default argument promotion with enum
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/expr_promote.c \
src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.c \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/expr_promote.c
diff -u src/tests/usr.bin/xlint/lint1/expr_promote.c:1.1 src/tests/usr.bin/xlint/lint1/expr_promote.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote.c:1.1 Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote.c Mon Aug 16 20:27:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: expr_promote.c,v 1.1 2021/08/16 20:11:03 rillig Exp $ */
+/* $NetBSD: expr_promote.c,v 1.2 2021/08/16 20:27:31 rillig Exp $ */
# 3 "expr_promote.c"
/*
@@ -28,6 +28,9 @@ struct arithmetic_types {
float _Complex float_complex;
double _Complex double_complex;
long double _Complex long_double_complex;
+ enum {
+ E
+ } enumerator;
};
void
@@ -51,7 +54,15 @@ caller(struct arithmetic_types *arg)
arg->long_floating,
arg->float_complex,
arg->double_complex,
- arg->long_double_complex);
+ arg->long_double_complex,
+ arg->enumerator);
}
-/* XXX: _Bool is not promoted but should. */
+/*
+ * XXX: _Bool should be promoted to 'int', C99 6.3.1.1p2 "If an int can
+ * represent ...".
+ */
+/*
+ * XXX: Enumerations may need be promoted to 'int', at least C99 6.3.1.1p2
+ * suggests that: "If an int can represent ...".
+ */
Index: src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.1 src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.1 Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln Mon Aug 16 20:27:31 2021
@@ -1,5 +1,5 @@
0sexpr_promote.c
Sexpr_promote.c
10d0.10e4sinkF2PcCEV
-54c0.54i4sinkf19PcCBIIIIIIuILuLQuQDDlDsXXlXV
-34d0.34d6callerF1PsT116arithmetic_typesV
+58c0.58i4sinkf20PcCBIIIIIIuILuLQuQDDlDsXXlXeT331.0.0V
+37d0.37d6callerF1PsT116arithmetic_typesV
Index: src/tests/usr.bin/xlint/lint1/expr_promote_trad.c
diff -u src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.1 src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.1 Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote_trad.c Mon Aug 16 20:27:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: expr_promote_trad.c,v 1.1 2021/08/16 20:11:03 rillig Exp $ */
+/* $NetBSD: expr_promote_trad.c,v 1.2 2021/08/16 20:27:31 rillig Exp $ */
# 3 "expr_promote_trad.c"
/*
@@ -27,6 +27,9 @@ struct arithmetic_types {
double double_floating;
/* long double is not available in traditional C */
/* _Complex is not available in traditional C */
+ enum {
+ E
+ } enumerator;
};
caller(arg)
@@ -42,5 +45,11 @@ caller(arg)
arg->signed_long,
arg->unsigned_long,
arg->single_floating, /* gets promoted to 'double' */
- arg->double_floating);
+ arg->double_floating,
+ arg->enumerator);
}
+
+/*
+ * XXX: Enumerations may need be promoted to 'int', at least C99 6.3.1.1p2
+ * suggests that: "If an int can represent ...".
+ */
Index: src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.1 src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.1 Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln Mon Aug 16 20:27:31 2021
@@ -1,5 +1,5 @@
0sexpr_promote_trad.c
Sexpr_promote_trad.c
10d0.10e4sinkFI
-45c0.45s1""i4sinkf11PCIuIIuIIuILuLDDI
-32d0.32do6callerf1PsT116arithmetic_typesI
+49c0.49s1""i4sinkf12PCIuIIuIIuILuLDDeT330.0.0I
+35d0.35do6callerf1PsT116arithmetic_typesI