Commit Graph

101 Commits

Author SHA1 Message Date
acqn 924fcf5d06 Replaced several occurance of PtrConversion() with StdConversion().
Variadic arguments of functions should be default-promoted.
2021-06-08 09:32:58 +08:00
acqn fdded33097 Made it easier to support 0-size structs in the future. 2020-08-15 06:27:11 +08:00
acqn 4f4487cb03 Added supports for long bit-fields. 2022-01-04 18:23:04 +08:00
acqn 2d96f79bc7 Added and used new utility type functions for bit-fields.
Fixed GetUnderlyingTypeCode() for bit-fields with widths > 16.
2021-12-01 09:45:17 +08:00
mrdudz 3c1bb85b8e remove dangling spaces 2022-04-17 16:07:09 +02:00
acqn 5adb29ce31 Made "bit-field-ness" a type property instead of a SymbolEntry or ExprDesc property.
Fixed integer promotion and result type in certain operations.
Fixed bit-fields 'op=' and postfix inc/dec operators.
2021-06-09 08:03:12 +02:00
acqn dcacba472a Moved ArithmeticConvert() from cc65/expr.c to cc65/datatype.c.
Reorganized a few functions in cc65/datatype.c.
Added SignedType() and UnsignedType() for future usage.
Made LimitExprValue() external so that it can be used more often.
2021-06-09 08:03:12 +02:00
Greg King e5813cfb1a Removed two duplicate TYPEDEFs from a header.
The first one is replaced by an #include of the header that has its original TYPEDEF.
The second one is replaced by its base type.

That change allows pedantic C90-compliant compilers to accept the header.
2021-05-13 00:24:32 -04:00
acqn f901adba22 Predefined type strings for inlined std function parameters. 2021-04-19 15:36:55 +02:00
acqn 9cea9ce5e2 Made the code more constness-correct with 'Type' usage. 2021-04-19 15:36:55 +02:00
acqn 328345b9c3 Removed a helper function that is no longer used. 2021-04-19 15:36:55 +02:00
acqn 896f463a23 Used more specific pointers instead of the "arbitary attribute pointer" used in type strings. 2021-04-19 15:36:55 +02:00
acqn 3755e4a863 Replaced checking for __fastcall__ aginst AutoCDecl etc. with IsFastcallFunc(). 2021-03-24 14:35:44 +08:00
acqn 047d0f479b Comments format fix. 2021-03-03 10:07:24 +01:00
acqn bfc7a51a44 Fixed Issue #1265 according to C89/C99 standards. 2021-01-30 14:31:51 +01:00
Oliver Schmidt 116682c190 Avoid C99 idioms. 2020-11-16 18:08:00 +01:00
Oliver Schmidt bee559d5f4
Merge pull request #1220 from acqn/StaticConst
[cc65] Fixed constant boolean expressions
2020-08-31 08:59:25 +02:00
acqn f1161daee9 Recursively checking for incomplete/unknown-sized types. 2020-08-30 17:33:36 +02:00
acqn 8541f18340 Improved diagnostic info on assignment to void types. 2020-08-30 17:33:36 +02:00
acqn 504aee3835
Merge branch 'master' into StaticConst 2020-08-27 06:27:23 +08:00
acqn 43cb092a68 Fixed CHECK failures on certain usage of incomplete enums. 2020-08-26 22:14:51 +02:00
acqn 17bbba7327 Added integer boolean type string.
No longer set the "expression tested" flag with constant results in comparison.
2020-08-20 07:52:03 +08:00
acqn 9fcde120aa Made function signatures in asm output use the parameter lists from original definitions instead of the composites. 2020-08-19 08:40:19 +02:00
acqn 56b659c0be Made char type a distinct type. 2020-08-18 10:48:38 +02:00
acqn f206833a20 Alternative fix for Issue #1167. 2020-08-17 20:31:02 +02:00
acqn 0afa1a9a95 Fixed function signatures in asm output.
Improved full type name production.
2020-08-17 20:30:32 +02:00
acqn 15f28c3a8c Fixed getting the basic raw type names. 2020-08-17 00:00:03 +02:00
acqn 11cd3e5cbd Utility for checking general datatype categories, incomplete ESU types and arrays of unknown sizes. 2020-08-17 00:00:03 +02:00
Jesse Rosenstock c4698dfd07 Use C89 semantics for integer conversions
Previously, the following rules were used for binary operators:
* If one of the values is a long, the result is long.
* If one of the values is unsigned, the result is also unsigned.
* Otherwise the result is an int.

C89 specifies the "usual arithmetic conversions" as:
* The integral promotions are performed on both operands.
* Then the following rules are applied:
  * If either operand has type unsigned long int, the other operand is
    converted to unsigned long int.
  * Otherwise, if one operand has type long int and the other has type
    unsigned int, if a long int can represent all values of an unsigned int,
    the operand of type unsigned int is converted to long int; if a long int
    cannot represent all the values of an unsigned int, both operands are
    converted to unsigned long int.
  * Otherwise, if either operand has type long int, the other operand is
    converted to long int.
  * Otherwise, if either operand has type unsigned int, the other operand is
    converted to unsigned int.
  * Otherwise, both operands have type int.
https://port70.net/~nsz/c/c89/c89-draft.html#3.2.1.5

As one example, these rules give a different result for an operator
with one long operand and one unsigned int operand.  Previously,
the result type was unsigned long.  With C89 semantics, it is just long,
since long can represent all unsigned ints.

Integral promotions convert types shorter than int to int (or unsigned int).
Both char and unsigned char are promoted to int since int can represent
all unsigned chars.
https://port70.net/~nsz/c/c89/c89-draft.html#3.2.1.1

Rename promoteint to ArithmeticConvert, since this is more accurate.

Fixes #170
2020-08-15 19:14:31 +02:00
acqn 13ed557b92 Fixed compatibility checking of function declarations by using the composite types of them. 2020-08-14 18:33:54 +02:00
acqn fe3f726fd6 Improved incomplete enum typed diagnostics. 2020-08-12 15:01:31 +02:00
acqn 9fcfa3fc49 Fixed full type names of functions with "empty" parameter list. 2020-08-12 15:01:31 +02:00
acqn bae431eab0 Fixed error message of CheckedPSizeOf(). 2020-08-03 06:18:28 +02:00
acqn d6aa446b54 Error info for loading expressions of incomplete enum types.
No more "Illegal type 0016".
2020-08-02 23:51:11 +02:00
acqn 6df4f1996b Improved diagnostics with more detailed type names. 2020-08-02 23:51:11 +02:00
acqn 80b0e57543 Changed parameter constness of TypeConversion(). 2020-08-02 18:55:46 +02:00
acqn d841bbe498 Utility to check for castability. 2020-08-02 18:55:46 +02:00
acqn 52051f444e Using tracked individual string buffers instead of a shared static string buffer for full type names. 2020-08-02 18:55:46 +02:00
acqn 4ccf10f3fa Utility to get full type names. 2020-08-02 18:55:46 +02:00
acqn 0df45fe2f2 Utility for getting ESU tag type symbols. 2020-08-02 18:55:46 +02:00
acqn 2a555d198c Changed 'switch' to 'if' according PR review comments. 2020-08-02 12:28:11 +02:00
acqn 30fd8592ae Avoid internal errors when using function-type objects in expressions. 2020-08-02 12:28:11 +02:00
acqn c37f9f1a41 Check if the integer size is known in GetIntegerTypeMin/Max() to prevent potential misuse. 2020-07-28 23:26:25 +02:00
acqn 0f412b6beb Small fixes according to PR review. 2020-07-28 23:26:25 +02:00
acqn daa65199b3 Fixed underlying types of enums.
Made enumerator diagnostics more sensible.
Fixed Issue #1048 as a natural result.
2020-07-28 23:26:25 +02:00
acqn 768e03a474 Small fixes and tidy-up based on PR review.
Renamed GetReplacementType() to GetStructReplacementType().
Clarified in comments that most *Struct* facilities work for unions as well.
Made it clear in some error messages with regards to structs/unions.
2020-07-19 10:58:33 +02:00
acqn 66ecc0e52c New utility to get the proper replacement type for passing structs/unions by value.
New utility to get basic type names such as 'struct', 'union' and so on.
2020-07-19 10:58:33 +02:00
Greg King 750a527100 Made C's sizeof operator work with initialized void variables.
Added regression tests that check cc65's handling of void variables.
2017-03-12 14:41:32 -04:00
mrdudz 6ab197f364 patch from Uz that makes some illegal operations on pointers error out 2015-07-10 14:27:49 +02:00
Greg King 2842b68a04 Reverted one of the changes in how function prototypes look, in cc65's assembly output. 2015-03-19 06:27:25 -04:00