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:
Stephen Heumann 2022-10-29 19:27:47 -05:00
parent f54d0e1854
commit f31b5ea1e6
5 changed files with 37 additions and 3 deletions

View File

@ -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

View File

@ -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';

View File

@ -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

View 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");
}

View File

@ -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.