mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-01 13:29:32 +00:00
Allow "extern inline" functions.
A function declared "inline" with an explicit "extern" storage class has the same semantics as if "inline" was omitted. (It is not an inline definition as defined in the C standards.) The "inline" specifier suggests that the function should be inlined, but it is legal to just ignore it, as we already do for "static inline" functions. Also add a test for the inline function specifier.
This commit is contained in:
parent
f54d0e1854
commit
f31b5ea1e6
@ -3779,7 +3779,7 @@ if isFunction then begin
|
||||
goto 1;
|
||||
end; {if}
|
||||
if isInline then
|
||||
if declSpecifiers.storageClass <> staticsy then
|
||||
if not (declSpecifiers.storageClass in [staticsy,externsy]) then
|
||||
Error(120);
|
||||
if isInline or isNoreturn then
|
||||
if not (isNewDeskAcc or isClassicDeskAcc or isCDev or isNBA or isXCMD) then
|
||||
|
@ -714,7 +714,7 @@ if list or (numErr <> 0) then begin
|
||||
117: msg := @'field cannot have incomplete or function type';
|
||||
118: msg := @'flexible array must be last member of structure';
|
||||
119: msg := @'inline specifier is only allowed on functions';
|
||||
120: msg := @'non-static inline functions are not supported';
|
||||
120: msg := @'inline functions without ''static'' or ''extern'' are not supported';
|
||||
121: msg := @'invalid digit for binary constant';
|
||||
122: msg := @'arithmetic is not allowed on a pointer to an incomplete or function type';
|
||||
123: msg := @'array element type may not be an incomplete or function type';
|
||||
|
@ -23,6 +23,7 @@
|
||||
{1} c99fpcmp.c
|
||||
{1} c99tgmath.c
|
||||
{1} c99pragma.c
|
||||
{1} c99inline.c
|
||||
{1} c11generic.c
|
||||
{1} c11align.c
|
||||
{1} c11noret.c
|
||||
|
33
Tests/Conformance/c99inline.c
Normal file
33
Tests/Conformance/c99inline.c
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Test inline function specifier (C99).
|
||||
*
|
||||
* This only tests "static inline" and "extern inline",
|
||||
* which are the only forms currently supported by ORCA/C.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static inline int f(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int extern g(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int (*p)(void) = f;
|
||||
int (*q)(void) = g;
|
||||
|
||||
if (f() + g() != 3)
|
||||
goto Fail;
|
||||
|
||||
if (p() + q() != 3)
|
||||
goto Fail;
|
||||
|
||||
printf ("Passed Conformance Test c99inline\n");
|
||||
return 0;
|
||||
|
||||
Fail:
|
||||
printf ("Failed Conformance Test c99inline\n");
|
||||
}
|
2
cc.notes
2
cc.notes
@ -451,7 +451,7 @@ The flexible array member does not contribute to the size of the struct as repor
|
||||
|
||||
(Kelvin Sherlock)
|
||||
|
||||
6. (C99) Functions may be declared as "static inline". These have the same semantics as other static functions. The "inline" specifier suggests (but does not require) that calls to the function should be inlined or otherwise optimized. ORCA/C currently does not inline these functions or apply any other special optimizations, but future versions might introduce such features. Note that non-static inline functions are not currently supported.
|
||||
6. (C99) Functions may be declared as "static inline" or "extern inline". These have the same semantics as if "inline" was omitted. The "inline" function specifier suggests (but does not require) that calls to the function should be inlined or otherwise optimized. ORCA/C currently does not inline these functions or apply any other special optimizations, but future versions might introduce such features. Note that inline functions without a "static" or "extern" storage-class specifier are not currently supported.
|
||||
|
||||
7. (Draft C23) Integer constants may be written in binary, with a "0b" or "0B" prefix followed by binary digits. The type of these constants is determined by the same rules as for octal and hexadecimal constants.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user