Commit Graph

901 Commits

Author SHA1 Message Date
Stephen Heumann c8517eff87 Give an error for sizeof(bitfield).
This violates a constraint in the standards (C17 6.5.3.4 p1).
2023-05-07 18:28:31 -05:00
Stephen Heumann c2262929e9 Fix handling of #pragma float.
This was not getting recognized properly, because float is a keyword rather than an identifier.
2023-04-30 21:47:19 -05:00
Stephen Heumann 9d5360e844 Comment out some unused error messages. 2023-04-30 21:38:34 -05:00
Stephen Heumann 338bfdd908 Add const qualifier in c2pstr/p2cstr declarations.
This reflects their actual behavior and may prevent some errors when using strict type checking.
2023-04-30 21:37:16 -05:00
Stephen Heumann 118e326ac9 Miscellaneous small updates to release notes. 2023-04-30 21:36:23 -05:00
Stephen Heumann 938fa96503 Update the manual.
It now covers pretty much all the new features, as well as addressing the errata from the release notes and some other miscellaneous issues. The early chapters still need to be updated to refer to a hard disk installation, rather than being based on running it from floppies (which is no longer supported). I'm sure more proofreading and editing would also be beneficial.
2023-04-30 21:35:32 -05:00
Stephen Heumann 986fe9a65b Address issues in samples detected by new lint checks.
The only actual behavior change is in Ackermann.cc, which previously reported incorrectly high recursion depths for some calculations.
2023-04-23 19:35:16 -05:00
Stephen Heumann ab975b611c Add C samples.
These are the samples from ORCA/C 2.1.0, converted to LF line endings.
2023-04-23 18:34:34 -05:00
Stephen Heumann e123339a45 Add the manual.
This is the ORCA/C 2.0 manual from Opus ][, re-saved in the modern Microsoft Word format and adjusted to fix some formatting issues. In particular, the embedded images needed to be converted to formats that current versions of Word support. The result is very close to the original version, although the pagination winds up slightly different in some places.
2023-04-22 19:02:12 -05:00
Stephen Heumann 0274b0ba83 Document octal formatting bug fix. 2023-04-17 22:00:29 -05:00
Stephen Heumann 84401b4e97 Fix a test case to account for printf '-' flag overriding '0'. 2023-04-16 21:44:05 -05:00
Stephen Heumann 3a298ec341 Add documentation and tests for 'a'/'A' printf conversions. 2023-04-16 20:25:15 -05:00
Stephen Heumann 2974c1b4bb Document fprintf bug fix. 2023-04-16 18:58:38 -05:00
Stephen Heumann 9dad2b6186 Update displayed version number to mark this as a development version. 2023-04-16 14:29:02 -05:00
Stephen Heumann 5c96042423 Update ORCA/C version number to 2.2.0 B7.
Also tweak documentation wording in a couple places.
2023-04-06 18:53:34 -05:00
Stephen Heumann e5c7aebb3f Avoid spurious undefined variable errors for functions returning structs/unions.
When the lint check for undefined variables was enabled, a "lint: unused variable: @struct" would be produced for any function returning a struct or union, due to the special static variable that is created to hold the return value. That spurious lint message is now suppressed.
2023-04-06 18:52:45 -05:00
Stephen Heumann 20f9170343 Give errors for certain illegal initializers.
This prohibits initializers in "extern" declarations within a function, and in the parameter declarations of non-prototyped functions.

Here are examples illustrating these cases:

int main(void) {
        extern int i = 50;
}

void f(i)
int i = 60;
{
}
2023-04-06 12:49:26 -05:00
Stephen Heumann 4c903a5331 Remove a few unused variables. 2023-04-04 18:11:41 -05:00
Stephen Heumann 0b3f48157e Simplify code for writing out extended constants.
This removes the need for the CnvSX function, so it is removed.
2023-04-04 18:11:04 -05:00
Stephen Heumann ba57d51500 Add a correction about the debug check box in Prizm. 2023-04-02 22:12:48 -05:00
Stephen Heumann 74cec68dac Generate better code for some floating-point and long long constants.
We now recognize cases where the same value needs to be pushed for several consecutive words, so it is more efficient to load it into a register and push that rather than just using PEA instructions.
2023-04-02 19:39:03 -05:00
Stephen Heumann 4e5e622903 Do not use FX2X to copy floating-point values.
This is gratuitously slow, and may also cause a loss of precision under Golden Gate (depending on the host platform).
2023-04-02 16:34:53 -05:00
Stephen Heumann c678151bde Add tests and documentation for fma(). 2023-04-02 16:31:28 -05:00
Stephen Heumann a988ef60bc Document bug fix for functions run at exit in large memory model. 2023-03-28 22:11:38 -05:00
Stephen Heumann ae89e77bbe Remove some unused or write-only variables. 2023-03-24 19:49:55 -05:00
Stephen Heumann 7e860e60df Generate better code for pc_ixa in large memory model.
This improves the code for certain array indexing operations.
2023-03-23 18:41:16 -05:00
Stephen Heumann 2412ae0661 Prohibit static initializers referring to a non-static array element.
This covers code like the following:

int main(void) {
        auto int a[20];
        static int *p = &a[5];
}

Previously, this would compile without error, and then either give a linker error or be linked to refer to the global symbol "a" (if there was one).
2023-03-21 09:10:37 -05:00
Stephen Heumann 3a64c5b977 Generate better code for stack array indexing in large memory model.
Any stack-allocated array must be < 32KB, so we can use the same approach as in the small memory model to compute indexes for it (which is considerably more efficient than the large-memory-model code).
2023-03-20 17:56:44 -05:00
Stephen Heumann be291b2423 Show "Including ..." lines for all headers when using a sym file.
Previously, only the last header from a group of headers represented together would be listed.
2023-03-20 17:22:13 -05:00
Stephen Heumann cc36e9929f Remove some unused variables. 2023-03-20 11:12:48 -05:00
Stephen Heumann 3b6f73c277 Prohibit "typedef" in function definitions. 2023-03-19 20:16:36 -05:00
Stephen Heumann cbf32e5b71 Comment out an unused peephole optimization involving BVS.
The code generator never generates this code sequence (and did not do so even prior to the last commit), so having a peephole optimization for it is pointless.
2023-03-18 20:09:49 -05:00
Stephen Heumann a5eafe56af Generate more efficient code for 16-bit signed comparisons.
The new code is smaller and (in the common case where the subtraction does not overflow) faster. It takes advantage of the fact that in overflow cases the carry flag always gets set to the opposite of the sign bit of the result.
2023-03-18 20:05:56 -05:00
Stephen Heumann 137188ff4f Comment out an obsolete error message. 2023-03-17 19:47:30 -05:00
Stephen Heumann 1b7b198039 Remove unneeded extern declarations. 2023-03-17 18:14:19 -05:00
Stephen Heumann ea056f1fbb Avoid listing the first line twice when a pre-include file is used. 2023-03-15 20:43:43 -05:00
Stephen Heumann 344bf6999f Do not give an error for files that end with an #endif with no newline.
This was a problem introduced by commit 30a04d42c5.
2023-03-15 20:11:39 -05:00
Stephen Heumann 49deff3c86 Generate more efficient code for certain conditionals.
This will change a "jump if true" to "jump if false" (or vice versa) and logically negate the condition in certain cases where that generates better code.

An assembly peephole optimization for certain "branch to branch" instructions is also added. (Certain conditionals could generate these.)
2023-03-14 21:32:20 -05:00
Stephen Heumann 7c8ec41148 Optimize some assembly code sequences that can occur for array access.
Here is an example that benefits from the new optimizations:

#pragma optimize 7
void f(char *a, unsigned i, unsigned n) {
        a[i] = (a[i] & 0xF0) | n;
}
2023-03-09 17:53:45 -06:00
Stephen Heumann 30a04d42c5 Require preprocessor conditionals to be balanced in each include file.
This is required by the standard syntax for a preprocessing file (C17 6.10), which must be a "group" (or empty).
2023-03-07 19:00:13 -06:00
Stephen Heumann 27c68b41d5 Do not inhibit sym file generation if there is a segment directive before an #include.
This affected code like the following, causing stdio.h not to be represented in the sym file:

segment "S";
#include <stdio.h>
int main(void) {}
2023-03-07 18:34:36 -06:00
Stephen Heumann c6ba1e1c1c Use bit operations rather than division in a few places.
This should produce faster code.
2023-03-06 22:52:52 -06:00
Stephen Heumann 3ac55a64bf Use an improved hash function for symbol tables.
The hash algorithm has been modified to include a rotate at each step. This should improve the quality of hashes and reduce the number of collisions. However, probably the more important change for performance is to do the modulo computation by repeated subtraction rather than by calling a slow library function.
2023-03-06 21:54:14 -06:00
Stephen Heumann 3406dbd3ae Prevent a tag declared in an inner scope from shadowing a typedef.
This could occur because when FindSymbol was called to look for symbols in all spaces, it would find a tag in an inner scope before a typedef in an outer scope. The processing order has been changed to look for regular symbols (including typedefs) in any scope, and only look for tags if no regular symbol is found.

Here is an example illustrating the problem:

typedef int T;
int main(void) {
        struct T;
        T x;
}
2023-03-06 21:38:05 -06:00
Stephen Heumann 645b210e7f Prevent tags from shadowing variable names within static initializers.
This occurred due to looking for the symbol in all namespaces rather than only variable space.

Here is an example affected by this:

int X;
int main(void) {
        struct X {int i;};
        static int *i = &X;
}
2023-03-05 22:29:09 -06:00
Stephen Heumann 1f6bc44b48 Fix handling of typedef names immediately after an inner scope where the identifier is redeclared.
If an identifier is used as a typedef in an outer scope but then declared as something else in an inner scope (e.g. a variable name or tag), and that same identifier is the next token after the end of the inner scope, it would not be recognized properly as a typedef name leading to spurious errors.\

Here is an example that triggered this:

typedef char Type;
void f(int Type);
Type t;

Here is another one:

int main(void) {
        typedef int S;
        if (1)
                (struct S {int a;} *)0;
        S x;
}
2023-03-05 21:40:59 -06:00
Stephen Heumann 85890e0b6b Give an error if assembly code tries to use direct page addressing for a local variable that is out of range.
This could previously cause bad code to be produced with no error reported.
2023-03-04 21:06:07 -06:00
Stephen Heumann a985a9ca7a Simplify code generation for function parameters.
The old approach would call GenerateCode twice for each parameter expression. Now, it is only called once. This is faster, and also avoids some oddities with error handling. With the previous approach, expressionType would not be set if there was an error in the expression, which could lead to additional spurious errors. Also, a lint message treated as a warning could appear twice.
2023-03-01 22:20:33 -06:00
Stephen Heumann ea623d38fc Avoid incorrectly setting lastwasconst.
This could happen in some cases where one subexpression of a larger expression was a constant. One effect of this was to cause spurious "lint: implicit conversion changes value of constant" messages in certain cases (when that lint check was enabled). It may also have caused certain errors to be missed in other situations.
2023-02-28 22:36:42 -06:00
Stephen Heumann bda54c0a79 Document qsort fixes. 2023-02-16 20:38:44 -06:00