Age | Commit message (Collapse) | Author | Files | Lines |
|
The variadic argument code did not check any of the variadic arguments
as it did not previously know the possible type. Now we have the possible
formatting information stored in the ctype, we can do some checks on the
printf formatting types.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Add code to parse the __attribute__((format)) used to indicate that
a variadic function takes a printf-style format string and where
those are. Save the data in ctype ready for checking when such an
function is encountered.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Add some tests for the new printf format checking code.
Note, these do not all pass yet.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This will be used for -Wformat.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is needed for printf format checking of "%zn", "%jn" & "%tn".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is needed for printf format checking of "%hhn" & "%hn".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is needed for printf format checking of "%Ls".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* add support for a new instruction: OP_FMA
* teach sparse to linearize __builtin_fma()
|
|
The support for the linearization of builtins was already
added for __builtin_unreachable() but this builtin has
no arguments and no return value.
So, to complete the experience of builtin linearization,
add the linearization of __builtin_fma().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The motivation for this is to experiment with adding infrastructure
for the linearization of builtins.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Allow the linearization of builtins to fail and continue with
the normal linearization of OP_CALLs. The motivation for this
is for the linearization of target specific builtins.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This will be the instruction for fused multiply-add
but the motivation for it is some experimentation with
the linearization of builtins.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* add & use replace_with_value()
|
|
With this change, using the testsuite via the Makefile is not
limited anymore to a single file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This avoids the need to have a separate 'return REPEAT_CSE' and
thus make the code slightly more compact and fast to read.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Replace existing 'replace_with_pseudo(insn, value_pseudo($N))'
by 'replace_with_value($N)'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
During simplification, it's relatively common to have to replace
an instruction with pseudo corresponding to a known value.
The pseudo can be created with value_pseudo() and the replacement
can be made via replace_with_pseudo() but the combination
of the two is a bit long.
So, create an helper doing both sat once: replace_with_value().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* teach sparse about union casts
|
|
* fix evaluate_ptr_add() when sizeof(offset) != sizeof(pointer)
|
|
* conditionalize warning "advancing past deep designator"
|
|
* cleanup: remove unneeded predeclaration of evaluate_cast()
|
|
evaluate_cast() is predeclared in the middle of the file but
is not used before it's defined.
So, remove this unneeded predeclaration.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
For a binary op, both sides need to be converted to the resulting
type of the usual conversion. For a compound-assignment (which
is equivalent to a binary op followed by an assignment), the LHS
can't be so converted since its type needs to be preserved for
the assignment, so only the RHS is converted at evaluation and
the type of the RHS is used at linearization to convert the LHS.
However, in the case of pointer arithmetics, a number of shortcuts
are taken and as a result additions with mixed sizes can be produced
producing invalid IR.
So, fix this by converting the RHS to the same size as pointers,
as done for 'normal' binops.
Note: On 32-bit kernel, this patch also removes a few warnings
about non size-preserving casts. It's fine as these warnings
were designed for when an address would be stored in an
integer, not for storing an offset like it's the case here.
Reported-by: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A cast to union type is a GCC extension similar to a compound
literal just for union, using the syntax of a cast.
However, sparse doesn't know about them and treats them like
other casts to non-scalars.
So, teach sparse about them, convert them to the corresponding
compound literal and add a warning flag to enable/disable the
associated warning: -W[no-]union-cast.
Note: a difference between union casts and compound literals
is that the union casts yield rvalues while compound
literals are lvalues but this distinction is not yet done
in this series.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
extract evaluate_compound_literal() from evaluate_cast,
in preparation for supporting union casts.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Casts to union type are a GCC extension and are similar to
compound literals.
However, sparse doesn't know about them and treats them like
other casts to non-scalars.
Add some testcases for this and its upcoming warning flag.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* doc: more compact sidebar
* doc: use shorter titles
* doc: reorganize the table of content
|
|
* fouled types are scalars too (fix is_{scalar,integral}_type()
|
|
is_scalar_type() accept SYM_RESTRICT but not SYM_FOULED
but both are for integer types (and only for them).
So, let it accept SYM_FOULED too. Same for is_integral_type().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* force to 0 expressions which are erroneously non-constant
|
|
This test was failing on 32-bit because it made
the assumption that 'long' is always 64-bit.
Fix this by using 'long long' when 64-bit is needed.
Fixes 36a75754ba161b4ce905390cf5b0ba9b83b34cd2
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
One is a LWN article which covers sparse very well, the other
is a pdf giving a short overview of sparse.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Mainly it's removing 'sparse' from the title.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Reorganize the table of of content with user documentation first
then all documentation useful for development on sparse itself.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Better to have the information about the GIT repositories
first because I'm not sure if anyone still use the tarballs.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The vertical spacing in the generated HTML is a bit excessive
to my taste. So decrease it somehow, especially the top of lists.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
There is generous spacing in the sidebar, too generous.
So, reduce it to something more compact, which will also
allow more entries without scrolling.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The logo takes quite a bit height in the sidebar and so
pushes the table of content too much at the bottom.
Fix this by reducing the logo to 50%.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* separate parsing of asm-names from attributes
* simplify parsing of storage modifiers
|
|
* improve presentation of the doc, mainly the sidebar
|
|
The second test is now made as the else part of the first test,
saving a 'return' that is otherwise not needed.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that 'MOD_INLINE' & 'MOD_VOLATILE' are associated with their
corresponding keyword, a single asm_modifier() method can cover
both cases.
So, replace asm_modifier_inline() & asm_modifier_volatile() by
a single, generic version: asm_modifier().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A significant number of declarators need to set or simply use
the modifier associated with the corresponding keyword but this
is open-coded for each of them. As result, almost all keywords
corresponding to a declaration need their own specific method.
Make this more generic by adding the associated modifier to the
ctype associated to keywords and passing the result of the keyword
lookup to the declarator methods. This way, these methods can be
made generic by getting the modifier from the ctype, like it was
already done for attributes.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The handling of the storage class modifiers is done
differently than the other modifiers:
* they don't use MOD_... but their own enums
* consequently they can't use modifier_string() and have
their own string table to display them.
* the attribute 'force' is considered as a kind of storage
class. Fine, but it means that 'register' or '__tls' can't
be used with 'force' (which is probably very fine but
seems more as a side-effect than something really desired).
The real justification for these difference seems to be
that storage class modifiers *must* be treated differently
than the other modifiers because they don't apply at the same
level. For example, in a declaration like:
static const int a[N];
'static' applies to the array/the whole object, while 'const'
only applies to the (type of the) elements of the array.
Storage class specifiers must thus be parsed, stored aside
and only be applied after the whole declarator have been parsed.
But other modifiers are also in the same situation (for example,
'__noreturn' or '__pure' for functions).
So, use the generic keyword/attribute handling of modifiers
for storage class specifiers but for simplicity, store them
separately in decl_state to easily do duplication tests on them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* delay 'empty character constant' warning to phase 5
|
|
When an expression that needs to be constant but is, in fact,
not constant, sparse throws an error and leaves it as-is.
But some code makes the assumption that the expression is
constant and uses its value, with some random result.
One situation where this happens is in code like:
switch (x) {
case <some non-const expression>: ...
In this case, the linearization of the switch/case statement
will unconditionally use the value of the case expression
but the expression has no value.
One way to avoid this would be to add defensive checks each
time a value is retrieved but this is a lot of work and time
for no benefits.
So, change this by forcing the expression to be a constant
value of 0 just after the error message has been issued.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* fix checking if type is void
|
|
Sparse warns if a void function returns a non-void expression.
But the check directly compares the returned type with void_ctype,
without taking in account the presence of a SYM_NODE. In
consequence, sparse issues a few false warnings.
Fix this by using is_void_type() to test the returned type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* teach sparse about wide string initializers
|
|
The warning "advancing past deep designator" is issued when a
multi-level (deep) designator is followed by a non-designated one.
But it's far from clear what is the value of this warning, what
could be the confusion about this situation and what is special
about these 'deep' designators?
There are hundreds such occurrences in the kernel (394 in the configs
I use for testing) and GCC, clang and sparse have no problems to handle
them correctly. This means that there is also 0 chances that they
will be 'corrected'.
So, add conditionalize this warning with a '-Wpast-deep-designator'
and make it false by default.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* fix evaluation of __sync_{bool,val}_compare_and_swap()
|
|
* fix type evaluation of shifts-assigns
* don't warn for UB shifts in dead code
|
|
* fix diagnostic source path from command line
* fix diagnostic source path for invalid streams
|
|
Just a tiny code reorganization to call is_string_type()
only where & when needed.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When evaluating initializers, it must be known if it is for a string
or not. But sparse doesn't known about wide strings.
Fix this by modifying is_string_type() to use is_wchar_type()
in addition of is_byte_type().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Like is_byte_type() but for wide chars.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The examination of a string initializer doesn't know about wide
strings. The only thing needed is if the base type is some kind
of char but for wide chars, this type is the same as 'int' and
an array of ints can't be treated the same as an array of chars.
So, do the detection for wide string initializers as:
1) check that the LHS base type is wchar_ctype
2) check that the RHS is a kind of string expression
(possibly between braces or parenthesis, recursively).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A warning is given for string initializers if the LHS array
is not large enough to contains the string. But this check
doesn't knowns about wide strings.
Fix this by selecting the correct char type and use this type
for the size calculations.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Evaluation doesn't know about wide strings.
Fix this by:
1) selecting the right base type (char_ctype vs wchar_ctype)
2) adapting the type, size & alignment of the underlying array
to this base type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
In the kernel, the architecture s390 uses these builtins to
implement __atomic_cmpxchg() and friends. These builtins
are polymorphic, so they need some special evaluation.
These builtins are known to sparse but with a return type
of 'int' and the argument's types being ignored.
A problem occurs when used on a pointer type: the expected
type doesn't match 'int' and it can give warnings like:
warning: non size-preserving integer to pointer cast
So, improve the support for these builtins by:
*) checking the number of arguments
*) extract the type from the 1st argument
*) set the returned type to this type if needed
*) finally, do the typechecking by calling evaluate_arguments()
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202008072005.Myrby1lg%25lkp@intel.com/
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
evaluate_arguments() is local to evaluate.c but the same functionality
is needed for builtins.
So, in order to not duplicate this code:
*) change slightly its interface to accept the expected types as a list
*) make this function extern.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Sparse complains when a shift amount is too big for the size
of its operand or if it's negative.
However, it does this even for expressions that are never evaluated.
It's especially annoying in the kernel for type generic macros,
for example the ones in arch/*/include/asm/cmpxchg.h
So, remove all warnings done at expansion time and avoid any
simplifications of such expressions. Same, at linearization
and optimization time but in this case mark the instructions as
'tainted' to inhibit any further simplifications. Finally, at the
end of the optimization phase, warn for the tainted instructions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
After the RHS of shift-assigns had been integer-promoted,
both gcc & clang seems to restrict it to an unsigned int.
This only make a difference when the shift count is negative
and would it make it UB.
Better to have the same generated code, so make the same here.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The result of a shift-assigns has the same type as the left
operand but the shift itself must be done on the promoted type.
The usual conversions are not done for shifts.
The problem is that this promoted type is not stored explicitly
in the data structure. This is specific to shift-assigns because
for other operations, for example add-assign, the usual conversions
must be done and the resulting type can be found on the RHS.
Since at linearization, the LHS and the RHS must have the same type,
the solution is to cast the RHS to LHS's promoted type during
evaluation.
This solve a bunch of problems with shift-assigns, like doing
logical shift when an arithmetic shift was needed.
Fixes: efdefb100d086aaabf20d475c3d1a65cbceeb534
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The usual conversions must not be applied to shifts.
This causes problems for shift-assigns.
So, add testcases for all combinations of size and signedness.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The name 'sindex' is already used by another package (biosquid).
So it was decided to rename it to 'semind'.
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
lintian (a linter for Debian packages) warns:
N: This manual page uses the \' groff sequence. Usually, the intent to
N: generate an apostrophe, but that sequence actually renders as a an acute
N: accent.
N:
N: For an apostrophe or a single closing quote, use plain '. For single
N: opening quote, i.e. a straight downward line ' like the one used in
N: shell commands, use \(aq.
I'm not following its advice but stick to ' as is done in other places
of sindex.1.
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Alexey Gladkov <gladkov.alexey@gmail.com>
|
|
Hurd doesn't define PATH_MAX but is needed by pre-process.c
and sindex.c.
pre-process.c had already its local define but sindex doesn't.
So, allow sindex to build on Hurd and avoid possible problems
with some future tools by moving the default define of 4096
for it to lib.h where it will be visible for all code.
Reported-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
|
|
|
|
|
|
|
|
One possible way to compile the linux kernel is by using the O=<DIR>
parameter to place all generated files outside the source tree.
Prior to this patch, sindex filters processed sources to exclude system
files. The base directory of the project was the current directory.
When compiled outside of the source tree, this may not be the case.
This patch adds a parameter and an environment variable to specify
the source tree.
You can use it like this:
$ make O=$PWD-build C=2 CHECK="sindex -B $PWD add --"
This parameter is also needed for searching if you want to display
the source code line because sindex does not store lines in the database
but reads them from source files.
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Change do_expression(EXPR_GENERIC) to inspect expr->control/map/def.
The is the minimal "better than nothing" change, technically incorrect
but still useful for the indexing.
Example:
void func(void)
{
_Generic(a,
int: b,
void: c,
default: d,
) = e;
}
output:
1:6 def f func void ( ... )
3:18 func --- v a bad type
4:33 func -w- v b bad type
5:33 func -w- v c bad type
6:33 func -w- v d bad type
7:13 func -r- v e bad type
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now, diagnostic messages are prepended with the source path.
But if the problem comes from a file included directly from
the command line like:
sparse -include some-buggy-file.c
the prepended message will be:
(null): note: in included file ...
because there isn't a source path yet.
So, initialize the source path to "command-line".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that the parent stream is stored as a position, the validity
of a stream can't anymore be tested by checking if its number
is non-negative because inside a struct position stream number
are stored as an unsigned (and changing it to signed would halve
the maximum number of stream).
So, add a check against input_stream_nr before returning the
previous stream.
Fixes: 4c6cbe557c48205f9b3d2aae4c166cd66446b240
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The dissect client uses struct symbol's fields 'examined' & 'evaluated'
to avoid reprocessing the same symbols. But these fields are used
internally by sparse for type examination & evaluation and despite
dissect not doing these operations explicitly, they can be done
implicitly (for example to handle static assertions or when the
value of a constant expression is needed) inside __sparse().
If this happens, dissect.c:examine_sym_node() will be a no-op because
node->examined will already be set and node->kind would be 0.
Same can happen with node->evaluated.
So, add a new field to struct symbol: 'inspected' and use it, as
well as the existing 'visited', instead of 'evaluated' & 'examined'.
This way, dissect will control its recursion via flags reserved for
backends and thus never set by sparse internals.
Note: when used on the kernel, this patch avoids a lot of warnings:
"warning: r_member bad sym type=7 kind=0"
"warning: r_member bad mem->kind = 0"
and creates substantially more normal output.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
|
|
Just suppress the warning about unknown type.
Before:
$ ./test-dissect validation/generic-functions.c
FILE: validation/generic-functions.c
13:1 def f testf void ( ... )
13:1 testf def . v a float
validation/generic-functions.c:13:1: warning: bad expr->type: 31
13:1 testf -r- . v a float
14:1 def f testd void ( ... )
14:1 testd def . v a double
validation/generic-functions.c:14:1: warning: bad expr->type: 31
14:1 testd -r- . v a double
15:1 def f testl void ( ... )
15:1 testl def . v a long double
validation/generic-functions.c:15:1: warning: bad expr->type: 31
15:1 testl -r- . v a long double
After:
$ ./test-dissect validation/generic-functions.c
FILE: validation/generic-functions.c
13:1 def f testf void ( ... )
13:1 testf def . v a float
13:1 testf -r- . v a float
14:1 def f testd void ( ... )
14:1 testd def . v a double
14:1 testd -r- . v a double
15:1 def f testl void ( ... )
15:1 testl def . v a long double
15:1 testl -r- . v a long double
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Since gcc 3.4.0 there is no option to specify the endianness for
the Xtensa architecture, so the kernel relies on autodetecting
the endianness and then defining the macros __XTENSA_E{B,L}__.
But this means that sparse's 'arch_big_endian' can't be used
for the predefine.
So, do not predefine these macros anymore, they will transparently
be set directly from the command line.
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The field 'result' have been committed by inadvertence in the
initial commit. Remove it now.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The keyword's type is a bitmask because depending on the context
the same keyword can be of different type (for example 'const'
as qualifier and the attribute 'const' , a variant of 'pure').
Thus, it's an error to test this type for equality, instead it's
a specific (set of) bit(s) that must be tested.
So, change a test ' x == KW_...' into 'x & KW_...'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
In the loop doing the parsing of attributes, it's first checked
if EOF is reached, then if the token is ';' but these tests are
not needed since they're subsumed by the third one: checking if
the token is an identifier.
So, remove the tests for EOF and ';', and change the for-loop
into a while-loop checking for TOKEN_IDENT. As a bonus, remove
the local variable holding the identifier since it's there only
for historical reasons.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
All symbols returned by lookup_keyword() are of type SYM_KEYWORD,
because either:
1) it's in NS_KEYWORD (and all symbol in NS_KEYWORD are SYM_KEYWORD)
2) it's in NS_TYPEDEF and all *keywords* in NS_TYPEDEF are reserved
and so can't be user defined and so must be SYM_KEYWORD.
Thus, they all have a symbol_op associated to them and it's
unneeded to test it.
So, remove the unneeded test.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
All symbols returned by lookup_keyword() are of type SYM_KEYWORD,
because either:
1) it's in NS_KEYWORD (and all symbol in NS_KEYWORD are SYM_KEYWORD)
2) it's in NS_TYPEDEF and all *keywords* in NS_TYPEDEF are reserved
and so can't be user defined and so must be SYM_KEYWORD.
It's thus unneeded to test it.
So, remove the unneeded test.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Since '__attribute__' is in NS_TYPEDEF, it's not useful to
look it up also in NS_KEYWORD.
So, remove NS_KEYWORD from the mask while looking up '__attribute__'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Matching the keyword '__attribute__' (or '__attribute') needs
several tests and this matching is needed to handle attributes
or to skip them.
So, create an helper, match_attribute(), and use it in the loops
to handle and to skip attributes.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
handle_attributes() used to also handle asm names and so used
the declarator method associated to the taken. But now, asm names
are handled in a separated function.
So, directly use attribute_specifier() to handle the attributes
instead of using it via the declarator method.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that the asm names are handled in handle_asm(), the 'keywords'
argument of handle_attributes() is no more needed since it always
must be 'KW_ATTRIBUTE'.
So, remove this argument.
Note: this is preparation work to later make the distinction between
function/variable/type/label/... attributes.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
An asm name is not really a declarator, it must only be placed
*after* a declarator and is directly handled by handle_asm_name().
It's thus not needed and possibly confusing to treat it like a
generic declarator.
So, fold parse_asm_declarator() into handle_asm_name() and remove it.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
handle_attributes() handles attributes but also the asm names.
These asm names must occur before the attributes and only once
while the attributes may occur multiple time. Also, these asm
names are not allowed everywhere attributes, only in declarations.
It's maybe handy to process both in the same function but it's
also slightly confusing. So, move the handling of the asm names
in a separate function.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When handling qualifiers, the corresponding symbol is looked-up with
lookup_symbol() then it's checked if the symbol's type is SYM_KEYWORD.
But, only if the identifier is a keyword (struct ident::keyword) can
the symbol be a SYM_KEYWORD. Thus, non-keyword can be filtered-out
early by using lookup_keyword().
So change the call to lookup_symbol() by a call to lookup_keyword().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The '-D' flag was fixed to accept whitespace before the argument
but the '-U' flag wasn't. So, fix this now.
Fixes: 7f1011b311e9329f53d73f88de495ea64071eb77
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The full URL for bugzilla is quite long and was rendered as
split into 2 lines which is quite ugly.
So, do not show the URL but simply the hyperlink's name:
"Linux kernel’s bugzilla for sparse".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Use 'https' instead of 'http' for pages needing some level of trust.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The online documentation was updated for the new homepage
but the manpages were forgotten.
So, update them now.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
modifier_string() returns either "" or a string with one or
several modifiers separated by a space. In this last case the
string has also a trailing space.
This trailing space is sometimes desired (for example when
composed with identifier name: "%s%s") but is also sometimes not
desired (for example when only the modifiers must be displayed).
So, create a variant of modifier_string() which doesn't add the
ending space: modifier_name().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Inlining in sparse works slightly differently than what my
mental model is: the body is only evaluated after the inline
expansion. IOW, an inline function is not evaluated until it
is effectively inlined. That's fine but it means that generic
expressions also need to be handled during the inlining.
However, since the body of inline functions is evaluated just
after inline expansion, so (recursively) copying the expression
and its type - expression map is quite useless here.
So, just copy the expression itself and its control expression
to 'isolate' them from evaluation, evaluate it and then just
copy the selected expression.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Since C99, a '*' is allowed in an abstract array declarator to
specify that the array is a VLA with a yet-to-be-determined size.
So, accept this construction (but still ignore it for now).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
match_idents() is now unused and identifier matching should
preferably be done via the keyword table.
So, remove this function.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Any type qualifier is valid inside an abstract-array-declarator
but currently only 'restrict' is accepted. Also the parsing of
this is somehow more complex than needed and done by comparing
the identifiers instead of being driven by the keyword table.
So, simplify & fix the parsing of these declarators by:
1) using the keyword type KW_QUALIFIER to identify all type
qualifier at once.
2) add a new keyword type just for 'static'
3) folding the helper abstract_array_static_declarator() into
the main function: abstract_array_declarator().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
C99 introduced some funky new array declarators, those with
'restrict' or 'static' inside the brackets.
Add some testcases for them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Comma expressions are not allowed for the size in an array
declarator.
So, change the parsing of these expressions to only accept
assignment-expressions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Comma expressions are not allowed for the size in an array
declarator. Add a testcase for this.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The documentation for submitting patches has ": the sparse version"
is in its title. This is quite useless and makes it longer than
needed.
So, remove this part from the title.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
since the development isn't done on github, the link "edit on github"
is useless and confusing.
So remove this link (but leave the one "View page source" as it's
sometimes quite handy).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
It's very useful to be able to access the index from the sidebar
but no change in the configuration seems to allow this. Trying
to abuse the toctree give the same result.
So, add it directly via the template system.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Combine the 'user' documentation with the one for developers
and add captions for each sections in order to have this
structuration visible in the sidebar.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The nocast-vs-bitwise document was copied here to be sure
to remain accessible but isn't really useful here now because:
1) the original document have also been archived to lore.kernel.org
2) nocast & bitwise have now been documented
3) 2) contains a link to 1)
So, remove this redundant document.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
First try at documenting sparse's extensions to C's type system.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that struct stream contains the parent's stream, it
might as well contains the position so that all information
about the parent is available.
So, add a struct position to struct stream, initialize it
with the information from the '#include' token (if there is one)
and use this positions's ::stream as previous/parent stream.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A subset of C syntax regarding character constants is:
char-constant:
' c-char-sequence '
c-char-sequence:
char
c-char-sequence char
In short, when tokenized, a character constant must have at least
one character between the quotes. Consequently, sparse will
issue an error on empty character constants (unlike GCC).
However, sparse issues the error during tokenization (phase 3),
before preprocessing directives are handled (phase 4).
This means that code like:
#if 0
... ''
#endif
will throw an error although the corresponding code is discarded.
Fix this by
1) silently accept empty char constants during tokenization
2) issue the diagnostic only when escape sequences are handled.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When a diagnostic is issued for a problem in an included file,
the message show the include's path but it's often needed to
(quickly) know the chain of include files involved.
So, if the path associated with the diagnostic is different
than the path oft he source file and different from the path
of the previous message, prepend the message with a note
showing the source file's path. And, if any intermediate
include file is concerned, display the include chain
(possibly truncated or not displayed at all if too long).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* teach sparse about -fmax-errors
* syntax errors in numbers are not fatal
|
|
* warn on empty assignments & initializations
|
|
* some small adjustments to the builtin types and predefined macros.
|
|
All the helpers for type-related predefines directly take in
argument the pointer to the type. All but predefine_width().
This must be an historical relic.
So, let predefine_width() also take the pointer to the type
as argument.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When parsing expressions, if an invalid number is reached, a fatal
error is issued. But this is not the kind of error for which
continuing the processing doesn't make sense, since the token
was already categorized as a number during the tokenization.
So, change the fatal error into a normal one (and set the value to 0).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
|
|
|
|
|
|
Currently sparse accepts an empty initialization like:
int a = ;
Make this an error.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Currently sparse accepts an empty assignment like:
a = ;
Make this an error.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On x86-64, the x32 ABI was processed as a kind of special case
of the usual 32-bit variant. But this doesn't work very well.
Fix it and help avoiding possible future problems by defining
a separate target for it.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
These types are aliased to size_t & ssize_t but this is not
correct for all architectures.
So, add a variable for them so that target files can adjust them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This type is predefined by GCC so add it to sparse too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
We just added __INT_LEAST${N}_TYPE__, so add these ones
too as they looks slightly more useful.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
These are used by some system headers (neon on arm64).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On powerpc, if long double is 128-bit width, then
'__LONGDOUBLE128' & '__LONG_DOUBLE_128__' should be defined.
So do this in the target specific file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Support for alpha was added in order to move the specific builtins
away from the common list without changing the defaults.
Improve the support for this arch by fixing a few specificities:
* support of 128-bit integers
* long doubles are 64-bit.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
By default, the architecture version is 'v8' for sparc32
and 'v9' for sparc64.
The predefines were added for sparc64 but not for sparc32.
Fix this by adding a generic 'sparcv%d' together with a
variable to hold the architecture version and initialize
this one accordingly.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
|
|
This is a fix for a problem reported today to the mailing list.
In check_assignment_types(), the first 'level' is checked by the
function itself but the next level is checked by the type_difference().
This later function take as arguments, beside the types to be
checked, the modifiers that can be assumed for each of the types
(this works as a kind of reverse mask).
But these modifiers are taken from target_qualifiers() which,
purposely ignore the modifiers for arrays introduced in commit
984b7b66457c ("[PATCH] deal correctly with qualifiers on arrays")
with the comment:
"Pointers to any array are considered as pointers to unqualified
type as far as implicit conversions are concerned"
But by dropping these modifiers, type_difference() reports
incorrect results for pointers to qualified arrays.
So, do not use target_qualifiers() but take the modifiers directly
from the ctypes. Admittingly, I'm far from sure that this is the
right fix but it solve several wrong cases.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is one of the architecture needing a specific predefine
set in order to correctly process byteorder.h.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is now the only architecture needing '-msize-long'.
Prepare the obsolescence of this option by adding the
target file for this architecture.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On arm, int32_t & uint32_t seem to be differently defined on bare-metal.
Fix this in the target-specific file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that the OS can be specified to sparse via an option (--os=$OS)
and that sparse knows about their specificities, it's no more
needed or useful to also define them in cgcc.
So, remove from cgcc the OS-specificities known to sparse (a few
few exotic ones remain for now) but ensure that the info about
the correct OS is passed to sparse.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
For CygWin, GCC defines some pseudo-specifiers like '__cdecl',
'__stdcall' or '_thiscall'. Some of these are already defined by cgcc.
So, add these predefines to sparse itself.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Predefine macros like '__OpenBSD__', ... for the three BSDs,
CygWin and Darwin (those for Linus and SunOS were already defined).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On Solaris, at least on sparc32, chars are unsigned.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On NetBSD & OpenBSD, some types are not defined like on Linux.
Fix this.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On Darwin, '__unix__' & '__unix' doesn't seem to be predefined.
Don't ask me why.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
These are already defined in cgcc but not yet by sparse
itself. So, add them now.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is not needed when doing native 'compilation' but is
quite handy when testing the predefined types & macros.
The supported OSes are: 'linux', 'freebsd', 'openbsd', 'netbsd'
'darwin', 'sunos', 'cygwin' and a generic 'unix'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Currently, the maximum number of displayed errors is 100.
This is nice to not be flooded with error messages when things
are really broken but in some situation, for example testing,
it is desirable to have all error messages.
So, teach sparse about '-fmax-errors=COUNT'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The problem is seems to be related with evaluate_dereference()
where all mods are dropped when the type is a node.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Those are cases that sparse should warn about but doesn't.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
You can assign a '<type>[]' to a 'const <type> *'. Likewise,
you can assign a '<type>[][N]' to a 'const <type> (*)[N]' but
sparse doesn't like this.
Analyzed-by: Ard Biesheuvel <ardb@kernel.org>
Reported-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://lore.kernel.org/linux-crypto/20200709120937.GA13332@gondor.apana.org.au/
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
More, specifically, split the 'init' method into a common part
and add one for each of the i386 (32-bit) and another one for 64-bit.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Most keywords have a variant with the leading nd trailing
double-underscore. Some have also a variant with only the
leading underscores. But only the identifier change, the
remaining of the information is duplicated for them.
So, use some macros to define the corresponding entries
without duplication.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Reorder the keywords to make them even more logically organized.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
With time, the keyword table has become quite hard to read.
So, split the table in 2: one for NS_TYPEDEF and one for NS_KEYWORD.
This allows to remove one argument, making more place for those
that really matter.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Depending on the endianness, predefine '__ARMEL__' or '__ARMEB__'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Depending on the endianness, predefine '__AARCH64EL__' or '__AARCH64EB__'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
It seems that in the next version of the standard, the
second argument of _Static_assert() will be optional.
Nice. Let sparse already support this now.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
For Nios2, some predefines with the trailing double underscores
were added but the variant with only the leading ones are also
used. So add these too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
On Nios2, long double are (of course) only 64 bits width.
Specify this in the target file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* predefine: fix multi-token predefine
* predefine: add helper predefine_{strong,weak}()
* predefine: avoid add_pre_buffer() for targets
* predefine: simplify add_pre_buffer()
|
|
The RISC-V architecture has some predefined macros
to specify which extensions are supported.
So, now that these extensions are known via the '-march'
options, add the corresponding predefines.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The RISC-V architecture has quite a bit of extensions.
Some of these correspond to a predefined macro and thus
parsing correctly the '-march' flag can be important.
So, teach sparse how to parse this flag for RISC-V.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The option '-march' is not one of the common option but is
architecture specific.
So, teach sparse to delegate the parsing of this option to
the targets.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
pre_buffer_begin & pre_buffer_end are the head and the tail of
a singly chained list. As such, it's slightly easier to not
keep a pointer on the last element but a pointer where the
next element should be written.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Avoid add_pre_buffer() and use one of the predefine...()
variant instead.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A lot of predefined macros are just set to the value '1' and
of them have a name that is not statically known. OTOH, the
function predefine() is designed for a statically known name
but a variable value.
Add a set of helpers to cover the first case: predefine_strong()
and predefine_weak().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The function predefine() and its variants are only valid
if they define a single-token value.
However, when a type is signed, predefine_min() will produce
a multi-token value.
Fix this by using add_pre_buffer() instead of predefine().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The function predefine() and its variants are only valid
if they define a single-token value.
Add a testcase for this.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When doing a shift operation, both arguments are subjected to
integer promotion and the type of the result is simply the type
of the promoted left operand. Easy.
But for a shift-assignment, things are slightly more complex:
-) 'a >>= n' should be equivalent to 'a = a >> n'
-) but the type of the result must be the type of the left
operand *before* integer promotion.
Currently, the linearization code use the type of the right
operand to infer of the type of the operation. But simply changing
the code to use the type of the left operand will also be wrong
(for example for signed/unsigned divisions). Nasty.
For example, the following C code:
int s = ...;
s >>= 11U;
is linearized as a logical shift:
lsr.32 %r2 <- %arg1, $11
while, of course it's an arithmetic shift that is expected:
asr.32 %r2 <- %arg1, $11
So, add a testcase for these.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The Kernel Test Robot reports a problem on microblaze.
The cause is that __MICROBLAZEEL__ is not defined. However, the real
problem is that sparse has no support at all for this architecture.
So, add the minimal support for microblaze.
Link: https://lore.kernel.org/lkml/202007060542.hNfoTcsC%25lkp@intel.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
A lot of content in lib.c have been added by just appending at the
bottom of what was already present. As consequence, things are now
not well organized at all, especially when related to the options.
So, reorganize things a little bit here:
* move all helpers on top
* keep things alphabetically sorted
* move options parsing in a separate file
* move predefine-related stuff in a separate file
|
|
Now lib.c contains almost nothing else than library entrypoints.
Move a small utility, hexval(), to utils.c to complete this cleanup.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
lib.c contains 2-3 helpers for parsing. Move them to parse.c.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The test-inspect tool uses GTK to visualize symbol nodes. It turns
out that gtk_init() implicitly sets the locale to the system locale,
and since Sparse uses strtod()/strtold() for parsing floating-point
numbers in expressions, parsing becomes locale-dependent.
Since the system's locale may be different from "C", test-inspect
may be unable to parse float numbers.
Steps to reproduce:
$ echo "int main(void){3.14;}" > test.c
$ LC_ALL="fr_FR.UTF-8" test-inspect test.c
Output:
test.c:1:16: error: constant 3.14 is not a valid number
Fix this by resetting the locale right after gtk_init().
Signed-off-by: Davidson Francis <davidsondfgl@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
* sindex: avoid a warning with 'case -1:'
|
|
When parsing the format, there is a 'case -1:' which:
* seems to be there only for the following label (but mixing
labels with cases, like here, is OK).
* on architectures where chars are unsigned, the compiler complains:
warning: case label value is less than minimum value for type
So, remove the unneeded 'case -1:' and use an explicit 'default:'
to catch invalid formats. Also, align the label with the cases,
it looks nicer so.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Reviewed-by: Alexey Gladkov <gladkov.alexey@gmail.com>
|
|
* teach sparse about arch specific asm constraints
* teach sparse about memory operand constraints for ppc & s390
|
|
* remove pre-C99 compatibility layer for BSD & Solaris
|
|
The 'Q', 'R', 'S' & 'T'' asm constraint are used for for memory
operands on S390 but only 'Q' belong to the 'common constraints'.
Fix this by handling the 3 others with an arch-specific method.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The 'Z' asm constraint is used for doing IO accessors on PPC but
isn't part of the 'common constraints'. It's responsible for
more than half of all warnings (with defconfig + allyesconfig).
Fix this by handling this constraint in a specific method for PPC.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When evaluating asm operands it must be known if they correspond
to a memory operand or not in order to process/ignore the 'noderef'
attribute.
This is done for operands specified with the common constraints
but not for the machine specific constraints.
So, add support for processing machine specific constraints.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This flag facilitates the creation of testcases for preprocessing.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
When inlining multiple times a function which contains an undeclared
function call, multiple error messages are issued. More annoyingly,
only the first one is meaningful, the other ones doesn't even show
the incriminated identifier:
error: undefined identifier '...'
error: not a function <noident>
Part of the problem is that the first message is displayed with
expression_error() which also sets the expression to &bad_ctype.
This change the way how the expression is handled when re-evaluated.
Fix this by avoiding the evaluation of function calls that already
evaluate to bad_ctype: it's known that an error message have already
been issued for them and that nothing good can done with them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Now that option parsing have moved to a separate file, move
everything related to predefined macros to a separate file too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The declarations and definitions of the variables corresponding to
the options half-sorted half-unsorted.
Sort them a little more.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
lib.c contains to much things and is too hard to keep tidy.
So, move everything related to option parsing in it's own file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is just to isolate the details about which switch need an
extra 'finalization' in a separate function in preparation
to moving all the parsing code in a separate file.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'tabstop' is unusual in the sense that it's one the few (the only?)
variable defined via an option flag which is not declared in "lib.h"
but in "token.h". This for to have to include "token.h" in the code
doing the parsing of the options ...
Move this declaration to "lib.h".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
It's a stylistic detail but a lot of the strcmp() calls used for
the processing of the options are written 'strcmp (...)'. Two
other functions calls are also in the case.
Reformat them to the usual style for function calls: without
the space between the function name and the arguments.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
These function have probably been added in 'historical order' and
as result it's not easy to quickly see where they're defined.
Change this arranging them in asciibetical order.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The helpers for parsing the options are often situated just above the
first function using them. As result, these helpers can be found a bit
everywhere in the code, it's messy and doesn't help to reuse these helpers.
So, move all these helpers to the top.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
So, use 'flag' instead of 'warning' for variable and function names.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|