aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
AgeCommit message (Collapse)AuthorFilesLines
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.