Oliver Schmidt
bee559d5f4
Merge pull request #1220 from acqn/StaticConst
...
[cc65] Fixed constant boolean expressions
2020-08-31 08:59:25 +02:00
acqn
74def4608a
The 'E_NEED_TEST' flag shouldn't be overwritten when loading the expression result.
2020-08-31 02:30:12 +08:00
acqn
c0a873e0c8
Reduced exess errors on wrong initializations with curly braces.
2020-08-30 17:35:48 +02:00
acqn
8b580e1191
Disabled struct/union fields of 'void' type.
2020-08-30 17:33:36 +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
abcc2a8f1a
Disallowed void arrays of elements of variant sizes.
2020-08-30 17:33:36 +02:00
acqn
d87846e1e1
Improved comments according to PR reviews.
2020-08-30 22:12:30 +08:00
acqn
60c59f59a3
Renamed StaticConstExpr() and StaticConstAbsIntExpr() with clearer comments.
2020-08-30 00:26:52 +08:00
acqn
df755df44d
Warning about ESU types declared inside parameter list as they are invisble outside.
2020-08-29 16:37:16 +02:00
acqn
33a75e0a73
Optimized parameter list checking.
...
Fixed function type comparison between ANSI and K&R styles.
2020-08-29 16:37:16 +02:00
acqn
0a96ffc878
Fixed function parameter checking.
...
Fixed function return type checking.
2020-08-29 16:37:16 +02:00
acqn
4e61ae5b36
Fixed function parameter type conversion.
2020-08-29 16:37:16 +02:00
acqn
632da3f4ee
Fixed tracking and checking flexible array members.
2020-08-29 16:35:42 +02:00
acqn
504aee3835
Merge branch 'master' into StaticConst
2020-08-27 06:27:23 +08:00
acqn
bb9c203222
Fixed integer promotion of unary operations.
2020-08-26 22:17:16 +02:00
acqn
8d225c32b1
Fixed checks on assignment to incomplete types.
2020-08-26 22:14:51 +02:00
acqn
43cb092a68
Fixed CHECK failures on certain usage of incomplete enums.
2020-08-26 22:14:51 +02:00
acqn
1957dc7a5c
Disallowed arrays of incomplete types.
...
Fixed diagnostics on incomplete local arrays.
2020-08-26 22:14:51 +02:00
acqn
f5b1b69376
Forbid struct/union fields of incomplete types.
2020-08-26 22:14:51 +02:00
Jesse Rosenstock
d38e5858f0
Add tests for #1211
...
CL_MoveRefs: Add CHECK (E->JumpTo != NULL) to make failure clearer.
2020-08-24 18:10:22 +02:00
acqn
c3a6b39945
Made struct assignment less hackish.
2020-08-24 18:02:29 +02:00
acqn
d1995fc81a
Fixed rvalue-ness of cast results.
2020-08-24 17:16:37 +02:00
acqn
911a79796d
Fixed checks and diagnostics on type-casting.
2020-08-24 17:16:37 +02:00
acqn
0486d28abc
Fixed Issue #327 .
2020-08-22 13:44:18 +02:00
acqn
f289ea6c14
Avoided generating unnecessary true-case labels in logic AND/OR.
2020-08-22 11:10:17 +08:00
acqn
0536f4f9bd
Minor fixes on constant expression checking and comments.
2020-08-21 23:27:41 +02:00
acqn
63256fd15d
Changed negation of signed long stored in unsigned long to unsigned subtraction.
2020-08-21 23:16:17 +02:00
acqn
f59c2a08d9
Added support for changing multiplications with certain negative multipliers into bit-shifts. Only enable certain kinds of signed mul replacements with shift according to the code size factor settings.
2020-08-21 23:16:17 +02:00
acqn
ea7336591c
Removed special-casing code for scaling up. Now it uses the normal multiplying code.
2020-08-21 23:16:17 +02:00
acqn
85ea06687b
Fixed logical AND and logical OR.
2020-08-20 07:52:15 +08:00
acqn
725511131a
Fixed constant expression checks with no-code requirement.
...
Used return-by-value initialization for ExprDesc.
2020-08-20 07:52:11 +08:00
acqn
3ea3887c77
Fixed warnings on const comparison.
...
Warnings on expressions with no effects.
Fixed const ternary.
Fixed ternary with struct/union types as the true/false-branch expressions.
2020-08-20 07:52:06 +08: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
Greg King
36dd82f0e6
Added g_branch() to cc65's code generator.
...
It uses BRA if the platform's CPU has BRA. Else, it generates a JMP.
(Used it in the bitfield sign-extending code.)
2020-08-18 19:11:18 -04:00
Jesse Rosenstock
ff535b8e1a
Treat signed int bit-fields as signed
...
Prior to this PR, `int`, `signed int`, and `unsigned int`
bitfields are all treated as `unsigned int`.
With this PR, `signed int` will be treated as `signed int`,
and the others remain unsigned.
Since `Type` does not distinguish between `int` and `signed int`,
add an extra `int* SignenessSpecified` param to `ParseTypeSpec`
so we can tell these apart for bit-fields and treat plain `int : N`
as `unsigned int : N` since it is more efficient to zero-extend
than sign-extend.
Fixes #1095
2020-08-18 12:23:20 +02:00
Jesse Rosenstock
55cebc7b9e
Move bit-field adjustment to codegen.c
...
Extract functions g_testbitfield and g_extractbitfield from LoadExpr.
This helps prepare for #1192 , since g_extractbitfield will get much
longer and call AddCodeLine.
2020-08-18 10:55:31 +02:00
acqn
56b659c0be
Made char type a distinct type.
2020-08-18 10:48:38 +02:00
acqn
87889df9e9
Fixed type checking in relation operations.
2020-08-18 09:39:43 +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
ebae994dc9
Fixed CHECK failure when calling functions defined with repeated parameter names.
...
Clarified the terms "parameter" vs "argument" in FunctionParamList().
2020-08-17 20:27:57 +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
1cf9404c19
Support C2X _Static_assert(expr) syntax
...
This makes the message in _Static_assert(expr, message) optional.
Fixes #1188 .
2020-08-16 11:38:20 +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
b19bb14348
Fixed checking conflitcing declarations with external vs other linkage.
2020-08-14 18:33:54 +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
44d52935da
Utility for getting the composite types of functions.
2020-08-14 18:33:54 +02:00
acqn
8a417ff039
Improved ESU declaration failure handling.
2020-08-14 18:15:31 +02:00
acqn
0dfe9ff5fe
Fixed testing 'struct->field'.
2020-08-14 08:32:22 +08:00
acqn
0fa18886c0
Fixed copying structs/unions > 4 bytes.
2020-08-13 08:59:05 +02:00
acqn
03b37cf712
Fixed type comparisons of typedefs and arrays.
2020-08-12 15:04:26 +02:00
acqn
eb4464e828
Fixed type comparisons of ESU types with stricter rules.
2020-08-12 15:04:26 +02:00
acqn
fe44fe963f
Disallowed empty enums.
2020-08-12 15:02:43 +02:00
acqn
97065faf1a
Disallowed struct/union types of 0 size as cc65 is not ready to support them.
2020-08-12 15:02:43 +02:00
acqn
4dfc1a5ded
Using a dedicated SC_FICTITIOUS flag in case of parsing errors.
2020-08-12 15:01:31 +02:00
acqn
bde5be6793
Improved error message on initializing extern variables inside functions.
2020-08-12 15:01:31 +02:00
acqn
b62b1650f5
Improved error messages on struct/union type multiple definitions.
2020-08-12 15:01:31 +02:00
acqn
fe3f726fd6
Improved incomplete enum typed diagnostics.
2020-08-12 15:01:31 +02:00
acqn
0d53806490
Avoided excess errors in incomplete struct assignment.
2020-08-12 15:01:31 +02:00
acqn
9317db6642
Slightly improved type error messages of 'op='.
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
68d63b089d
Reduced error flood raised by misplaced variable declarations.
2020-08-12 15:01:31 +02:00
acqn
0f1a5e0520
Set enum tag definition flags.
2020-08-09 22:12:36 +02:00
acqn
1dd899c7c9
Fixed non-file-scope multiple definition checking.
2020-08-09 22:12:36 +02:00
acqn
d68cd90e47
Function declaration in functions cannot have storage classes other than 'extern'.
2020-08-07 10:16:33 +02:00
acqn
43efc256f1
Changed error/warning messages not using the term 'tentative' according to PR reviews.
2020-08-07 10:16:33 +02:00
acqn
b2d3b8379c
Warning about forward declaration of enum types in non-cc65 modes.
2020-08-07 10:16:33 +02:00
acqn
8cdffc1944
No storage for unsuccessfully parsed variables.
2020-08-07 10:16:33 +02:00
acqn
fdef067629
Fixed tentative definition of variables of incomplete types that may be completed later.
...
Tenative arrays that never get completed are now assumed each to have one element.
2020-08-07 10:16:33 +02:00
acqn
fdd120db49
Enabled to output errors and warnings about tentative definitions.
2020-08-07 10:16:33 +02:00
acqn
f59d6b8f6a
Redefining enums/structs/unions of 0 size is no longer treated as declarations and thus forbidden.
2020-08-07 10:16:33 +02:00
Jesse Rosenstock
cdfc1afd89
Fix vacuous comparison warning from 0df45fe
...
cc65/symentry.c:306:60: warning: address of array 'Sym->Name' will always evaluate to 'true' [-Wpointer-bool-conversion]
sprintf (TypeName, "%s %s", GetBasicTypeName (T), Sym->Name ? Sym->Name : "<unknown>");
~~~~~^~~~ ~
2020-08-05 17:48:13 +02:00
Jesse Rosenstock
d8f9201ecd
LoadExpr: Optimize <= 8-bit bit-field loads
...
Set CF_FORCECHAR to do as many operations as char ops as possible.
Clear high byte at the end.
2020-08-05 12:49:46 +02:00
Jesse Rosenstock
0c72647edd
Remove extra ED_TestDone call
...
Accidentally added in #1141 .
2020-08-03 12:40:58 +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
11a5f0edf1
No "Statement has no effect" warnings on statements with errors.
2020-08-02 23:51:11 +02:00
acqn
7e68a24625
Clearer warning messages on unused symbols.
2020-08-02 23:51:11 +02:00
acqn
e8c2886455
Improved error messages on redefinitions of constants and bit-fields.
2020-08-02 23:51:11 +02:00
acqn
ef5a4db12e
Improved warning messages on UB shifts.
2020-08-02 23:51:11 +02:00
acqn
2ab7272673
Improved warning on comparison of unsigned type < 0.
2020-08-02 23:51:11 +02:00
acqn
99ac1c46da
Made errors/warnings statistic message visible when there are errors.
2020-08-02 23:51:11 +02:00
acqn
44e3080ea9
Increased upper limit of allowed errors before aborting.
2020-08-02 23:51:11 +02:00
acqn
00c16d34a4
Minor fixes for HandleSymRedefinition().
2020-08-02 23:51:11 +02:00
acqn
80b0e57543
Changed parameter constness of TypeConversion().
2020-08-02 18:55:46 +02:00
acqn
003d47cc8b
Improved type conversion diagnostic messages.
...
Allowed incompatible pointer assignments with warnings.
Fixed Issue #1089 .
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
Oliver Schmidt
c831f40e9b
Unfortunately there's no other way than using the absolute path to init the correct MSVC 2017 environment.
2020-08-02 18:44:13 +02:00
Oliver Schmidt
992596c981
Initialize MSVC 2017 environment before build.
2020-08-02 17:32:36 +02:00
Jesse Rosenstock
adda28f5c5
LoadExpr: Set CF_FORCECHAR if test is required
...
If we are testing, we do not need to load the high byte(s).
2020-08-02 12:31:57 +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
e526cbbff6
Fixed handling multiple storage specifiers in one declaration.
2020-08-02 02:20:25 +02:00
Oliver Schmidt
e1043fac12
Adjusted to https://github.com/cc65/cc65/pull/1124 .
2020-08-01 10:56:05 +02:00
Jesse Rosenstock
9c70bd44a6
Clarify comment about large shift
...
This is to avoid overflow on host platform.
2020-07-31 19:33:28 +02:00
Jesse Rosenstock
847982c6bf
Handle bit-field test after shift/mask
...
Previously, bit-field tests were incorrectly combined with load in
`if (x.bitfield)`. Delay the test until after the shift/mask
is done. Still combine tests with load if no shift/mask is required.
Fixes #1139
2020-07-31 19:33:28 +02:00
Jesse Rosenstock
d0c7108dcf
Change copyright notice to "The cc65 Authors"
2020-07-30 19:17:11 +02:00
Jesse Rosenstock
3df6c383c0
Add support for static_assert
...
Add C11's _Static_assert and static_assert macro.
This is like #error, but is handled at a later stage
of translation, so it is possible to check sizes of
types, values of enums, etc.
https://en.cppreference.com/w/c/language/_Static_assert
https://port70.net/~nsz/c/c11/n1570.html#6.7.10
2020-07-30 19:17:11 +02:00
Jesse Rosenstock
2d5fd0fc63
Use char ops if possible for bit-field loads
...
Set CF_FORCECHAR and change type to char once we have
shifted into a char.
This saves some unnecessary ldx #0 instructions.
2020-07-30 14:59:23 +02:00
acqn
e38f601fcc
Fixed padding at the ends of structs with bit-fields.
2020-07-30 08:38:24 +02:00
acqn
8a511bb63d
Fixed nested array initializers.
2020-07-30 08:38:24 +02:00
acqn
9075a853dc
Allows one trailing comma before the closing curly of a struct/union initializer.
2020-07-30 08:38:24 +02:00
acqn
25d10d9d9a
Fixed nested struct/union initialization.
...
Fixed bit-fields offsets in anonymous structs.
2020-07-30 08:38:24 +02:00
acqn
d6d667a688
Improved error handling with symbol redefinitions.
2020-07-30 08:22:29 +02:00
acqn
92de4fa0d0
Enabled to recognize labels when parsing local variable declarations.
2020-07-30 08:22:29 +02:00
acqn
19c81ed866
Fixed type mask usage.
2020-07-30 08:13:23 +02:00
Jesse Rosenstock
fb9b50ff9c
Move type checks before bit-field width parsing
2020-07-30 08:10:38 +02:00
Jesse Rosenstock
a2561d07f3
Remove special-case bit-field width code
...
cbb33f8
restricted allowed bit-field types to int,
so this is equivalent for now, but forward-compatible.
Fixes FIXME
Also move the int type check before parsing the colon.
2020-07-30 08:10:38 +02:00
Oliver Schmidt
8eab28012a
Adjusted project name.
2020-07-28 23:29:16 +02:00
acqn
cbb33f86e8
Disabled using non-int-size types to declare bit-fields.
2020-07-28 23:26:25 +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
7e243e0f2c
Allowed using all integer types including enum and char types to define bit-fields,
...
but kept the currently behavior that all of them are treated as unsigned int.
2020-07-28 23:26:25 +02:00
acqn
d8184fbe54
No longer insert all enums in the global symbol table.
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
Greg King
44c82eb1c3
Made da65 disassemble branch instructions with relative address expression operands if there's no label.
2020-07-21 18:43:32 -04:00
acqn
07e18774f7
Added spaces around '|' with regex replacement.
2020-07-21 18:23:52 +02:00
acqn
c66d0881b9
Made the enum/enumerator types clearer and improved DumpSymEntry() output.
2020-07-21 18:23:52 +02:00
acqn
18bd76bb90
Minor fixes and improvements.
2020-07-21 18:23:52 +02:00
acqn
65081aebed
Made able to recognize global declarations of static arrays. Fixed Issue #975 .
2020-07-21 18:23:52 +02:00
acqn
0250c87ac6
Fixed SC_* type masks by making them all bitwise-exclusive.
2020-07-21 18:23:52 +02:00
acqn
78342fa82c
Fix for "auto" variables made "static" with the "-Cl" options.
2020-07-20 15:01:47 +02:00
acqn
71c2d27705
Removed an ED_IsBitField() test according to PR review.
2020-07-20 14:54:32 +02:00
acqn
2245783345
Fixed ability to do actual type conversion from bit-fields to integers. Note this doesn't try to fix the signedness issues.
2020-07-20 14:54:32 +02:00
acqn
b67b8ddd38
Disabled applying 'sizeof' to bit-fields.
2020-07-20 14:54:32 +02:00
acqn
62a6e37487
Made the code handling '&expression' slightly tidier.
2020-07-20 14:54:32 +02:00
acqn
3c52ad1d9e
New utility ED_DisBitField() to make an expression no longer a bit-field.
2020-07-20 14:54:32 +02:00
Greg King
fd0a6955da
Changed "IsTypeStruct() || IsTypeUnion()" expressions into shorter "IsClassStruct()" expressions.
...
Type-classes are groups of types that can be handled in the same way (similar syntax).
2020-07-19 14:30:22 -04:00
acqn
29c50ab25f
Corrected the error message about struct/union members not found.
2020-07-19 12:57:59 +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
0c3e1b491f
Disabled -Wstruct-param by default.
2020-07-19 10:58:33 +02:00
acqn
b45d373fd6
Fixed passing by value structs/unions <= 4 bytes in size to functions. Larger ones are forbidden for now.
2020-07-19 10:58:33 +02:00
acqn
9f67b45ea0
Fixed returning by value structs/unions <= 4 bytes in size from functions. Larger ones are forbidden for now.
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
acqn
333fa97326
Whitespaces/newlines fixes.
2020-07-18 12:54:29 +02:00
acqn
9198b3be00
Fixed '&function' and '&array'.
2020-07-18 12:54:29 +02:00
acqn
d23b577331
More compiler flags on address types to match the location types of expressions.
2020-07-18 12:54:29 +02:00
acqn
2108489523
Fix for Issue #1075 and #1077 .
2020-07-18 12:54:29 +02:00
acqn
727040d1ac
Comment fix.
2020-07-12 12:35:42 +02:00
acqn
7d652d42dc
Added a warning on promoting a decimal constant without a 'u'/'U' suffix to unsigned long.
2020-07-12 12:35:42 +02:00
Jesse Rosenstock
f5afc75cbd
ar65/LibClose: Include filename in error messages
...
```
ar65: Error: Problem deleting temporary library file '../lib/apple2enh.lib.temp': No such file or directory
```
is the error I'm getting with `make -j 19` when trying
to debug #1080 .
2020-07-09 21:56:02 +02:00
acqn
85e73e91f8
Only enable signed div replacements with shift according to the code size factor settings.
...
Also with better comments.
2020-07-09 10:00:50 +02:00
acqn
09bcff0862
Added support for changing divisions by negative power-of-2 denominators into bit shifts,
...
and fixed #169 including the case of -2147483648 which is negative but appears positive.
2020-07-09 10:00:50 +02:00
acqn
30835e3d9d
More optimized codegen for the correct cases of the Issue #169 fix.
2020-07-09 10:00:50 +02:00
acqn
e98fe04cc2
Almost fixed Issue #169 . The only denominator not working right now is -2147483648.
2020-07-09 10:00:50 +02:00
Jesse Rosenstock
82c8bd6e2b
Replace unary negation with subtraction
...
Remove MSVC pragma.
2020-07-09 09:49:24 +02:00
Jesse Rosenstock
2c16453a9f
Guard MSVC pragma with ifdef _MSC_VER
...
Fix broken travis-ci with gcc -Werror [-Werror=unknown-pragmas].
2020-07-09 09:49:24 +02:00
Jesse Rosenstock
9e5b8d99a3
Fix MSVC build broken by #1058
...
MSVC complains about unary negation of unsigned, but it's
intended. Suppress the warning.
https://github.com/cc65/cc65/pull/1058#discussion_r451757967
"Tested" with godbolt.org.
2020-07-09 09:49:24 +02:00
Jesse Rosenstock
6dc2bf1226
Rename PaddingBitWidth to PaddingBits
2020-07-08 16:46:34 +02:00
Jesse Rosenstock
9858e47dfd
Pad bit-fields only to the next byte
...
Fixes #1054 .
Previously, bit-fields followed by another field were aligned
to two bytes. Bit-fields ending the struct were (and continue
to be) aligned only to a single byte.
```
struct s {
unsigned int x : 4;
};
struct t {
unsigned int x : 4;
unsigned int y;
};
```
Before: `sizeof(struct s) == 1`, sizeof(struct t) == 4`
After: `sizeof(struct s) == 1` sizeof(struct t) == 3`
2020-07-08 16:46:34 +02:00
Jesse Rosenstock
9e881a497e
Fix formatting
2020-07-08 16:45:00 +02:00
Jesse Rosenstock
c273c90bf2
Fix formatting
2020-07-08 16:45:00 +02:00
Jesse Rosenstock
527df094ca
Use xrealloc in cl65
...
Previously, xmalloc and xfree were used.
2020-07-08 16:45:00 +02:00
Jesse Rosenstock
416adbce82
Add blank line
2020-07-08 16:44:06 +02:00
Jesse Rosenstock
021362fb75
cl65: Remove temporary .o files
2020-07-08 16:44:06 +02:00
acqn
539924249b
More complete fix for Issue #1071 .
2020-07-07 18:28:56 +02:00
acqn
286da30a26
Quick fix for Issue #1071 .
2020-07-07 18:28:56 +02:00
Daniel Serpell
17c5504129
In Atari XEX output format, join memory areas if possible.
...
This makes executables shorter if two memory areas are consecutive.
2020-07-04 23:28:10 +02:00
Jesse Rosenstock
d31171164e
Fix formatting
2020-06-29 14:49:36 -04:00
Jesse Rosenstock
fae25bc459
CHECK we have at most a partial byte
2020-06-29 14:49:36 -04:00
Jesse Rosenstock
f4a6d08847
Fix full bytes vs full word in comment
2020-06-29 14:49:36 -04:00
Jesse Rosenstock
a00611798d
Output bit-field data as chars instead of ints
...
This prepares for #1058 , which will pad bit-fields only to
the next byte, instead of the next sizeof(int) (two bytes).
OutputBitFieldData now outputs chars instead of ints, and
calls to this function loop until there is less than one byte
to output. A final partial byte is written out with zero padding
as a final partial int was previously.
2020-06-29 14:49:36 -04:00
Jesse Rosenstock
90d1c89bff
Allow overlap of bit-field storage units ( #1055 )
...
* Allow overlap of bit-field storage units
Previously,
struct s {
unsigned int x : 10;
unsigned int y : 10;
};
had sizeof(struct s) == 4.
With this change, allow the storage units of x and y to overlap,
so sizeof(struct s) == 3, with y stored immediately after x,
with no padding between them.
An int bit-field (the only type currently supported) will still
never occupy more than two bytes.
* ParseStructInit: Fix typo and expand comment
Explain why there are at most 30, not 32 bits.
* ParseStructDecl: Rewrite AddBitFieldCall
No behavior change.
Co-authored-by: Jesse Rosenstock <jmr@users.noreply.github.com>
2020-06-27 15:02:11 +02:00
acqn
8a166ac82f
Fixed register usage tracking interfered by CE_SetArg.
2020-06-22 23:23:39 +02:00
acqn
2220c58f51
If the previous insn may be skipped, we cannot simply predict the output values of the registers.
2020-06-22 23:23:39 +02:00
acqn
53eb6a948d
No more duplicated stores by Opt_tosshift which could result in worse optimizations.
2020-06-22 23:23:39 +02:00
acqn
49c5cfd65b
Improved fix for Issues #167 and #784 and somehow #781 .
2020-06-22 23:23:39 +02:00
acqn
48d3578c24
Fixed Issue #784 .
2020-06-22 23:23:39 +02:00
acqn
a7a8426a90
Just keep Lhs loads in OptStackOps and leave them to OptUnusedLoads,
...
whilst Rhs loads must be removed for OptStackOps to work right.
Fixed Issue #167 as well as similar issues with tosshift.
2020-06-22 23:23:39 +02:00
Jesse Rosenstock
1c2edc5434
AddBitField: Rename Width arg to BitWidth
...
This makes the arg consistent with the SymEntry field name.
2020-06-21 01:08:44 +02:00
Jesse Rosenstock
4afc552e17
ParseStructDecl: Make BitOffs unsigned
...
This makes it consistent with SymEntry and removes the need for
some casts that were added to avoid warnings about signed vs
unsigned comparison.
2020-06-21 01:07:45 +02:00
mrdudz
baa5d051e4
use same description as in the docs
2020-06-16 00:11:07 +02:00
mrdudz
349a84d972
remove superfluous TAB
2020-06-16 00:08:55 +02:00
mrdudz
98c7186221
Add description for --debug-opt-output to the --help output
2020-06-15 23:39:50 +02:00
acqn
f9204e5b6f
Fixed g_addlocal codegen with long types.
2020-06-01 22:37:40 +02:00
acqn
8066cd9ace
Fixed wrong case in PreDec codegen, which never seems to be in use though.
2020-06-01 22:37:40 +02:00
acqn
07a5324a81
Fixed Issue #1028 by outputing local literals when exiting the function scope.
2020-06-01 22:37:40 +02:00
acqn
68f53e69f1
Fixed Issues #420 and #919 by always outputing the code segment before the three data segments for functions.
2020-06-01 22:37:40 +02:00
acqn
33e103fdc6
Fixed Issue #1040 : non-byte pointer +=/-= byte codegen bug.
2020-06-01 22:37:40 +02:00
Oliver Schmidt
555282497c
Removed --lib option from cl65.
...
The general approach of cl65 when generating the command lines to be executed is to first put options and the put files. However, this doesn't work well with the --lib option which would rather need to be put when libraries in general are put. I opted to not add this special behavior to cl65 as
* the use case for the --lib option is _VERY_ specific
* cl65 is after all a wrapper for ordinary use cases
2020-05-30 21:03:15 +02:00
laubzega
dc4142e1a9
Minor formatting changes after review.
2020-05-29 10:00:33 +02:00
laubzega
083f3ae26b
Fix for #928 .
2020-05-29 10:00:33 +02:00
Greg King
f8be35b41e
Fixed some typos in the "large alignment" support.
2020-05-15 21:09:02 -04:00
Chris Cacciatore
ad1eadd60d
Added support for --large-alignment in ld65.
...
Implemented the same way as in ca65.
2020-05-15 17:54:41 -04:00
greg-king5
4ea2bfef0a
Aligned comment.
2020-03-26 23:08:49 -04:00
marko.lauke
3e12840933
+code style
2020-03-26 23:08:49 -04:00
marko.lauke
68ff89ba0a
+cc65 inline asm stp mnemonic support
2020-03-26 23:08:49 -04:00
bbbradsmith
e0cb33d9d4
SEGMENT start of 0 should be valid
2020-03-22 21:03:07 +01:00
Greg King
2fc24847ac
Fixed an error message printer.
...
The disassembler can be built and won't crash if it sees duplicate labels, and one of them is an unnamed label.
2020-03-11 18:07:08 -04:00
Greg King
e2c6648607
Fixed a typo in commit 2e5fbe89cd
.
...
Changed a && to ||.
2020-02-21 08:12:05 -05:00
acqn
dc5114b071
Just disable OptPushPop if N/Z is used after the PLA.
...
This is a more conservative way to fix Issue #971 .
2020-02-01 18:04:32 +01:00
acqn
6d530931bf
Quick fix for the OptPushPop bug reported in Issue #337 .
2020-02-01 18:04:32 +01:00
acqn
9559625ee8
Always insert a LDA after the removed PLA during the optimization in OptPushPop.
...
Fixed Issue 971.
2020-02-01 18:04:32 +01:00
acqn
5b11eb4bb9
Corrected check in OptTransfers2 for register usage. Fixed Issue 992.
2020-02-01 18:04:32 +01:00
Greg King
90a2edcfa2
Made cc65 detect a possibly missing argument at the end of a function argument list.
...
(It could be a stray comma at the end of the list.)
2020-01-25 04:14:58 -05:00
Greg King
5109c0b68f
Made ca65 give error messages when it sees duplicate .define commands.
2020-01-02 04:26:02 -05:00
Greg King
3fa253d31f
Updated the cx16 library to the Commander X16 Kernal's prerelease 35.
2019-12-25 10:56:32 -05:00
Greg King
fb0d09a277
Changed sim65's internal error codes from 9-bit values to 7-bit values.
...
Some shells truncate process return codes to 8 bits. And, the eigth bit often is used to show that a signal stopped the process.
2019-12-06 14:47:47 -05:00
bbbradsmith
c9355734f5
make linker generated export warning conistent with the import warning
2019-11-18 21:50:44 +01:00
bbbradsmith
788fbcc9c8
Fix silent crash failure on warning from linker command line define import size mismatch
2019-11-18 21:50:44 +01:00
Greg King
4f24a06f0e
Fixed error handling for missing names in ld65 configure files.
2019-10-12 07:59:49 -04:00
Greg King
2e5fbe89cd
Made the "none" CPU allow all address sizes.
2019-10-02 10:09:48 -04:00
Greg King
18afc7c703
Created a target and a library for the Commander X16 prototype computer.
2019-09-27 03:38:51 -04:00
Greg King
0896deedef
Added a .ORG keyword to ca65 structs/unions.
...
Allow 24-bit numbers as operands in ca65 structs/unions.
2019-09-11 19:00:08 -04:00
Greg King
a0db846a97
Allowed old-style (K and R) function declarations to be fastcall.
...
That lets them match old-style definitions. It avoids "Type conflict" error messages. It allows shorter function calls.
Fixed the types of some variables in "test/ref/otccex.c". It avoids crashes on 64-bit Windows (32-bit Windows with 64-bit pointers).
2019-07-22 09:26:23 -04:00
Lauri Kasanen
925ea9d544
cc65: Add support for binary literals
...
Binary literals, 0b001, are a GCC extension in C and a C++14 feature.
2019-07-20 17:21:42 +02:00
Björn Esser
2f3955dbc7
src/Makefile: Simplify BUILD_ID logic.
2019-07-15 12:42:48 +02:00
Greg King
28584b31f1
Made the ld65 configure file's segment offset attribute accept zero as a value.
...
Expressions are allowed as values. Therefore, zero might be set explicitly by some conditions.
2019-06-30 22:44:10 -04:00
Björn Esser
83e0c70de5
Replace GIT_SHA with a more versatile BUILD_ID definition.
...
When compiling cc65, it will by default place the git hash (if available) of
the checked out commit in the version string. This isn't useful when building
a package for a Linux distribution, since there either won't be an upstream
git hash if there is one at all.
Thus we replace GIT_SHA with a more versatile BUILD_ID, which can be defined
to any arbitrary string. When building, its contents will be appended to the
version string instead of the git hash.
If BUILD_ID is not defined by the user the behaviour will be exactly the same
as before. That means BUILD_ID gets automatically defined to Git <GIT_SHA>,
if it can be determined from a checkout.
2019-06-09 20:17:15 +02:00
bbbradsmith
5269552346
sim65 common define for paravirt hooks base location
...
allows the loaded binary to take up as much space as possible
restored some documentation of the hooks but without reference to specific location
2019-05-31 10:40:04 +02:00
Oliver Schmidt
6efb71bea7
Rearranged paravirt function vector.
...
- exit right below 6502 vectors.
- keep exit addr stable as it may be called from asm.
2019-05-30 00:10:17 +02:00
bbbradsmith
7e4c4ee53e
sim65/main.c spaces were requested
2019-05-29 22:56:51 +02:00
bbbradsmith
fb7d4acd5c
versionable header for sim65
...
load and run address now configured from header
fix error codes not to conflict with test
fix test/misc/endless.c which is supposed to fail if an endless loop does not occur
2019-05-29 22:56:51 +02:00
bbbradsmith
07ca772932
adjust literal width to match variable type
2019-05-29 22:56:51 +02:00
bbbradsmith
2f3cae0d2e
movable sp for sim65
2019-05-29 22:56:51 +02:00
bbbradsmith
4642421da4
are more specific version of the comparison removal #895
2019-05-27 10:03:25 +02:00
bbbradsmith
3a3107b244
Disabling too-aggressive optimization in OptCmp8
...
Generates incorrect code for some 16-bit cases. See: #895
2019-05-27 10:03:25 +02:00
Richard Halkyard
448aa35f50
Fix realloc() bug in gr65
...
The pointer to the input buffer was not being updated after a call to
realloc(), causing the program to crash if realloc() moved the buffer.
2019-05-22 11:33:43 +02:00
Greg King
644d623d31
Reset the name of the "current bss segment" before writing bss variables into the output Assembly file.
...
Then, cc65 can notice a single "#pragma bss-name()" at the beginning of the variables list.
2019-05-18 12:16:52 -04:00
bbbradsmith
9299e550a5
fix NearAddr case in comment
2019-05-11 12:32:44 +02:00
bbbradsmith
7d14cff6bb
o65.c: missed a link time resolution of EXPR_NEARADDR
2019-05-11 12:32:44 +02:00
bbbradsmith
10cefdb456
move EXPR_NEARADDR to end of enum list to avoid invalidation of existing object binaries?
2019-05-11 12:32:44 +02:00
bbbradsmith
ac2ecb0b2c
65816 now generate EXPR_NEARADDR instead of EXPR_WORD0 for default assumed address mode, which will be validated by the linker's range check rather than blindly truncated. Assuming the assembler correctly validated this, the linker is allowed to truncate.
2019-05-11 12:32:44 +02:00
Christian Groessler
dd53c2ddc3
src/ld65/main.c: fix copy'n'paste error in comment
2019-05-01 10:57:48 +02:00
Christian Groessler
5a05acf936
ld65: implement '--allow-multiple-definition' command line parameter
2019-05-01 10:57:48 +02:00
Christian Groessler
c248c14075
src/ld65/exports.c: Issue an error instead of a warning for duplicate global symbols.
2019-05-01 10:57:48 +02:00
Brad Smith
1a5fa6dc51
goto.c warning fix for implicit truncation
2019-05-01 10:53:41 +02:00
IrgendwerA8
37f80534c9
Fix for #830 supplied by UvB
2019-04-25 15:19:53 +02:00
Greg King
214c90f957
Made the code that logs indirect-goto referals be a little more efficient.
2019-04-23 19:12:02 -04:00
Lauri Kasanen
f328481a48
Replace hard returns with an "else", add an error for non-IDENT tokens, and test for static
2019-04-21 12:46:03 -04:00
Lauri Kasanen
60d8559372
Return after errors, move left bracket consumption down
2019-04-21 12:46:03 -04:00
Lauri Kasanen
654d972288
C90 param, void
2019-04-21 12:46:03 -04:00
Lauri Kasanen
a9cbb5305c
Fix missing spaces
2019-04-21 12:46:03 -04:00
Lauri Kasanen
304473d857
Adjustment for '816
2019-04-21 12:46:03 -04:00
Lauri Kasanen
3b3b16ee9c
Add support for computed gotos
...
This is a GCC extension that allows C to use fast jump tables.
2019-04-21 12:46:03 -04:00
Lauri Kasanen
c2220f3c30
Add a goto indirect jump from pointer
2019-04-21 12:46:03 -04:00
Lauri Kasanen
37f00e6644
Export the label symbol table
2019-04-21 12:46:03 -04:00
Lauri Kasanen
2af76c7cff
Only for jumps, the lib uses named asm labels in branches
2019-04-21 12:46:03 -04:00
Lauri Kasanen
c3d809b129
Fix jmp-callax.c bug
2019-04-21 12:46:03 -04:00
IrgendwerA8
dcbe03f23b
Adjusted to the current multiline-comment style.
2019-04-02 16:34:22 +02:00
IrgendwerA8
1530020a1f
Fix for multiplication optimization issue #367
2019-04-02 16:34:22 +02:00
Steven Hugg
ae261e91f2
Code cleanup per code review
2019-03-31 22:33:22 -04:00
Steven Hugg
9faaa0689b
cleaned up code per review
2019-03-31 22:33:22 -04:00