aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
AgeCommit message (Collapse)AuthorFilesLines
2017-02-13C11: teach sparse about '_Alignof()'Luc Van Oostenryck1-0/+1
This is a new name for GCC's '__alignof()' operator which was already supported. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2014-10-10don't call isdigit/tolower with a char argumentRamsay Jones1-1/+1
This suppresses some "array subscript has type 'char'" warnings from gcc (version 4.8.3). (see also, commit cf5114a1) Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-11-29sparse: Relicense under the MIT licenseFranz Schrober1-1/+17
The old code was relicensed by Novafora Corporation, successor in interest to Transmeta Corporation, in 2009. Other authors were also asked about the change of their contributions to the MIT license and all with copyrightable changes agreed to it. Signed-off-by: Franz Schrober <franzschrober@yahoo.de> Acked-by: Adam DiCarlo <adam@bikko.org> Acked-by: Al Viro <viro@ZenIV.linux.org.uk> Acked-by: Alberto Bertogli <albertito@blitiri.com.ar> Acked-by: Alecs King <alecs@perlchina.org> Acked-by: Alexander Shishkin <alexander.shishckin@gmail.com> Acked-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: Alexey Zaytsev <alexey.zaytsev@gmail.com> Acked-by: Andries E. Brouwer <Andries.Brouwer@cwi.nl> Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Acked-by: Ben Pfaff <blp@nicira.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Bernd Petrovitsch <bernd@petrovitsch.priv.at> Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Acked-by: Blue Swirl <blauwirbel@gmail.com> Acked-by: Chris Forbes <chrisf@ijw.co.nz> Acked-by: Chris Wedgwood <cw@f00f.org> Acked-by: Christopher Li <sparse@chrisli.org> Acked-by: Damien Lespiau <damien.lespiau@gmail.com> Acked-by: Dan Carpenter <error27@gmail.com> Acked-by: Dan McGee <dan@archlinux.org> Acked-by: Daniel De Graaf <danieldegraaf@gmail.com> Acked-by: Daniel Sheridan <dan.sheridan@postman.org.uk> Acked-by: Dave Jones <davej@redhat.com> Acked-by: David Given <dg@cowlark.com> Acked-by: David Miller <davem@redhat.com> Acked-by: David Mosberger-Tang <dmosberger@gmail.com> Acked-by: David Olien <David.Olien@lsi.com> Acked-by: Diego Elio Pettenò <flameeyes@flameeyes.eu> Acked-by: Emil Medve <Emilian.Medve@Freescale.com> Acked-by: Ethan Jackson <jacksone@nicira.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Frank Zago <fzago@systemfabricworks.com> Acked-by: Frederic Crozat <fcrozat@suse.com> Acked-by: Geoff Johnstone <geoff.johnstone@gmail.com> Acked-by: Hannes Eder <hannes@hanneseder.net> Acked-by: Jan Pokorný <pokorny_jan@seznam.cz> Acked-by: Jeff Garzik <jgarzik@redhat.com> Acked-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Joe Perches <joe@perches.com> Acked-by: Joel Soete <rubisher@scarlet.be> Acked-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Acked-by: Josh Triplett <josh@kernel.org> Acked-by: Kamil Dudka <kdudka@redhat.com> Acked-by: Kim Phillips <kim.phillips@linaro.org> Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com> Acked-by: Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Acked-by: Martin Nagy <nagy.martin@gmail.com> Acked-by: Masatake YAMATO <yamato@redhat.com> Acked-by: Mauro Dreissig <mukadr@gmail.com> Acked-by: Michael Büsch <m@bues.ch> Acked-by: Michael Stefaniuc <mstefani@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Mika Kukkonen <mikukkon@iki.fi> Acked-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Mitesh Shah <Mitesh.Shah@synopsys.com> Acked-by: Morten Welinder <mortenw@gnome.org> Acked-by: Namhyung Kim <namhyung@gmail.com> Acked-by: Nicolas Kaiser <nikai@nikai.net> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Pavel Roskin <proski@gnu.org> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Acked-by: Peter Jones <pjones@redhat.com> Acked-by: Peter A Jonsson <pj@sics.se> Acked-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Acked-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Randy Dunlap <rdunlap@xenotime.net> Acked-by: Reinhard Tartler <siretart@tauware.de> Ached-by: Richard Knutsson <richard.knutsson@gmail.com> Acked-by: Rob Taylor <rob.taylor@codethink.co.uk> Acked-by: Rui Saraiva <rmpsaraiva@gmail.com> Acked-by: Ryan Anderson <ryan@michonline.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Samuel Bronson <naesten@gmail.com> Acked-by: Santtu Hyrkkö <santtu.hyrkko@gmail.com> Acked-by: Shakthi Kannan <shakthimaan@gmail.com> Acked-by: Stephen Hemminger <shemminger@linux-foundation.org> Acked-by: Thomas Schmid <Thomas.Schmid@br-automation.com> Acked-by: Tilman Sauerbeck <tilman@code-monkey.de> Acked-by: Vegard Nossum <vegardno@ifi.uio.no> Acked-by: Xi Wang <xi.wang@gmail.com> Acked-by: Yura Pakhuchiy <pakhuchiy@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-25Get rid of gcc warning about enum valuesChristopher Li1-1/+1
Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-23Fix segfault cause by fucntion without ident.Christopher Li1-1/+1
This allow compile "drivers/usb/core/hub.c" without sefault. Signed-off-by: Christopher Li <sparse@chrisli.org>
2013-02-13Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/sparse into margeChristopher Li1-101/+50
Pull preprocessor fix from Al Viro. 1) we really, really shouldn't convert escape sequences too early; #define A(x) #x A('\12') should yield "'\\12'", *not* "'\\n'". 2) literal merging handles all sequences of string/wide string literals; result is wide if any of them is wide. string_expression() is handling that wrong - "ab"L"c" is L"abc" 3) with support (no matter how cursory) of wide char constants and wide string literals, we really ought to handle #define A(x,y) A(L,'a') properly; it's not that tricky - combine() needs to recognize <IDENT["L"],CHAR> and <IDENT["L"],STRING> pairs. 4) '\777' is an error, while L'\777' is valid - the value should fit into unsigned char or unsigned counterpart of wchar_t. Note that for string literals this happens *after* phase 6 - what matters is the type of literal after joining the adjacent ones (see (2) above). 5) stringifying should only quote \ and " in character constants and string literals, #define A(x) #x A(\n) should produce "\n", not "\\n" 6) we are losing L when stringifying wide string literals; that's wrong. I've patches hopefully fixing the above. Basically, I delay interpreting escape sequences (past the bare minimum needed to find where the token ends) until we are handling an expression with character constant or string literal in it. For character constants I'm keeping the token body in token->embedded - 4-character array replacing token->character. That covers practically all realistic instances; character constant *may* be longer than that, but it has to be something like '\x000000000000000000000000041' - sure, that's 100% legitimate C and it's going to be the same as '\x41' on everything, but when was the last time you've seen something like that? So I've split TOKEN_CHAR into 5 values - TOKEN_CHAR+1--TOKEN_CHAR+4 meaning 1--4 characters kept in ->embedded[], TOKEN_CHAR itself used for extremely rare cases longer than that (token->string holds the body in that case). TOKEN_WIDE_CHAR got the same treatment. AFAICS, with those fixes we get the same behaviour as in gcc for silently ignored by cpp if the string/char constant doesn't make it out of preprocessor. sparse still warns about those. The situation with this one is frustrating; on one hand C99 is saying that e.g. '\x' is not a token. Moreover, in a footnote in 6.4.4.4 it flat-out requires diagnostics for such. On the other hand... footnotes are informative-only and having "other character" token match ' would puts us in nasal daemon country, so gcc is free to do whatever it feels like doing. I think we shouldn't play that kind of standard-lawyering *and* sparse has always warned on that, so I've left that warning in place. Note that real wchar_t handling is still not there; at the very least, we need to decide what type will be used for that sucker (for gcc it's int on all targets we care about), fix the handling of wide string literals in initializers and evaluate_string() and stop dropping upper bits in get_string_constant(). That would probably mean not using struct string for wide ones, as well... Hell knows; I don't want to touch that right now. If anything, I'd rather wait until we get to C11 support - they've got much saner variants of wide strings there (char16_t/char32_t with u and U as token prefix as L is used for wchar_t; there's also u8"..." for UTF8 strings).
2013-02-12switch to delayed handling of escape sequencesAl Viro1-48/+5
#define A(x) #x A('\12') should *not* yield "'\\n'"; the problem is that we are doing the conversion too early. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-11Fix wrong array size expressionMauro Dreissig1-1/+1
Signed-off-by: Mauro Dreissig <mukadr@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2012-04-13Fix handling of __func__Al Viro1-53/+45
It's not a string literal, it's a static array Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2011-11-21recognize binary constantsDan Carpenter1-1/+8
Sparse doesn't parse binary constants properly so the following code generates an error: x = 0b11; test.c:5:17: error: constant 0b11 is not a valid number Kamal: add call to tolower(), since "0B11" is also a valid syntax. Reported-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
2011-04-26use ARRAY_SIZE() when possible (continued)Jan Pokorný1-1/+1
Some cases were omitted with the patch from Namhyung Kim (commit c5e425e in Chris Li's repo). My curiosity led me to try out coccinelle/spatch as suggested by Nicholas Mc Guire in reply to Kim's patch, but it*) only discovered occurrences in show-parse.c, probably because of "const vs. non-const" differences of array item types and the expression given to sizeof. *) sequence to try coccinelle out on this case (when coccinelle installed): $ wget http://coccinelle.lip6.fr/rules/array.cocci $ sed 's/<linux\/kernel.h>/"lib.h"/' array.cocci > array-sparse.cocci $ for i in $(find . -path ./validation -prune -o -name "*.c" -print); \ > do spatch -sp_file array-sparse.cocci $i; done Beside proceeding messages, this will print out any "real" patch generated according to the semantic patch in `array-sparse.cocci' (it can also reflect these changes directly etc.). Signed-off-by: Jan Pokorny <pokorny_jan@seznam.cz> Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-06-17Parsing wide char stringChristopher Li1-5/+8
A follow up change to parse the wide char string. It currently only parse and store it like normal strings. Need more change to reflect the base type and size etc. Signed-off-by: Christopher Li <sparse@chrisli.org>
2010-04-08Allow parsing L'\0'Christopher Li1-1/+2
It is nasty that L'\0' start from an identifier letter. I try my best not to slow down the hot path. The test is done inside get_one_identifier() after the ident hash is built. It look a little bit out of palace but faster than testing 'L' before hand. Signed-off-by: Christopher Li <sparse@chrisli.org>
2009-07-18Don't mix storage class bits with ctype->modifiers while parsing typeAl Viro1-7/+5
Keep storage class (and "is it inline") explicitly in decl_state; translate to modifiers only when we are done with parsing. That avoids the need to separate MOD_STORAGE bits while constructing the type (e.g. in alloc_indirect_symbol(), etc.). It also allows to get rid of MOD_FORCE for good - instead of passing it to typename() we pass an int * and let typename() tell whether we'd got a force-cast. Indication of force-cast never makes it into the modifier bits at all. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
2009-07-18Simplify get_number_value() and ctype_integer()Al Viro1-20/+20
There's no point whatsoever in constructing modifiers for chosen type when decoding integer constant only to have them picked apart by ctype_integer(). Seeing that the former is the only caller of the latter these days, we can bloody well just pass the rank and signedness explicitly and save a lot of efforts. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
2009-07-17Fix type_info_expression()Al Viro1-2/+10
sizeof (typename){initializers}.foo is nice and valid C99 - it's parsed as sizeof primary.foo <- sizeof postfix.foo <- sizeof postfix <- sizeof unary <- unary. Current type_info_expression() stops too early. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
2008-07-14Set *tree to NULL on errorVegard Nossum1-0/+2
On "Syntax error in unary expression", the output parameter "tree" would be left uninitialized and subsequently used in unary_expression(), leading to segfault. Caught by valgrind and fixed by me ;-) Signed-off-by: Vegard Nossum <vegardno@ifi.uio.no>
2007-07-29[PATCH] braino in conditional_expression()Al Viro1-1/+1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-07-24expression.c: Clean up match_oplist() and add missing va_end()ricknu-0@student.ltu.se1-7/+7
Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
2007-07-10fix handling of address_space in casts and assignmentsAl Viro1-5/+13
Turn FORCE_MOD into storage class specifier (that's how it's actually used and that makes for much simpler logics). Introduce explicit EXPR_FORCE_CAST for forced casts; handle it properly. Kill the idiocy in get_as() (we end up picking the oddest things for address space - e.g. if we have int __attribute__((address_space(1))) *p, we'll get warnings about removal of address space when we do things like (unsigned short)*p. Fixed. BTW, that had caught a bunch of very odd bogosities in the kernel and eliminated several false positives in there. As the result, get_as() is gone now and evaluate_cast() got simpler. Kill the similar idiocy in handling pointer assignments; while we are at it, fix the qualifiers check for assignments to/from void * (you can't assign const int * to void * - qualifiers on the left side should be no less than on the right one; for normal codepath we get that checked, but the special case of void * skips these checks). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-07-08fix the comma handling in integer constant expressionsAl Viro1-11/+3
Treat it as normal binary operation, taint the value, check the taint. We can do other kind of value tainting with the same infrastructure as well... Review and testing would be welcome; AFAICS, it works, but... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-26[PATCH] fix handling of integer constant expressionsAl Viro1-6/+62
Hopefully correct handling of integer constant expressions. Please, review. Rules: * two new flags for expression: int_const_expr and float_literal. * parser sets them by the following rules: * EXPR_FVALUE gets float_literal * EXPR_VALUE gets int_const_expr * EXPR_PREOP[(] inherits from argument * EXPR_SIZEOF, EXPR_PTRSIZEOF, EXPR_ALIGNOF get int_const_expr * EXPR_BINOP, EXPR_COMPARE, EXPR_LOGICAL, EXPR_CONDITIONAL, EXPR_PREOP[+,-,!,~]: get marked int_const_expr if all their arguments are marked that way * EXPR_CAST gets marked int_const_expr if argument is marked that way; if argument is marked float_literal but not int_const_expr, we get both flags set. * EXPR_TYPE also gets marked int_const_expr (to make it DTRT on the builtin_same_type_p() et.al.) * EXPR_OFFSETOF gets marked int_const_expr When we get an expression from parser, we know that having int_const_expr on it is almost equivalent to "it's an integer constant expression". Indeed, the only checks we still have not done are that all casts present in there are to integer types, that expression is correctly typed and that all indices in offsetof are integer constant expressions. That belongs to evaluate_expression() and is easily done there. * evaluate_expression() removes int_const_expr from some nodes: * EXPR_BINOP, EXPR_COMPARE, EXPR_LOGICAL, EXPR_CONDITIONAL, EXPR_PREOP: if the node is marked int_const_expr and some of its arguments are not marked that way once we have done evaluate_expression() on them, unmark our node. * EXPR_IMLICIT_CAST: inherit flags from argument. * cannibalizing nodes in *& and &* simplifications: unmark the result. * EXPR_CAST: unmark if we are casting not to an integer type. Unmark if argument is not marked with int_const_expr after evaluate_expression() on it *and* our node is not marked float_literal (i.e. (int)0.0 is fine with us). * EXPR_BINOP created (or cannibalizing EXPR_OFFSETOF) by evaluation of evaluate_offsetof() get int_const_expr if both arguments (already typechecked) have int_const_expr. * unmark node when we declare it mistyped. That does it - after evaluate_expression() we keep int_const_expr only if expression was a valid integer constant expression. Remaining issue: VLA handling. Right now sparse doesn't deal with those in any sane way, but once we start handling their sizeof, we'll need to check that type is constant-sized before marking EXPR_SIZEOF int_const_expr. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-26[PATCH] implement __builtin_offsetof()Al Viro1-0/+67
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-06-25[PATCH] deal with enum members without excessive PITAAl Viro1-0/+7
mark symbols for enum members, have primary_expression() copy their ->initializer instead of dancing through the EXRP_SYMBOL with expand_expression() finally getting to the damn thing. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-05-26handle __alignof as equivalent of __alignof__Al Viro1-0/+1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2007-03-09Fix typos in commentsJosh Triplett1-1/+1
Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-11-21double inclusionsNicolas Kaiser1-1/+0
Remove two double inclusions. Signed-off-by: Nicolas Kaiser <nikai@nikai.net> Signed-off-by: Josh Triplett <josh@freedesktop.org>
2006-07-05[PATCH] Add support for GCC's __builtin_types_compatible_p extensionJosh Triplett1-2/+47
Parse and support GCC's __builtin_types_compatible_p extension, which takes two types as arguments, and returns 1 for compatible types or 0 for incompatible types. Since sparse already supports comparisons with types as the operands, just transform __builtin_types_compatible_p(a, b) into the comparison a == b. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-16Re-name "error()" function to "sparse_error()"Linus Torvalds1-4/+4
Mitesh Shah (and others) report that broken libc's will have their own "error()" that the sparse naming clashes with. So use a sed-script to rewrite all the occurrences. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-22[PATCH] replaced warnings with errors.Mitesh Shah1-4/+4
This replaceq calls to warning() with error() at places where (I think) the gcc reports an error. Also added a global variable die_if_error which is set if there is one or more errors. If someone wants to stop processing further, can check for the variable. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-09Warn about undefined preprocessor symbols at expansion time, not parse timeLinus Torvalds1-0/+9
This means that we can do #if defined(TOKEN) && TOKEN > 1 and we will _not_ warn even with -Wundef, since the "TOKEN > 1" test will never even be expanded if TOKEN isn't defined. Al Viro gets credit for the algorithm changes, I just did the actual coding. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-19Fix assignment and conditional expression parsing with no left side.Linus Torvalds1-2/+2
We used to parse it with a NULL left side, which just doesn't make any sense. Refuse to recognize it instead.
2005-04-07Split out the blob allocator from lib.c into allocate.c.Linus Torvalds1-0/+2
It's disgusting how intimate lib.c is with all the types, and this is slowly trying to split things up a bit. Now the intimate part is in allocate.c, but maybe we can get to the point where each allocation user just declares its own allocation strategy, and just uses the generic routines in allocate.c
2005-04-07Update copyright notices a bit.Linus Torvalds1-1/+1
2005-04-07Add __sizeof_ptr__ that looks at a pointer expression andLinus Torvalds1-31/+47
returns the size of the underlying object. This is different from "sizeof(*expr)" for arrays, where the array would degenerate to a pointer to one member, and thus "sizeof(*expr)" gives the size of one entry in the array. Why do this? It's useful for things like #define memset(a,b,c) ({ \ (void) __builtin_warning(__sizeof_ptr__(a) > 1, __sizeof_ptr__(a) != (c), "check memset size"); \ memset(a, b, c); }) where we really want to check the size of the object we're doing the "memset()" on, but the regular sizeof() just doesn't cut it.
2005-04-07Handle __func__, __FUNCTION__ and __PRETTY_FUNCTION__ the sameLinus Torvalds1-0/+59
way, and give them a real string. This means that __func__ actually works as a constant string, not as a pseudo-symbol, which is wrong. But hey, sue me.
2005-04-07Add system-specific compatibility functions to makeLinus Torvalds1-2/+1
up for various system deficiencies. This makes sparse easier to port to silly things like MinGW or Solaris. In particular: - strtold() is a C99 thing, not everybody has it - MinGW has problems with mmap(MAP_ANONYMOUS) and doesn't zero it. - st_ino/st_dev is POSIX identity testing, not supported by MinGW
2005-04-07Many files:welinder@darter.rentec.com1-10/+10
warn->warning error->error_die new error lib.h: warn->warning error->error_die new error Add gcc format checking to warning/error/...
2005-04-07Keep track of computed target label lists per-function.Linus Torvalds1-1/+6
Associate them with each computed goto, and copy them properly when inlining.
2005-04-07Make sizeof understand the C99 "sizeof typed initializer" syntax.Linus Torvalds1-1/+12
Also fix the type return of initializer evaluation, so that we get the right size in the right place. Add the necessary lines to parse the thing too.
2005-04-07[PATCH] FP handlingAlexander Viro1-15/+25
FP handling added, everything straightforward by now.
2005-04-07C99 says strings should be up to 4095 bytes.Linus Torvalds1-5/+6
Also, while we're here, be more careful about the exact limits, and concatenation: we want to have the ending NUL character even when we concatenate too much.
2005-04-07Don't allow string concatenation to overflow MAX_STRING.Linus Torvalds1-0/+9
2005-04-07[PATCH] teach sparse about __alignof__Stephen Hemminger1-11/+22
This teaches sparse what __alignof__ really means, instead of just using the same code as "__sizeof__" It gets rid of the warnings in ebtables that does: struct ebt_entries { ... char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))); }; Which caused warning because sparse was evaluating __alignof__ as the same as sizeof, and sizeof was 57 (ie non-power of 2). This is just based on the existing code and a peek at the data structures in expression and symbol.
2005-04-07[PATCH] Update get_number_value()Alexander Viro1-80/+94
This updates the type semantics of "get_number_value()" to C99 semantics rather than the previous gcc/C90 type expansion semantics. Now regular decimal integers (without suffixes) that are too big to fit in "long" expand to "long long" rather than "unsigned long". It also uses "strtoull()" rather than open-coding the conversion.
2005-04-07If int/long are the same size, an int that overflows intoLinus Torvalds1-3/+2
unsigned stays as an (unsigned) int. Otherwise it becomes a long.
2005-04-07Macroize lr_binop_expression() helper function.Linus Torvalds1-49/+85
This function was the top performance offender in sparse. We really want it inlined, since all it really does is to do an indirect call or two, and if inlined that call turns into a direct call. Making it a macro allows us to pass in the operation comparison as code rather than as a list of integers, which again allows the compiler to do a much better job.
2005-04-07Make sure we don't silently accept an empty expressionLinus Torvalds1-2/+12
following unary expressions.
2005-04-07Allow underscores in integer constants for readability.Linus Torvalds1-2/+8
Thus 0x1234_5678 is a valid constant, as is 100_000_ul. The parser doesn't care where they are.
2005-04-07Remove TOKEN_FP vs TOKEN_INTEGER distinction, and make numbers beLinus Torvalds1-24/+30
just TOKEN_NUMBER. This matches how tokenization is supposed to be done, and simplifies the code. Expression evaluation changed to cope with the new rules.
2005-04-07Don't get confused about "void *" nodes.Linus Torvalds1-1/+1
We'd incorrectly test the right type of a compatible pointer expression for "void *" without dropping off the node information. This allows us to fix a casting bug, where we used to drop the node information at the cast.
2005-04-07"a->b" is just shorthand for "(*a).b".Linus Torvalds1-2/+9
So let's make that explicit in the parse tree, and avoid carrying the special cases around further. This makes the evaluation phase only have one case to worry about.
2005-04-07Make "value is so big" warning print the constant.Linus Torvalds1-3/+5
This makes it a lot easier to see what's up.
2005-04-07Now that BITS_IN_XXXX aren't defined contstants any more,Linus Torvalds1-6/+6
rename them lower cased to match standard C naming rules.
2005-04-07Clean up type expression syntax.Linus Torvalds1-2/+9
We now require square brackets around the type, to avoid any confusion with casts or variable declarations: if ([typeof(x)] == [int]) ...
2005-04-07Support C types as first-class citizens, allowing typeLinus Torvalds1-8/+8
comparisons etc: if (typeof(a) == int) { ... (although right now I don't actually do the proper comparison expansion and all comparisons return "true").
2005-04-07Warn about users trying to use type names in expressions.Linus Torvalds1-1/+15
I think I'll allow type expressions at some point, since it shouldn't actually be all that hard, and would even clean some stuff up. But for now, we'll just warn about non-C code.
2005-04-07[PATCH] Make sparse understand complex initializers inside expressionsDave Olien1-6/+17
This patch makes a cast expression followed by an initializer list into a postfix expression that can be dereferenced as a structure or an array. There are approximately 7 instances of these expressions in the Linux kernel, that give warnings about "expected lvalue for member dereference". The approach involved introducing a new "stack-based temporary" symbol of the same type as the cast expression, and using this as the target of the initialization expression. The subsequent array or structure member dereferences are made to that temporary symbol. show-parse.c need modification to display a symbol expression with an initializer list that is NOT in a symbol declaration list. An example of this form with structure member dereference is: typedef struct { long t1; long t2; long t3; } longstruct_t; long test; int main(void) { int a, b, c; test = (longstruct_t){a, b, c}.t3; return 0; } An example of this form with array member dereference is: typedef int iarray[2]; int pgp; main(void) { int index; int a, b; pgp = (iarray){a,b}[index]; }
2005-04-07Update copyright notices to reflect the fact that TransmetaLinus Torvalds1-0/+1
isn't the sole copyright owner these days.
2005-04-07Make the tokenizer recognize FP tokens, even if we don'tLinus Torvalds1-1/+5
actually handle them correctly later on yet.
2005-04-07Parse and evaluate gcc computed goto extensions: label addressingLinus Torvalds1-0/+10
(&&label) and computed goto (goto *expr). Add label ctype for __label__ identifier. This is still quite broken (it should create a block-symbol in the NS_LABEL namespace, right now it creates a regular symbol).
2005-04-07Don't warn about signedness for hax/octal constants. They are commonlyLinus Torvalds1-4/+7
used for bitfields where we really don't care.
2005-04-07Start updating the copyright license comments to the OSL,Linus Torvalds1-1/+3
preparing for a public release.
2005-04-07Peter points out that the type masking shifts can overflowLinus Torvalds1-2/+2
if sizeof(long long) == sizeof(long) (and furter if it's also the same size as 'int', all perfectly legal C). Fix it by his suggestion.
2005-04-07Evaluate logical expressions, and short-circuit it.Linus Torvalds1-2/+2
Make the pre-processor use the expression evaluator, so that it actually gets all the signed/unsigned comparisons right etc. Make logical expressions an expression type of their own. They have some very special behaviour both type-wise and evaluation-wise (the short-circuiting thing).
2005-04-07Change the copyright to Transmeta Corp, that's likely to beLinus Torvalds1-1/+1
the real one when it goes out the door.
2005-04-07Oops. Initializer casts didn't actually save the result.Linus Torvalds1-1/+1
2005-04-07Remove last user of "struct token" from "struct expression".Linus Torvalds1-4/+95
Now constant expressions (strings, integers and fp constants) are evaluated at parse-time into the proper EXPR_xxx type. Remove "struct token" from "struct statement", which really only wanted to know the position. So replace it with "struct position".
2005-04-07Evaluate assignments:Linus Torvalds1-3/+4
- expand combinations ('a += b' => 'a = a + b') - check resulting types Rename 'MINUS' and 'TIMES' as 'SUB' and 'MUL' in assignments.
2005-04-07Parse initializers properly. We parsed them before, but we didn'tLinus Torvalds1-1/+1
add them to the parse tree. We now do.
2005-04-07Start doing constant strings right: do proper concatenation of strings,Linus Torvalds1-6/+35
and evaluate their type to be arrays of char rather than just a pointer.
2005-04-07A structure member is just an identifier, not a random token.Linus Torvalds1-1/+1
2005-04-07Introduce a "struct position", and have the different types referLinus Torvalds1-26/+29
to it, instead of having everybody have pointers to "struct token" only because they wanted to have the position. Fix array addition type degeneration.
2005-04-07Give comma expressions and comparison expressions different types,Linus Torvalds1-13/+13
even though they parse like other binops: they have different semantic type behaviour, and should be evaluated separately. Show bitfield symbol types.
2005-04-07Make a function call point an expression type of its own, andLinus Torvalds1-3/+18
make the arguments use a proper argument list instead of being a comma-expression (which has totally different type semantics). Evaluate assignments and function calls (and their arguments). Show function calls in the debug info.
2005-04-07Fix typename parsing (incorrect ctype usage), and correctLinus Torvalds1-1/+3
handling of 'long' and 'long long' types. Fix cast parsing and evaluate casts.
2005-04-07Start doing type evaluation for binops - integer promotion rulesLinus Torvalds1-6/+11
etc. Add a function call expression type. Make expression type evaluation return a success/failure value.
2005-04-07Split up the expression parsing in "parse.c" into a file ofLinus Torvalds1-0/+347
its own - expression.c.