From: Richard Biener Date: Thu, 29 Jun 2023 06:55:39 +0000 (+0200) Subject: c/110454 - ICE with bogus TYPE_PRECISION use X-Git-Tag: basepoints/gcc-15~7958 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d81c7a25365d3cc87e5edad5e68049b149af55b4;p=thirdparty%2Fgcc.git c/110454 - ICE with bogus TYPE_PRECISION use The following sinks TYPE_PRECISION to properly guarded use places. PR c/110454 gcc/c/ * c-typeck.cc (convert_argument): Sink formal_prec compute to where TYPE_PRECISION is valid to use. gcc/testsuite/ * gcc.dg/Wtraditional-conversion-3.c: New testcase. --- diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 22e240a3c2a5..7cf411155c60 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -3385,8 +3385,6 @@ convert_argument (location_t ploc, tree function, tree fundecl, conversions. */ if (warn_traditional_conversion || warn_traditional) { - unsigned int formal_prec = TYPE_PRECISION (type); - if (INTEGRAL_TYPE_P (type) && SCALAR_FLOAT_TYPE_P (valtype)) warning_at (ploc, OPT_Wtraditional_conversion, @@ -3429,6 +3427,8 @@ convert_argument (location_t ploc, tree function, tree fundecl, else if (SCALAR_FLOAT_TYPE_P (type) && SCALAR_FLOAT_TYPE_P (valtype)) { + unsigned int formal_prec = TYPE_PRECISION (type); + /* Warn if any argument is passed as `float', since without a prototype it would be `double'. */ if (formal_prec == TYPE_PRECISION (float_type_node) @@ -3472,6 +3472,7 @@ convert_argument (location_t ploc, tree function, tree fundecl, && INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (valtype)) { + unsigned int formal_prec = TYPE_PRECISION (type); tree would_have_been = default_conversion (val); tree type1 = TREE_TYPE (would_have_been); diff --git a/gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c b/gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c new file mode 100644 index 000000000000..796f2eb88453 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c @@ -0,0 +1,9 @@ +/* { dg-options "-Wtraditional-conversion -Wno-psabi" } */ + +typedef int __attribute__((__vector_size__ (4))) V; + +void +foo (V v) +{ + foo (v); +}