This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Unreviewed patch [-Wlarger-than-]


This is fairly harmless - it only touches -Wlarger-than stuff - and
fixes PR 602.

-Wlarger-than with a void function segfaults with CVS GCC.

I've been bootstrapping with it for over a week.  OK to commit this
patch and test case?

Neil.

	* c-decl.c (c_expand_body): Check TYPE_SIZE_UNIT (ret_type)
	is not NULL.
	* toplev.c (decode_W_option): Update warn_larger_than
	unconditionally for each processed switch.
	* testsuite/gcc.dg/Wlarger-than.c: New test.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.202
diff -u -p -r1.202 c-decl.c
--- c-decl.c	2001/01/13 12:34:01	1.202
+++ c-decl.c	2001/01/21 17:27:52
@@ -6723,7 +6723,8 @@ c_expand_body (fndecl, nested_p)
     {
       tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
 
-      if (ret_type && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
+      if (ret_type && TYPE_SIZE_UNIT (ret_type)
+	  && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
 	  && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
 				   larger_than_size))
 	{
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.417
diff -u -p -r1.417 toplev.c
--- toplev.c	2001/01/15 22:45:32	1.417
+++ toplev.c	2001/01/21 17:28:07
@@ -4171,8 +4171,7 @@ decode_W_option (arg)
     {
       larger_than_size = read_integral_parameter (option_value, arg - 2, -1);
 
-      if (larger_than_size != -1)
-	warn_larger_than = 1;
+      warn_larger_than = larger_than_size != -1;
     }
   else if (!strcmp (arg, "unused"))
     {
Index: testsuite/gcc.dg/Wlarger-than.c
===================================================================
RCS file: Wlarger-than.c
diff -N Wlarger-than.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ Wlarger-than.c	Sun Jan 21 09:28:07 2001
@@ -0,0 +1,10 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.  */
+
+/* { dg-do compile } */
+/* { dg-options "-Wlarger-than-32768" } */
+
+/* -Wlarger-than with functions returning void used to segfault.
+   Source: PR 602, testsuite-ized by Neil Booth 21 Jan 2000.  */
+
+static void foo (void) {}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]