extern variables and object-like macro consts

This commit is contained in:
2026-06-17 21:52:05 +02:00
parent f5605fd3ec
commit 19e9fbdd4b
33 changed files with 3136 additions and 116 deletions
+100
View File
@@ -8,6 +8,15 @@ struct Imported_Handle {
};
static struct Imported_Handle handle = {7};
int imported_global = 0;
const int imported_const_global = 9;
const int imported_const_array[2] = {10, 20};
const Imported_Const_Array imported_typedef_const_array = {11, 12};
int imported_redeclared_array[4] = {13, 14, 15, 16};
Imported_Value imported_record_global = {40};
const Imported_Array_Record imported_const_array_record = {{20, 21}};
Imported_Array_Record imported_mutable_array_record = {{0, 1}};
int child_shared_global = 0;
int child_value(int value) {
return value;
@@ -47,6 +56,97 @@ int imported_apply(Imported_Mapper mapper, int value) {
return result;
}
int imported_check_state(
Imported_Color color,
int macro_value,
int const_value,
int global_value,
int record_value,
int octal_value,
unsigned int uint_value,
int redefined_value,
int inactive_undef_value,
int repeated_value,
unsigned int hex_e_value,
long negative_decimal_value,
unsigned int negative_hex_value,
unsigned int negative_uint_value,
float float_value,
double double_value
) {
if (!(color.r == 255 &&
color.g == 255 &&
color.b == 255 &&
color.a == 255 &&
macro_value == 42 &&
const_value == 9 &&
global_value == 42 &&
record_value == 42 &&
octal_value == 8 &&
uint_value == 4294967295U &&
redefined_value == 2 &&
inactive_undef_value == 77 &&
repeated_value == 123 &&
hex_e_value == 0xDEADBEEF &&
negative_decimal_value == -2147483648L &&
negative_hex_value == 0x80000000U &&
negative_uint_value == 0xFFFFFFFFU &&
float_value == 2.5f &&
double_value == 6.25)) {
abort();
}
return 0;
}
int imported_check_zero_state(
Imported_Color partial,
Imported_Zero_Outer nested,
Imported_Zero_Union first_union
) {
if (!(partial.r == 7 &&
partial.g == 0 &&
partial.b == 0 &&
partial.a == 0 &&
nested.head == 5 &&
nested.inner.weight == 0.0f &&
nested.inner.values[0] == 0 &&
nested.inner.values[1] == 0 &&
nested.inner.label == NULL &&
nested.choice.integer == 0 &&
first_union.integer == 9)) {
abort();
}
return 0;
}
int imported_check_array_record(void) {
if (!(imported_const_array_record.values[0] == 20 &&
imported_const_array_record.values[1] == 21 &&
imported_mutable_array_record.values[0] == 42 &&
imported_mutable_array_record.values[1] == 1)) {
abort();
}
return 0;
}
int imported_check_conversions(Imported_Conversions value) {
if (!(value.wrapped == 255 &&
value.truncated == 3 &&
value.from_integer == 42.0f &&
value.from_float == 16777216.0 &&
value.pointer == NULL)) {
abort();
}
return 0;
}
int imported_check_inline(int scalar, int record) {
if (!(scalar == 6 && record == 14)) {
abort();
}
return 0;
}
int imported_variadic(int marker, ...) {
va_list args;
va_start(args, marker);