diff options
author | Richard Biener <rguenther@suse.de> | 2023-06-29 08:55:39 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-06-29 10:10:44 +0200 |
commit | d81c7a25365d3cc87e5edad5e68049b149af55b4 (patch) | |
tree | 9e7fde02f3ca4c4aff637fe4040fcbfd1e7a8775 /gcc | |
parent | 4e9f6c14280699997a633cefd3fb315b2bd4762c (diff) | |
download | gcc-d81c7a25365d3cc87e5edad5e68049b149af55b4.zip gcc-d81c7a25365d3cc87e5edad5e68049b149af55b4.tar.gz gcc-d81c7a25365d3cc87e5edad5e68049b149af55b4.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/c-typeck.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 22e240a..7cf4111 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 0000000..796f2eb --- /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); +} |