mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-11-17 05:06:10 +00:00
6ead1d4caf
These are currently only run by the new DOIT3 test-running script. Note that these tests are designed to be applicable to most implementations of C95/C99/C11, not just ORCA/C. They do make certain assumptions not guaranteed by the standards (e.g. power of 2 types and some properties of IEEE-like FP), but in general those assumptions should be true for most 'normal' systems.
59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
/*
|
|
* Test miscellaneous C99 features.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
|
|
/* __STDC_HOSTED__ predefined macro */
|
|
#if !defined(__STDC_HOSTED__) || __STDC_HOSTED__ != 1
|
|
#error "Not a hosted implementation of C99+"
|
|
#endif
|
|
|
|
/* Trailing comma in enums */
|
|
enum {A,B,C,};
|
|
|
|
/* static inline functions */
|
|
inline static int f(void) {
|
|
return C;
|
|
}
|
|
|
|
/* restricted pointers and idempotent type qualifiers */
|
|
void g(char *restrict c1, char * const restrict const c2) {
|
|
*c1 = *c2;
|
|
}
|
|
|
|
int main(void) {
|
|
/* // comments */ char s[] =
|
|
// This is a comment
|
|
"But this is not";
|
|
|
|
if (sizeof s != 16)
|
|
goto Fail;
|
|
|
|
if (f() != 2)
|
|
goto Fail;
|
|
|
|
/* Mixed declarations and statements */
|
|
char c = 'x';
|
|
|
|
/* Declarations in for loops */
|
|
for (int i = 0; i < 256; i++) {
|
|
/* isblank() macro/function */
|
|
if ((_Bool)isblank(i) != (i == ' ' || i == '\t'))
|
|
goto Fail;
|
|
if ((_Bool)(isblank)(i) != (i == ' ' || i == '\t'))
|
|
goto Fail;
|
|
}
|
|
|
|
g(&c,s);
|
|
if (c != 'B')
|
|
goto Fail;
|
|
|
|
printf ("Passed Conformance Test c99misc\n");
|
|
return 0;
|
|
|
|
Fail:
|
|
printf ("Failed Conformance Test c99misc\n");
|
|
}
|