From c81116e29a8e2467681da7e1437911657cccb831 Mon Sep 17 00:00:00 2001 From: Petr Skocik Date: Tue, 20 Nov 2018 19:24:24 +0100 Subject: [PATCH] Make casts lose top-level qualifiers TODO: also make them lose lvalue status --- tccgen.c | 1 + tests/tests2/94_generic.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tccgen.c b/tccgen.c index 0d68696..47db9c6 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2660,6 +2660,7 @@ static void gen_cast(CType *type) | (lvalue_type(type->ref->type.t) & VT_LVAL_TYPE); } vtop->type = *type; + vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY ); } /* return type size as known at compile time. Put alignment at 'a' */ diff --git a/tests/tests2/94_generic.c b/tests/tests2/94_generic.c index e5df2a7..78ca912 100644 --- a/tests/tests2/94_generic.c +++ b/tests/tests2/94_generic.c @@ -74,5 +74,8 @@ int main() //should accept ({ }) in the controlling expr of _Generic even in const_wanted contexts struct { _Bool x_0: _Generic(({0;}),default:1); } my_x; + _Generic((__typeof((float const)((float const){42}))*){0}, float*: 0); //casts lose top-level qualifiers + int const x = 42; __typeof((__typeof(x))x) *xp = 0; (void)_Generic(xp, int*: 0); //casts lose top-level qualifiers + return 0; }