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]
Other format: [Raw text]

Re: PATCH: Fix middle-end/13448


Mark Mitchell <mark@codesourcery.com> writes:

| Tested on i686-pc-linux-gnu, applied on the mainline and on the 3.4
| branch.

Backported to gcc-3_3-branch.
Bootstrapped and regtested on an i686-pc-linux-gnu.

-- Gaby

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 1.16114.2.933
diff -p -r1.16114.2.933 ChangeLog
*** ChangeLog	12 Mar 2004 20:09:52 -0000	1.16114.2.933
--- ChangeLog	12 Mar 2004 22:39:08 -0000
***************
*** 1,3 ****
--- 1,18 ----
+ 2004-03-12  Gabriel Dos Reis  <gdr@cs.tamu.edu>
+ 
+ 	Backport
+ 	2004-02-27  Mark Mitchell  <mark@codesourcery.com>
+ 	PR middle-end/13448
+ 	* c-tree.h (readonly_warning): Rename to ...
+ 	(readonly_error): ... this.
+ 	* c-typeck.c (build_unary_op): Adjust accordingly.
+ 	(readonly_warning): Rename to ...
+ 	(readonly_error): ... this and issue errors, not warnings.
+ 	(build_modify_expr): Call readonly_error, not readonly_warning.
+ 	(c_expand_asm_operands): Likewise.
+ 	* tree-inline.c (optimize_inline_calls): Do not inline
+ 	functions after errors have occurred.
+ 
  2004-03-12  Philip Blundell  <philb@gnu.org>
  
  	PR target/10730
Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.109
diff -p -r1.109 c-tree.h
*** c-tree.h	16 Sep 2002 18:33:18 -0000	1.109
--- c-tree.h	12 Mar 2004 22:39:08 -0000
*************** extern tree build_external_ref			PARAMS 
*** 270,276 ****
  extern tree parser_build_binary_op              PARAMS ((enum tree_code,
  							 tree, tree));
  extern int c_tree_expr_nonnegative_p          	PARAMS ((tree));
! extern void readonly_warning			PARAMS ((tree, const char *));
  extern tree build_conditional_expr              PARAMS ((tree, tree, tree));
  extern tree build_compound_expr                 PARAMS ((tree));
  extern tree c_cast_expr				PARAMS ((tree, tree));
--- 270,276 ----
  extern tree parser_build_binary_op              PARAMS ((enum tree_code,
  							 tree, tree));
  extern int c_tree_expr_nonnegative_p          	PARAMS ((tree));
! extern void readonly_error			PARAMS ((tree, const char *));
  extern tree build_conditional_expr              PARAMS ((tree, tree, tree));
  extern tree build_compound_expr                 PARAMS ((tree));
  extern tree c_cast_expr				PARAMS ((tree, tree));
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.213.2.12
diff -p -r1.213.2.12 c-typeck.c
*** c-typeck.c	10 Mar 2004 18:37:22 -0000	1.213.2.12
--- c-typeck.c	12 Mar 2004 22:39:12 -0000
*************** build_unary_op (code, xarg, flag)
*** 2968,2977 ****
  
  	/* Report a read-only lvalue.  */
  	if (TREE_READONLY (arg))
! 	  readonly_warning (arg, 
! 			    ((code == PREINCREMENT_EXPR
! 			      || code == POSTINCREMENT_EXPR)
! 			     ? "increment" : "decrement"));
  
  	if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE)
  	  val = boolean_increment (code, arg);
--- 2968,2977 ----
  
  	/* Report a read-only lvalue.  */
  	if (TREE_READONLY (arg))
! 	  readonly_error (arg, 
!                           ((code == PREINCREMENT_EXPR
!                             || code == POSTINCREMENT_EXPR)
!                            ? "increment" : "decrement"));
  
  	if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE)
  	  val = boolean_increment (code, arg);
*************** pedantic_lvalue_warning (code)
*** 3252,3274 ****
  /* Warn about storing in something that is `const'.  */
  
  void
! readonly_warning (arg, msgid)
       tree arg;
       const char *msgid;
  {
    if (TREE_CODE (arg) == COMPONENT_REF)
      {
        if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
! 	readonly_warning (TREE_OPERAND (arg, 0), msgid);
        else
! 	pedwarn ("%s of read-only member `%s'", _(msgid),
! 		 IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1))));
      }
    else if (TREE_CODE (arg) == VAR_DECL)
!     pedwarn ("%s of read-only variable `%s'", _(msgid),
! 	     IDENTIFIER_POINTER (DECL_NAME (arg)));
    else
!     pedwarn ("%s of read-only location", _(msgid));
  }
  
  /* Mark EXP saying that we need to be able to take the
--- 3252,3274 ----
  /* Warn about storing in something that is `const'.  */
  
  void
! readonly_error (arg, msgid)
       tree arg;
       const char *msgid;
  {
    if (TREE_CODE (arg) == COMPONENT_REF)
      {
        if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
! 	readonly_error (TREE_OPERAND (arg, 0), msgid);
        else
! 	error ("%s of read-only member `%s'", _(msgid),
!                IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1))));
      }
    else if (TREE_CODE (arg) == VAR_DECL)
!     error ("%s of read-only variable `%s'", _(msgid),
!            IDENTIFIER_POINTER (DECL_NAME (arg)));
    else
!     error ("%s of read-only location", _(msgid));
  }
  
  /* Mark EXP saying that we need to be able to take the
*************** build_modify_expr (lhs, modifycode, rhs)
*** 3955,3961 ****
        || ((TREE_CODE (lhstype) == RECORD_TYPE
  	   || TREE_CODE (lhstype) == UNION_TYPE)
  	  && C_TYPE_FIELDS_READONLY (lhstype)))
!     readonly_warning (lhs, "assignment");
  
    /* If storing into a structure or union member,
       it has probably been given type `int'.
--- 3955,3961 ----
        || ((TREE_CODE (lhstype) == RECORD_TYPE
  	   || TREE_CODE (lhstype) == UNION_TYPE)
  	  && C_TYPE_FIELDS_READONLY (lhstype)))
!     readonly_error (lhs, "assignment");
  
    /* If storing into a structure or union member,
       it has probably been given type `int'.
*************** c_expand_asm_operands (string, outputs, 
*** 7037,7043 ****
  	      || ((TREE_CODE (type) == RECORD_TYPE
  		   || TREE_CODE (type) == UNION_TYPE)
  		  && C_TYPE_FIELDS_READONLY (type)))
! 	    readonly_warning (o[i], "modification by `asm'");
  	}
      }
  
--- 7037,7043 ----
  	      || ((TREE_CODE (type) == RECORD_TYPE
  		   || TREE_CODE (type) == UNION_TYPE)
  		  && C_TYPE_FIELDS_READONLY (type)))
! 	    readonly_error (o[i], "modification by `asm'");
  	}
      }
  
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.38.2.11
diff -p -r1.38.2.11 tree-inline.c
*** tree-inline.c	23 Jul 2003 07:13:37 -0000	1.38.2.11
--- tree-inline.c	12 Mar 2004 22:39:13 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 35,40 ****
--- 35,41 ----
  #include "hashtab.h"
  #include "splay-tree.h"
  #include "langhooks.h"
+ #include "diagnostic.h"
  
  /* This should be eventually be generalized to other languages, but
     this would require a shared function-as-trees infrastructure.  */
*************** optimize_inline_calls (fn)
*** 1442,1447 ****
--- 1443,1455 ----
    inline_data id;
    tree prev_fn;
  
+ 
+   /* There is no point in performing inlining if errors have already
+      occurred -- and we might crash if we try to inline invalid
+      code.  */
+   if (errorcount || sorrycount)
+     return;
+         
    /* Clear out ID.  */
    memset (&id, 0, sizeof (id));
  


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