mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-11-17 05:06:10 +00:00
3f450bdb80
This is a minimal implementation that does not actually inline anything, but it is intended to implement the semantics defined by the C99 and later standards. One complication is that a declaration that appears somewhere after the function body may create an external definition for a function that appeared to be an inline definition when it was defined. To support this while preserving ORCA/C's general one-pass compilation strategy, we generate code even for inline definitions, but treat them as private and add the prefix "~inline~" to the name. If they are "un-inlined" based on a later declaration, we generate a stub with external linkage that just jumps to the apparently-inline function.
43 lines
712 B
C
43 lines
712 B
C
/*
|
|
* Test inline function specifier (C99).
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
static inline int f(void) {
|
|
return 1;
|
|
}
|
|
|
|
inline int extern g(void) {
|
|
return 2;
|
|
}
|
|
|
|
inline int h(int i) {
|
|
return i+5;
|
|
}
|
|
|
|
int main(void) {
|
|
int (*p)(void) = f;
|
|
int (*q)(void) = g;
|
|
int (*r)(int) = h;
|
|
|
|
if (f() + g() != 3)
|
|
goto Fail;
|
|
|
|
if (p() + q() != 3)
|
|
goto Fail;
|
|
|
|
if (h(2) != 7)
|
|
goto Fail;
|
|
if (r(23) != 28)
|
|
goto Fail;
|
|
|
|
printf ("Passed Conformance Test c99inline\n");
|
|
return 0;
|
|
|
|
Fail:
|
|
printf ("Failed Conformance Test c99inline\n");
|
|
}
|
|
|
|
extern inline int h(int i);
|