1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00
Commit Graph

160 Commits

Author SHA1 Message Date
uz
50ff6d0768 Create one literal pool per function, so that literal pool data is removed
together with a function, if it is not used. Literal storage can now be
controlled by #pragma writable-strings on a per function basis.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4499 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-04 14:12:25 +00:00
uz
ce931b85be In case of parse errors for structs, don't just set the type of the result to
"int", return a valid lvalue instead.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4483 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-11-24 23:02:58 +00:00
uz
548336a7bd Renamed attribute handling functions. Added SymHasAttr().
git-svn-id: svn://svn.cc65.org/cc65/trunk@4375 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-19 10:19:26 +00:00
uz
5a00b38aab Fixed the existing but unused attribute parsing code. Added
__attribute__((noexit)) that may be used to mark functions that won't return.
Added this attribute to the exit() function in stdlib.h.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4372 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-18 18:31:02 +00:00
uz
0ce362a69b Some cleanup in the code generator. Added a g_drop function. g_drop and
g_space can now handle sizes > 255 bytes.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4370 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-15 21:08:03 +00:00
uz
17d592352c Fixed an error with r4329: In case of a struct pointer the qualifiers of the
pointers had been used, not the qualifiers of the struct.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4340 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-08 09:54:46 +00:00
uz
9c5224165f Fixed a bug: A similar problem as that with structs does also exist for
arrays. An array element has all qualifiers from itself and from the array
declaration.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4334 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 18:46:39 +00:00
uz
7992bfb74a Changed solution for r4329 so that it uses less memory.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4331 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 18:22:28 +00:00
uz
c69e2d9f0f Fixed a bug: Function designators are converted to rvalues of type "pointer to
function", so dereferencing a function is a legal operation. The result is
immediately converted back to "pointer to function" again. Note: Because of
performance considerations, cc65 does treat functions as "pointer to function"
internally, but nevertheless dereferencing a function must be possible.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4330 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 17:49:45 +00:00
uz
43c89d5fd0 Fixed a bug: A struct field has all qualifiers from its definition plus the
qualifiers of the struct.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4329 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 17:37:45 +00:00
uz
8e35f0d9c8 The combined assignment operator (-=, +=, ...) did not check that the rhs is
actually an integer.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4297 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-01 19:41:40 +00:00
uz
b5db4cd5fa Added wide char literals, but treat them identical as normal strings.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4185 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-18 14:28:52 +00:00
uz
e68332a10b Fixed several more problems like the one in Assignment() some time ago: An
expression that yields a constant value may have side effects, and the
expression code must not be removed in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4138 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 20:29:12 +00:00
uz
2d3b0f1146 Fixed a problem similar to the one in Assignment() some time ago: An
expression that yields a constant value may have side effects, and the
expression code must not be removed in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4137 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 20:08:21 +00:00
uz
0c20177fce Allow to store start and end of generated code in the ExprDesc structure. New
function MarkedExprWithCheck.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4135 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 19:48:22 +00:00
uz
94a2223443 Use SymIsTypeDef and SymIsBitField instead of accessing Sym->Flags directly.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4123 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-06 16:51:08 +00:00
uz
944057238e Simplify code generated for the ?: operator when type conversion code for the
second operand is necessary. Instead of generating interleaved code with
several jumps, just move the code to the right place.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4105 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-01 08:57:36 +00:00
uz
6b4fe90928 First implementation of bit fields.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4079 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-29 21:20:13 +00:00
uz
bd872a6324 Added code to parse bit fields and enter them into the symbol table. They're
not supported in code generation until now.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4072 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-29 17:38:53 +00:00
uz
c214fa6395 When preprocessing, all compares evaluate to constants, so don't print a
warning in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4059 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-27 22:09:46 +00:00
uz
d65928829f Added a warning if the result of a compare operation is constant. This should
protect against missing parenthesis like in (si & 0x7F == 0). Hopefully
without too many false positives.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4057 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-27 22:00:18 +00:00
uz
a3eed9016f Fix problem with R3904: Chars on the lhs of opeq must still be accessed as
such.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3985 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-07-30 15:15:13 +00:00
uz
37157a31a8 Fixed problems with R3977: While the solution was correct, the generated code
is bad, since information is lost when converting functions and arrays to
pointers and cannot be regained easily. So I've reverted the change and fixed
the problem in a less general manner.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3984 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-07-30 14:45:50 +00:00
uz
4dd9c523e7 Check for division by/modulo by zero when parsing the /= and %= operators.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3937 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-02-17 21:09:59 +00:00
uz
c4dac550a8 Small change to avoid endless error loops (aborted by the maximum error count)
if an unexpected token is encountered in Primary().


git-svn-id: svn://svn.cc65.org/cc65/trunk@3936 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-02-17 20:56:13 +00:00
uz
308ceeacf9 Fixed problems with casts, where larger values weren't truncated when casting
down to char size.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3904 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-12-28 16:25:03 +00:00
uz
cc36f8a93a Moved the fascall and near/far flags from the function desriptor into the
type. Started to add general handling of address size flags in types.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3891 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-24 17:33:30 +00:00
uz
0b60ac4716 Use GlobalModeFlags() if apropriate.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3885 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-09 20:33:11 +00:00
uz
1e672a3169 Fixed a bug: The op= operators (+=, -=, etc.) worked on const qualified
objects.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3883 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-07 22:22:58 +00:00
uz
66b3f9d974 Fixed a bug: It was possible to increment or decrement const qualified
objects.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3882 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-07 22:18:12 +00:00
uz
5cd0b86a1a Indexing a string by an expression which was not a simple variable didn't
work:  "abcd"[atoi("2")];
                         


git-svn-id: svn://svn.cc65.org/cc65/trunk@3880 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 21:20:42 +00:00
uz
9127774a4d Pass a complete ExprDesc and not just the Flags field to GlobalModeFlags to
allow for better debugging (output) in case of problems.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3879 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 21:11:26 +00:00
uz
dbb9a31fd9 Fixed wrong code generation for
((unsigned char *)(&shadow))[reg & 0x0f] = value;


git-svn-id: svn://svn.cc65.org/cc65/trunk@3875 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 19:47:57 +00:00
uz
3482a9e7ce Fixed a comment
git-svn-id: svn://svn.cc65.org/cc65/trunk@3868 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-03 20:09:03 +00:00
cuz
52c0c284da Calling an undefined function is an error in C99.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3857 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-07-31 18:30:33 +00:00
cuz
10c949062b Fixed a bug: The compiler evaluated constant expressions internally always
using signed integers as data types. This led to wrong results for mod, div
and compares.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3797 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-08-26 18:53:46 +00:00
cuz
80a4c8c02b Fix type of "&array" - it will actually generate pointer to array, not pointer
to element. This will make some valid code work but emits now errors for
questionable code.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3775 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-03-18 19:15:35 +00:00
cuz
9601baf6ec Fixed internal compiler error on invalid input code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3768 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-02-03 18:11:37 +00:00
cuz
eb745b3d1b Fixed a problem with undefined identifiers in #if expressions: If the
identifier is not the last token on the line, the compiler will run into
an error.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3744 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-05-29 20:38:44 +00:00
cuz
de3a20a898 Changed the low level type representation from a strung of unsigned short
elements to a string of structs, each representing one type element. This
should fix problems on unusual architectures, since it is no longer necessary
to embedd pointers and other data converted to numbers in the string of
unsigned shorts.
Increased the TypeCode length to unsigned long to make room for more type
bits.
Inline more functions in datatype.h.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3709 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-19 12:29:37 +00:00
cuz
64921852dd Parse the C99 "restrict" keyword correctly (but ignore it otherwise).
git-svn-id: svn://svn.cc65.org/cc65/trunk@3706 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-17 20:19:35 +00:00
cuz
e4ec9014d2 Reversed accidentally checked in changes
git-svn-id: svn://svn.cc65.org/cc65/trunk@3613 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-08-31 21:49:12 +00:00
cuz
d6c50c1826 Added HuC6280 cpu (will be treated as a 65C02)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3612 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-08-31 21:48:08 +00:00
cuz
c218639977 Fixed a bug: The compiler aborted with an internal error if a non function
was called as a function after printing the diagnostic.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3526 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-07-17 09:49:34 +00:00
cuz
b01c0cf2b7 Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@3511 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-05-11 13:54:22 +00:00
cuz
e06d9d0d84 Fixed a bug (hopefully).
The ArrayRef() does really need a rewrite, now since we have better
expression info.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3364 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-01-09 21:17:19 +00:00
cuz
40d01eb4ce Fixed bug with braces in initializer lists
git-svn-id: svn://svn.cc65.org/cc65/trunk@3193 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-09-23 17:34:03 +00:00
cuz
366d066375 Fixed the last fix
git-svn-id: svn://svn.cc65.org/cc65/trunk@3171 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-08-02 17:19:52 +00:00
cuz
123677c802 In a function call for all parameters not covered by a prototype, convert
arrays to pointer to first element, and functions to pointer to function.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3169 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-08-02 16:39:55 +00:00
cuz
104f041111 Add dummy return value to avoid a wcc warning
git-svn-id: svn://svn.cc65.org/cc65/trunk@3162 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-07-17 22:16:02 +00:00