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

The following sinks TYPE_PRECISION to properly guarded use places.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed as
obvious.

	PR c/110454
gcc/c/
	* c-typeck.cc (convert_argument): Sink formal_prec compute
	to where TYPE_PRECISION is valid to use.

	* gcc.dg/Wtraditional-conversion-3.c: New testcase.
---
 gcc/c/c-typeck.cc                                | 5 +++--
 gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/Wtraditional-conversion-3.c

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);
+}
-- 
2.35.3

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

only message in thread, other threads:[~2023-06-29  8:12 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:12 [PATCH] 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).