mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-11-19 03:07:00 +00:00
102d6873a3
This was non-standard in various ways, mainly in regard to pointer types. It has been rewritten to closely follow the specification in the C standards. Several helper functions dealing with types have been introduced. They are currently only used for ? :, but they might also be useful for other purposes. New tests are also introduced to check the behavior for the ? : operator. This fixes #35 (including the initializer-specific case).
28 lines
734 B
C++
28 lines
734 B
C++
/* Deviance Test 7.8.0.1: Ensure invalid operand types for ?: are detected */
|
|
|
|
int printf(const char *, ...);
|
|
|
|
int main(void) {
|
|
int i = 1;
|
|
struct S {int i;} s = {4};
|
|
int *ip = &i;
|
|
long *lp = 0;
|
|
const int *cip = &i;
|
|
|
|
/* each statement below should give an error */
|
|
1 ? i : s;
|
|
1 ? s : i;
|
|
1 ? i : (void)0;
|
|
1 ? ip : lp;
|
|
|
|
/* these are illegal in standard C, but allowed by loose type checks */
|
|
#pragma ignore 24
|
|
1 ? main : (void*)(void*)0;
|
|
1 ? &ip : &cip;
|
|
|
|
/* should give an error, but currently does not in ORCA/C */
|
|
1 ? cip : (char)+0.0;
|
|
|
|
printf ("Failed Deviance Test 7.8.0.1\n");
|
|
}
|