Commit Graph

82 Commits

Author SHA1 Message Date
acqn fdded33097 Made it easier to support 0-size structs in the future. 2020-08-15 06:27:11 +08:00
acqn 21858b52e7 Separated data initializer stuff from declaration stuff. 2022-01-03 13:10:32 +08:00
Greg King 325ff9667e Used (size_t), instead of (long) where converting between pointers and integers.
(long) still is 32 bits on 64-bit Windows!
2021-12-12 19:40:43 -05:00
acqn 18ae09f682 Less excessive errors with failed array declarations. 2021-05-14 10:48:17 +02:00
acqn 5c43d1e04f Changed codegen for postfix inc/dec operations by deferring them till sequence points.
This usually allows faster & smaller code.
Note that deferred operations must still be called at sequence points even if the whole expressions containing them had constant values.
2020-10-20 22:01:55 +02:00
acqn 6b64b43395 Made local static data use a separated label pool from the code label pool. 2020-08-31 09:12:03 +02:00
acqn 504aee3835
Merge branch 'master' into StaticConst 2020-08-27 06:27:23 +08:00
acqn 1957dc7a5c Disallowed arrays of incomplete types.
Fixed diagnostics on incomplete local arrays.
2020-08-26 22:14:51 +02: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 13ed557b92 Fixed compatibility checking of function declarations by using the composite types of them. 2020-08-14 18:33:54 +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 d68cd90e47 Function declaration in functions cannot have storage classes other than 'extern'. 2020-08-07 10:16:33 +02:00
acqn 8cdffc1944 No storage for unsuccessfully parsed variables. 2020-08-07 10:16:33 +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
acqn 78342fa82c Fix for "auto" variables made "static" with the "-Cl" options. 2020-07-20 15:01:47 +02:00
acqn 2108489523 Fix for Issue #1075 and #1077. 2020-07-18 12:54:29 +02:00
Greg King a6b04f6e97 Changed most "backticks" (grave accents) into apostrophes.
Quotations that are embraced by tick marks now look better, in most fonts.
2019-01-05 14:57:12 -05:00
laubzega 02a914625b Formatting fixes. 2018-10-02 18:49:53 +02:00
laubzega c797b3b376 Proper warnings for "risky" gotos. 2018-10-02 18:49:53 +02:00
Laubzega a4b6bb63c0 Minor changes after review. 2018-10-02 18:49:53 +02:00
Laubzega 581c46c213 Add checks for risky goto statements. 2018-10-02 18:49:53 +02:00
Greg King 0390c34e88 Changed multi-line C comments into another style.
The left side doesn't look unbalanced.
2014-06-30 16:51:07 -04:00
Oliver Schmidt 4185caf855 Normalized code. 2014-03-04 01:11:19 +01:00
Oliver Schmidt 85885001b1 Removed (pretty inconsistently used) tab chars from source code base. 2013-05-09 13:57:12 +02:00
uz fd679d92d0 Fixed a problem: When a struct or unit was declared with a tag name, it was
possible to use the opposite type with the tag name. That is "struct a" after
declaring "union a" and vice versa.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5980 b7a2c559-68d2-44c3-8de9-860c34a00d81
2013-02-02 22:31:26 +00:00
uz cd7e65f97e Fixed an uniniitalized variable which caused ranom error messages on static
local variables.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5650 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-04-22 21:38:31 +00:00
uz faf58a8220 Fixed an error when parsing local variables: Variables must be inserted into
the symbol table *before* the optional initializer is parsed, because they
might be referenced in the intializer.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5648 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-04-22 18:08:45 +00:00
uz 724d1b9160 Fixed an error: When determining where to place initialized data, the compiler
didn't look "deep enough" into nested arrays to determine the constness
correctly.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5622 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-03-24 14:28:59 +00:00
uz 64b597017a Fix the check for constant static local data, which was wrong when the data
was an array. It should go into RODATA, not DATA.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4669 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-05-27 19:47:13 +00:00
uz 7687489a08 Fixed a bug in the last change. For variables that have no initializer, no
storage was allocated if -Cl (static locals) was in effect.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4390 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-26 10:17:17 +00:00
uz bd45df7cad Rearranged/duplicated optimization steps to generate better code in a few
cases.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4387 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-23 10:03:46 +00:00
uz 814be2524b Restructured parts of locals.c. This will also fix a problem where arrays with
unspecified size but an initializer would cause an error when -Cl (static
locals) was in effect.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4385 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-23 09:22:17 +00:00
uz 24c6e1ce5b Move some storage class handling and checking for implicit into from locals.c
and compile.c into ParseDecl() (declare.c).


git-svn-id: svn://svn.cc65.org/cc65/trunk@3867 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-03 18:20:12 +00:00
uz 841ea0e686 Transfer the storage class flags from struct DeclSpec into struct Declaration.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3866 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-03 18:00:05 +00:00
cuz fd7e66f24c Fixed an error.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3784 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-07-03 16:01:51 +00:00
cuz 5c1bc2d740 Output warnings for implicit int types if std >= C99.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3361 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-01-09 18:03:55 +00:00
cuz 8752f0b2c1 Removed ExprLoad to LoadExpr.
Moved LoadExpr + support functions into a separate module.
Removed obsolete files.
Some cleanup and makefile adjustments.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3113 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-09 14:12:57 +00:00
cuz 9fc71c5e93 Renamed ExprDesc.Val to ExprDesc.IVal. Added an FVal field for a floating
point constant.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3107 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 14:48:59 +00:00
cuz 104ae3a54f Move the compiler stack pointer into its own module.
Improved the inlining of standard C functions. Added more standard functions
to inline.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3095 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-05 11:35:53 +00:00
cuz 8d8162eb23 Rewrite/cleanup of the complete expression flags handling.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3056 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-31 15:27:33 +00:00
cuz 878e4f1352 Changed the expression parser to return the lvalue flag as part of the
ExprDesc structure, not as separate value.
WARNING: The current code does compile but does not work correctly, because
the lvalue flag is part of ExprDesc.Flags and not masked out in several tests
throughout the code.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3046 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-25 20:59:38 +00:00
cuz d0ea9f34b6 Made several options that can be changed by #pragmas stackable.
Added new #pragma regvars.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2902 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-03-07 21:53:35 +00:00
cuz 14fc5c1073 Renamed exprhs to ExprLoad
git-svn-id: svn://svn.cc65.org/cc65/trunk@2426 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-29 09:16:28 +00:00
cuz 81f94afd5c Rewrote type conversions
git-svn-id: svn://svn.cc65.org/cc65/trunk@2262 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-11 20:18:30 +00:00
cuz f817b05fa9 Allow initialization of flexible array struct members
git-svn-id: svn://svn.cc65.org/cc65/trunk@1928 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-02-05 22:02:48 +00:00
cuz 7a1a7745eb Fixed the address
git-svn-id: svn://svn.cc65.org/cc65/trunk@1913 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-02-01 12:38:43 +00:00
cuz 703447dd26 Locals with a qualifier and implicit int type where not parsed correctly
git-svn-id: svn://svn.cc65.org/cc65/trunk@1910 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-01-28 16:28:41 +00:00
cuz 70755921a9 Re-added register variables.
Changed/added several optimizer steps to detect register variables correctly
or to handle them in a special way.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1636 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-25 15:05:15 +00:00
cuz ede471904c Reenable register variables
git-svn-id: svn://svn.cc65.org/cc65/trunk@1625 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-24 23:31:54 +00:00