mirror of
git://repo.or.cz/tinycc.git
synced 2026-11-05 05:36:35 +08:00
Previously, TCC wrongly discarded the const and volatile qualifiers from parameter types when adjusting them. - convert_parameter_type() will no longer remove the const and volatile qualifiers from a CType. - a new function, convert_expression_type(), will remove the const and volatile qualifiers before tail-calling convert_parameter_type(). - unary() and gexpr() will call convert_expression_type() instead of convert_parameter_type() to ensure that expression semantics are unchanged. The new tests for restrict also pass, but only because the restrict keyword is ignored.
62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
void pointer_parameters(int *const cp, int *volatile vp, int *restrict rp)
|
|
{
|
|
_Static_assert(_Generic(&cp, int *const *: 1, default: 0),
|
|
"const pointer parameter remains qualified");
|
|
_Static_assert(_Generic(&vp, int *volatile *: 1, default: 0),
|
|
"volatile pointer parameter remains qualified");
|
|
_Static_assert(_Generic(&rp, int *restrict *: 1, default: 0),
|
|
"restrict pointer parameter remains qualified");
|
|
}
|
|
|
|
void declared_const(int *const pointer);
|
|
void declared_const(int *pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int **: 1, default: 0),
|
|
"declaration qualifier does not affect definition");
|
|
pointer = 0;
|
|
}
|
|
|
|
void defined_const(int *pointer);
|
|
void defined_const(int *const pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int *const *: 1, default: 0),
|
|
"definition retains const");
|
|
}
|
|
|
|
void declared_volatile(int *volatile pointer);
|
|
void declared_volatile(int *pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int **: 1, default: 0),
|
|
"declaration qualifier does not affect definition");
|
|
pointer = 0;
|
|
}
|
|
|
|
void defined_volatile(int *pointer);
|
|
void defined_volatile(int *volatile pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int *volatile *: 1, default: 0),
|
|
"definition retains volatile");
|
|
pointer = 0;
|
|
}
|
|
|
|
void declared_restrict(int *restrict pointer);
|
|
void declared_restrict(int *pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int **: 1, default: 0),
|
|
"declaration qualifier does not affect definition");
|
|
pointer = 0;
|
|
}
|
|
|
|
void defined_restrict(int *pointer);
|
|
void defined_restrict(int *restrict pointer)
|
|
{
|
|
_Static_assert(_Generic(&pointer, int *restrict *: 1, default: 0),
|
|
"definition retains restrict");
|
|
pointer = 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
return 0;
|
|
}
|