The NetBSD Project

CVS log for src/usr.bin/xlint/lint1/oper.c

[BACK] Up to [] / src / usr.bin / xlint / lint1

Request diff between arbitrary revisions

Default branch: MAIN

Revision 1.11 / (download) - annotate - [select for diffs], Sat Apr 16 22:21:10 2022 UTC (9 months, 2 weeks ago) by rillig
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10, HEAD
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

lint: merge mod_t.m_test_context into m_requires_bool

These two flags mean exactly the same.

No functional change.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Aug 2 20:58:39 2021 UTC (17 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.9: +17 -11 lines
Diff to previous 1.9 (colored)

lint: expand abbreviations in definitions of operator properties

No functional change.

Revision 1.9 / (download) - annotate - [select for diffs], Sat Mar 20 20:56:58 2021 UTC (22 months, 1 week ago) by rillig
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.8: +1 -7 lines
Diff to previous 1.8 (colored)

lint: move getopname over to tree.c

Except for the one use in print_tnode, the name of the operator is only
used in tree.c.

No functional change.

Revision 1.8 / (download) - annotate - [select for diffs], Sat Mar 20 20:39:35 2021 UTC (22 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.7: +6 -22 lines
Diff to previous 1.7 (colored)

lint: remove redundant operator properties table

It's enough to have modtab, which describes the properties of the
various operators.  There is no need to have a second table imods that
holds the same content.  Rather make modtab constant as well.

The only possible functional change is that the names of the internal
operators 'no-op', '++', '--', 'real', 'imag' and 'case' may appear in
diagnostics, where previously lint invoked undefined behavior by passing
a null pointer for a '%s' conversion specifier.

Revision 1.7 / (download) - annotate - [select for diffs], Sat Mar 20 20:15:37 2021 UTC (22 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.6: +13 -9 lines
Diff to previous 1.6 (colored)

lint: fix argument names and table headings for operator definitions

The abbreviations in the table of operator properties had been wrong
since ops.def 1.10 from 2021-01-12, when strict bool mode was added.  In
an earlier working draft, I had named that column 'takes_others' instead
of 'requires_bool', that's where the 'o' came from.

The names of the macro arguments had been wrong since op.h 1.11 from
2021-01-09, when the order of the columns changed and the macros were
not adjusted accordingly.  Since all the properties of the operator
table are uniform, this didn't result in any bugs, it was just confusing
for human readers.

Clang-tidy suggests to enclose the macro arguments in oper.c in
parentheses but that is not possible since the arguments are either
empty or 1, and the syntactical ambiguity of the '+ 0' being either a
unary or a binary operator is needed here.

No change to the resulting binary.

Revision 1.6 / (download) - annotate - [select for diffs], Sat Mar 20 19:33:25 2021 UTC (22 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.5: +9 -5 lines
Diff to previous 1.5 (colored)

lint: make lint's own code pass the strict bool mode

No functional change.

Revision 1.5 / (download) - annotate - [select for diffs], Mon Jan 18 20:02:34 2021 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.4: +3 -2 lines
Diff to previous 1.4 (colored)

lint: clean up code (mostly comments)

Revision 1.4 / (download) - annotate - [select for diffs], Sat Jan 16 02:40:02 2021 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

lint: replace 0 and 1 with false and true, where appropriate

Change in behavior: Passing the option -h exactly 4294967296 times or
any multiple thereof is no longer equivalent to passing it never at all,
it is now equivalent to passing it once.  See main2.c, hflag++ for the
actual change.

Other than that, no functional change intended.

A very large portion of the code already conformed to the requirements
of the strict bool mode.  The only missing thing was using the constant
literals false and true instead of 0 and 1.  For sure there are some
integer literals left that can be converted.  For now, all literals that
appeared in the form " = 0" or " = 1" have been replaced.

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jan 12 20:42:01 2021 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

lint: add new check for strict bool mode

In strict bool mode, bool is considered incompatible with all other
scalar types, just as in Java, C#, Pascal.

The controlling expressions in if statements, while loops, for loops and
the '?:' operator must be of type bool.  The logical operators work on
bool instead of int, the bitwise operators accept both integer and bool.
The arithmetic operators don't accept bool.

Since <stdbool.h> implements bool using C preprocessor macros instead of
predefining the identifiers "true" and "false", the integer constants 0
and 1 may be used in all contexts that require a bool expression.
Except from these, no implicit conversion between bool and scalar types
is allowed.

See usr.bin/tests/xlint/lint1/d_c99_bool_strict.c for more details.

The command line option -T has been chosen because all obvious choices
(-b or -B for bool, -s or -S for strict) are already in use.  The -T may
stand for "types are checked strictly".

The default behavior of lint doesn't change.  The strict bool check is
purely optional.

An example program for strict bool mode is usr.bin/make, which has been
using explicit comparisons such as p != NULL, ch != '\0' or n > 0 in
most places for a long time now, even before the refactoring in 2020.

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jan 9 22:19:11 2021 UTC (2 years ago) by rillig
Branch: MAIN
Changes since 1.1: +5 -3 lines
Diff to previous 1.1 (colored)

lint: make the table containing the operator properties more readable

The C preprocessor does not require its arguments to be expressions, an
empty string is valid as well.  This allows to replace the 0 in the
operator properties table with a space, making the 1 stick out.

Since the table is quite long, divide it into sections and add section

No change in the generated code.

Revision 1.1 / (download) - annotate - [select for diffs], Sat Jan 9 21:37:44 2021 UTC (2 years ago) by rillig
Branch: MAIN

lint: rename ops.c to oper.c

The file ops.c had previously been autogenerated.  This meant that in a
NetBSD build, it was generated in OBJDIR, and a build that had just
updated src/usr.bin would fail.  For a build that last ran on
2020-12-01, and again today, it looks like this:

	#      link  lint1/lint1
	cc ... -o lint1 cgram.lo ... ops.lo ... tyname.lo
	/usr/bin/ld: ops.lo: in function `initmtab':
	ops.c:(.text+0x63): undefined reference to `STRUCT_ASSIGN'

This is caused by ops.c existing in OBJDIR, so the new version in
NETBSDSRCDIR is not looked at.  To prevent this, use oper.c instead as
the filename, which has not been used before.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

CVSweb <>