Commit Graph

85 Commits

Author SHA1 Message Date
acqn 43d2fd2a96 Added support for the popular __COUNTER__ macro. 2022-07-24 23:19:05 +08:00
Bob Andrews 68610490c9
Merge pull request #1837 from acqn/PPLineFix
[cc65] Fixed predefined __FILE__, __LINE__ and added missing preprocessing directive #line
2022-08-26 23:12:59 +02:00
acqn 57ad7c8766 Improved diagnostics about C++ style comments for c89. 2022-08-22 14:31:53 +08:00
acqn fd7f32ecd3 Improved error handling and diagnostics with failed macro definitions. 2022-08-22 14:31:51 +08:00
acqn 9565f41381 Improved Diagnostic with #include. 2022-08-19 13:27:56 +08:00
acqn 5d5bd472c6 Removed extra whitespace at line ends in preprocess-only output (-E).
Increased threshold from 5 to 7 for skipped newlines with #line directives in preprocess-only output (-E).
2022-08-22 00:27:21 +08:00
acqn 79f97e7714 Reused code more for macros in preprocessing directives. 2022-08-22 00:24:28 +08:00
acqn bb9c98f4c9 Added support for the #line directive. 2022-07-24 23:19:05 +08:00
acqn 36123c9c8f Improved naming for stuff related to preprocessing directives. 2022-07-24 23:19:05 +08:00
acqn cf7558add3 Added check for ## at either end of macro expansion. 2022-08-18 23:16:29 +08:00
acqn a3a5fbe809 Disallowed 'defined' as a macro name. 2022-08-07 13:56:47 +08:00
acqn ae811baaf1 Fixed the bug that redefined macros could co-exist but not all be undefined with a single #undef. 2022-08-06 18:21:42 +08:00
acqn 47d5e74a6e Modified way to keep undefined macro handling more consistent. 2022-08-18 22:51:23 +08:00
acqn 7971eec3cc Fixed parentheses handling when a function-like macro name itself is used as an macro argument. 2022-08-07 12:45:48 +08:00
acqn 0a051a4dee Unsupported #pragma within argument lists of function-like macro invocation. 2022-08-06 16:56:28 +08:00
acqn 251e984ba8 Fixed error recovery with preprocessing directives failures. 2022-08-05 14:03:51 +08:00
acqn 2f357ba9b2 Preprocessor directives can now appear in the argument list of function-like macro calls.
#pragma PP-tokens can now be macro replaced.
#include header names directly enclosed in <> are free of macro replacement.
Preprocess-only mode (-E) now outputs with #line as source info.
Moved testcases for #760 and #1357.
Added testcase for #1643.
2022-07-26 21:10:38 +08:00
acqn 80fc8cd11e Added preprocessor warning on missing terminating characters of character/string literals. 2022-07-26 21:10:36 +08:00
acqn 2c9c8ee196 Fixed extra "Macro argument count mismatch" message when a macro argument list is unterminated. 2022-07-26 21:10:31 +08:00
acqn 60c1290468 Fixed the bug that preprocessor could run past the end of included files.
Fixed the wrong filename and 0 line number in disgnostics when a preprocessor error occurred at the end of a file.
Fixed diagnostics for missing #endif.
2022-07-26 21:10:26 +08:00
acqn 0063f73f8a Fixed __FILE__ and __LINE__ macros for preprocessor. 2022-07-24 23:19:05 +08:00
acqn 7381a2c420 Added check for extra tokens at the end of directives.
Improved diagnostics on missing/illegal macro names.
2022-07-24 19:07:16 +08:00
acqn 8289c94e69 Fixed skipped lines consist of a leading # followed by any non-directive PP-token sequence. 2022-07-26 14:28:27 +08:00
acqn be26b0631b Fixed #ifdef and #ifndef. 2022-07-24 19:07:02 +08:00
acqn 16a8a64746 Use a dedicated expression parser for the preprocessor. 2022-07-21 11:10:02 +08:00
acqn f91c8ad247 Allowed comments right after "#" in preporcessor directives. 2022-07-21 11:09:59 +08:00
acqn d3d6de2704 Allowed the pp-tokens following #error and #warning directives to be optional. 2022-07-21 11:09:56 +08:00
Greg King 0d3c827d80 Made the C preprocessor #if nesting stack have 256 levels.
Closes #1523.
2021-05-30 03:52:32 -04:00
Andrea Odetti bcc670ee36 Standard formatting of error messages.
https://www.gnu.org/prep/standards/html_node/Errors.html

Issue: https://github.com/cc65/cc65/issues/1494
2021-05-11 17:41:59 +02:00
acqn 60c59f59a3 Renamed StaticConstExpr() and StaticConstAbsIntExpr() with clearer comments. 2020-08-30 00:26:52 +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
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
Greg King a555f121fd Fixed the " til " typos. 2015-09-06 12:25:00 -04: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 631c553233 Reverted some errorneously committed changes which enabled debug output.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5414 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-01-20 16:04:37 +00:00
uz cbefb85d47 Fixed a problem reported by Greg King. structs returned from functions in the
primary register are actually rvalues and need special treatment.
                                                                 


git-svn-id: svn://svn.cc65.org/cc65/trunk@5413 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-01-20 16:01:25 +00:00
uz 05f7296369 Restructured search path handling.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4662 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-05-09 10:54:15 +00:00
uz af27ae6d79 Fixed two issues with macros:
* A newline between the macro name and the argument list of a function like
  macro was not accepted.
* An unterminated macro argument list was not always detected.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4621 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-03-14 17:46:02 +00:00
uz 41f7757204 Ignore unknown preprocessor directives in an #if group that is excluded.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4534 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-30 11:20:09 +00:00
uz 85f96a7d6f Fixed warnings generated by clang (run by Per Olofsson).
git-svn-id: svn://svn.cc65.org/cc65/trunk@4255 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-28 15:59:18 +00:00
uz 1a54f34a84 Fixed a problem with recursive macro expansions. They didn't work if the same
macro was involved more than one time.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3911 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-01-24 16:31:18 +00:00
cuz 9174f65e54 Make much more usage of dynamic strings (StrBufs) instead of char* and
friends. Since names and other strings are now StrBufs in many places, code
for output had to be changed.
Added support for string literals to StrBuf.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3825 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-03-31 20:54:45 +00:00
cuz e8b90752d9 Preprocess the remainder of the line in a #include preprocessor directive.
This allows use of macros in the file spec and is a requirement of the C
standard.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3803 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-08-31 16:02:03 +00:00
cuz 79a89299b9 Added #warning (suggestion by Rudolf Schubert).
git-svn-id: svn://svn.cc65.org/cc65/trunk@3799 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-08-28 12:53:43 +00:00
cuz b7255ed8fa Terminate the line containing the #if expression before passing it to the
parser.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3743 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-05-29 20:36:21 +00:00
cuz 84706bd2d5 Fixed portability problems with va_copy. In three places, calls to fstat
had to be replaced by calls to stat, because fileno is no longer available
when forcing the compiler into pure c89 (or c99) mode.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3683 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-12-11 12:40:51 +00:00
cuz f02698b66d Minor changes to the variadic macro feature. Added a copyright notice to
the file.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3554 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-07-26 22:30:35 +00:00