* 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.
PR middle-end/13448
* gcc.dg/inline-5.c: New test.
* gcc.dg/always-inline.c: Split out tests into ...
* gcc.dg/always-inline2.c: ... this and ...
* gcc.dg/always-inline3.c: ... this.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78682
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-02-29 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-02-29 Nathanael Nerode <neroden@gcc.gnu.org>
* configure.ac: Rearrange some threading code for clarity;
extern tree build_external_ref (tree, int);
extern tree parser_build_binary_op (enum tree_code, tree, tree);
extern int c_tree_expr_nonnegative_p (tree);
-extern void readonly_warning (tree, const char *);
+extern void readonly_error (tree, const char *);
extern tree build_conditional_expr (tree, tree, tree);
extern tree build_compound_expr (tree);
extern tree c_cast_expr (tree, tree);
/* 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);
/* Warn about storing in something that is `const'. */
void
-readonly_warning (tree arg, const char *msgid)
+readonly_error (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));
}
\f
/* Mark EXP saying that we need to be able to take the
|| ((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'.
|| ((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'");
}
}
2004-02-29 Mark Mitchell <mark@codesourcery.com>
+ PR middle-end/13448
+ * gcc.dg/inline-5.c: New test.
+ * gcc.dg/always-inline.c: Split out tests into ...
+ * gcc.dg/always-inline2.c: ... this and ...
+ * gcc.dg/always-inline3.c: ... this.
+
+2004-02-29 Mark Mitchell <mark@codesourcery.com>
+
PR debug/12103
* g++.dg/debug/crash1.C: New test.
/* { dg-do compile } */
/* { dg-options "-Winline -O2" } */
#include <stdarg.h>
-inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" "" } */
-void
-q(void)
-{
- t(); /* { dg-error "called from here" "" } */
-}
-inline __attribute__ ((always_inline)) void
-q2(void)
-{ /* { dg-error "recursive" "" } */
- q2(); /* { dg-error "called from here" "" } */
- q2(); /* { dg-error "called from here" "" } */
-}
inline __attribute__ ((always_inline)) void
e(int t, ...)
{ /* { dg-error "variable argument" "" } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Winline -O2" } */
+inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" "" } */
+void
+q(void)
+{
+ t(); /* { dg-error "called from here" "" } */
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Winline -O2" } */
+inline __attribute__ ((always_inline)) void
+q2(void)
+{ /* { dg-error "recursive" "" } */
+ q2(); /* { dg-error "called from here" "" } */
+ q2(); /* { dg-error "called from here" "" } */
+}
--- /dev/null
+/* PR middle-end/13448 */
+
+/* { dg-options "-O3" } */
+
+void funct (const int n)
+{
+ n++; /* { dg-error "" } */
+}
+
+int main () {
+ funct (1);
+ return 0;
+}
#include "langhooks.h"
#include "cgraph.h"
#include "intl.h"
-
+#include "diagnostic.h"
/* This should be eventually be generalized to other languages, but
this would require a shared function-as-trees infrastructure. */
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));