From: Gabriel Dos Reis Date: Fri, 12 Mar 2004 22:43:29 +0000 (+0000) Subject: backport: re PR middle-end/13448 (gcc 3.3.2, internal error when -O3 and trying to... X-Git-Tag: releases/gcc-3.3.4~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=694b9c55ca755bdb094893509c21cf661bf8c279;p=thirdparty%2Fgcc.git backport: re PR middle-end/13448 (gcc 3.3.2, internal error when -O3 and trying to modify function const arg) Backport 2004-02-27 Mark Mitchell 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. From-SVN: r79409 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 41e9e8128528..267d953a1c83 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2004-03-12 Gabriel Dos Reis + + Backport + 2004-02-27 Mark Mitchell + 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 PR target/10730 diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 159c235224e2..1e7b3cc061a9 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -270,7 +270,7 @@ extern tree build_external_ref PARAMS ((tree, int)); 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 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)); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 25731f716ebe..e50ce5b100ae 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2968,10 +2968,10 @@ build_unary_op (code, xarg, flag) /* Report a read-only lvalue. */ if (TREE_READONLY (arg)) - readonly_warning (arg, - ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement")); + readonly_error (arg, + ((code == PREINCREMENT_EXPR + || code == POSTINCREMENT_EXPR) + ? "increment" : "decrement")); if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE) val = boolean_increment (code, arg); @@ -3252,23 +3252,23 @@ pedantic_lvalue_warning (code) /* Warn about storing in something that is `const'. */ void -readonly_warning (arg, msgid) +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_warning (TREE_OPERAND (arg, 0), msgid); + readonly_error (TREE_OPERAND (arg, 0), msgid); else - pedwarn ("%s of read-only member `%s'", _(msgid), - IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (arg, 1)))); + error ("%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))); + error ("%s of read-only variable `%s'", _(msgid), + IDENTIFIER_POINTER (DECL_NAME (arg))); else - pedwarn ("%s of read-only location", _(msgid)); + error ("%s of read-only location", _(msgid)); } /* Mark EXP saying that we need to be able to take the @@ -3955,7 +3955,7 @@ build_modify_expr (lhs, modifycode, rhs) || ((TREE_CODE (lhstype) == RECORD_TYPE || TREE_CODE (lhstype) == UNION_TYPE) && C_TYPE_FIELDS_READONLY (lhstype))) - readonly_warning (lhs, "assignment"); + readonly_error (lhs, "assignment"); /* If storing into a structure or union member, it has probably been given type `int'. @@ -7037,7 +7037,7 @@ c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line) || ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE) && C_TYPE_FIELDS_READONLY (type))) - readonly_warning (o[i], "modification by `asm'"); + readonly_error (o[i], "modification by `asm'"); } } diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 4dc7e67f5faf..43d35c3843de 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -35,6 +35,7 @@ Boston, MA 02111-1307, USA. */ #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. */ @@ -1442,6 +1443,13 @@ optimize_inline_calls (fn) 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));