Sorry, I used the wrong e-mail address for Joseph. On Wed, Jun 26, 2024 at 11:09:37AM -0400, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > -- >8 -- > Here we ICE in c_expr_sizeof_expr on an erroneous expr.value. The > code checks for expr.value == error_mark_node but here the e_m_n is > wrapped in a C_MAYBE_CONST_EXPR. I don't think we should have created > such a tree, so let's return earlier in c_cast_expr. > > PR c/115642 > > gcc/c/ChangeLog: > > * c-typeck.cc (c_cast_expr): Return error_mark_node if build_c_cast > failed. > > gcc/testsuite/ChangeLog: > > * gcc.dg/noncompile/sizeof-1.c: New test. > --- > gcc/c/c-typeck.cc | 3 +++ > gcc/testsuite/gcc.dg/noncompile/sizeof-1.c | 7 +++++++ > 2 files changed, 10 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/noncompile/sizeof-1.c > > diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc > index ffcab7df4d3..8c03a7731c4 100644 > --- a/gcc/c/c-typeck.cc > +++ b/gcc/c/c-typeck.cc > @@ -6695,6 +6695,9 @@ c_cast_expr (location_t loc, struct c_type_name > *type_name, tree expr) > return error_mark_node; > > ret = build_c_cast (loc, type, expr); > + if (ret == error_mark_node) > + return error_mark_node; > + > if (type_expr) > { > bool inner_expr_const = true; > diff --git a/gcc/testsuite/gcc.dg/noncompile/sizeof-1.c > b/gcc/testsuite/gcc.dg/noncompile/sizeof-1.c > new file mode 100644 > index 00000000000..db7e2044b11 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/noncompile/sizeof-1.c > @@ -0,0 +1,7 @@ > +/* PR c/115642 */ > +/* { dg-do compile } */ > + > +void f (int N) { > + int a[2][N]; > + sizeof ((int [2][N])a); /* { dg-error "cast specifies array type" } */ > +} > > base-commit: 47b68cda2c4afe32e84c5f18da0196c39e5e0edf > -- > 2.45.2 >
Marek