public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2181] c/110454 - ICE with bogus TYPE_PRECISION use
@ 2023-06-29  8:13 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-06-29  8:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d81c7a25365d3cc87e5edad5e68049b149af55b4

commit r14-2181-gd81c7a25365d3cc87e5edad5e68049b149af55b4
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jun 29 08:55:39 2023 +0200

    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:
---
 gcc/c/c-typeck.cc                                | 5 +++--
 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 22e240a3c2a..7cf411155c6 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 00000000000..796f2eb8845
--- /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);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-29  8:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29  8:13 [gcc r14-2181] c/110454 - ICE with bogus TYPE_PRECISION use Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).