[PATCH] Avoid segfaulting in {start,finish}_decl
mark@codesourcery.com
mark@codesourcery.com
Fri Oct 20 15:23:00 GMT 2000
OK.
I think the right fix for these kinds of problems, eventually,
is to create type-safe error_mark_nodes; error_type,
error_decl, etc.
Then, the usual macros could still work on these nodes,
which would make the compiler a lot more robust, and easier
to maintain.
Another problem is that there is no good convention
about when error_mark_node is used vs. when NULL_TREE is
used. (Some functions return one on error; others return
the other.) Some day...
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
----- Original Message -----
Sent : 10/20/00 2:46 PM
>From : Jakub Jelinek <jakub@redhat.com>
To : gcc-patches@gcc.gnu.org
Subject: [PATCH] Avoid segfaulting in {start,finish}_decl
> Hi!
> This patch avoids segfaulting on the enclosed testcase (and gives the same
> error messages for it as egcs 1.1.2).
> Ok to commit?
> 2000-10-20 Jakub Jelinek <jakub@redhat.com>
> * c-decl.c (start_decl): Don't segfault if TREE_TYPE is error_mark.
> (finish_decl): Likewise.
> * gcc.dg/noncompile/init-3.c: New test.
> --- gcc/c-decl.c.jj Thu Oct 19 08:30:49 2000
> +++ gcc/c-decl.c Fri Oct 20 23:21:08 2000
> @@ -3506,7 +3506,8 @@ start_decl (declarator, declspecs, initi
> default:
> /* Don't allow initializations for incomplete types
> except for arrays which might be completed by the initialization. */
> - if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
> + if (TREE_CODE (TREE_TYPE (decl)) != ERROR_MARK
> + && COMPLETE_TYPE_P (TREE_TYPE (decl)))
> {
> /* A complete type is ok if size is fixed. */
>
> @@ -3677,7 +3678,8 @@ finish_decl (decl, init, asmspec_tree)
> layout_decl (decl, 0);
> }
>
> - if (TREE_CODE (decl) == VAR_DECL)
> + if (TREE_CODE (decl) == VAR_DECL
> + && TREE_CODE (TREE_TYPE (decl)) != ERROR_MARK)
> {
> if (DECL_SIZE (decl) == 0 && COMPLETE_TYPE_P (TREE_TYPE (decl)))
> layout_decl (decl, 0);
> --- gcc/testsuite/gcc.dg/noncompile/init-3.c.jj Fri Oct 20 23:38:01 2000
> +++ gcc/testsuite/gcc.dg/noncompile/init-3.c Fri Oct 20 23:37:57 2000
> @@ -0,0 +1,4 @@
> +void die(void)
> +{
> + char foo[BAR] = "1234"; /* { dg-error "undeclared|function|incomplete type" } */
> +}
> Jakub
____________________________________________________
Get MORE than just FREE e-mail. Get a private Web office.
Organize your team with FREE communication and
collaboration tools from HotOffice(R) at www.hotoffice.com.
More information about the Gcc-patches
mailing list