This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/5713
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 Feb 2002 20:14:11 +0100
- Subject: [PATCH] Fix PR c++/5713
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The testcase below caused ICE in make_decl_rtl (because as both i variables
are merged together after the error, its initializer is expanded before
size variable is expanded).
The following patch seems to work (passed bootstrap/checking too).
2002-02-20 Jakub Jelinek <jakub@redhat.com>
PR c++/5713
* c-decl.c (duplicate_decls): Return 0 if issued error about
redeclaration.
* decl.c (duplicate_decls): Return 0 if issued error about
redeclaration.
* gcc.dg/noncompile/20020220-1.c: New test.
--- gcc/cp/decl.c.jj Mon Feb 18 17:45:11 2002
+++ gcc/cp/decl.c Wed Feb 20 17:27:56 2002
@@ -3344,6 +3344,7 @@ duplicate_decls (newdecl, olddecl)
&& namespace_bindings_p ())
? "`%#D' previously defined here"
: "`%#D' previously declared here", olddecl);
+ return 0;
}
else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_INITIAL (olddecl) != NULL_TREE
--- gcc/c-decl.c.jj Sat Feb 16 21:31:22 2002
+++ gcc/c-decl.c Wed Feb 20 17:26:07 2002
@@ -1690,6 +1690,7 @@ duplicate_decls (newdecl, olddecl, diffe
&& current_binding_level == global_binding_level)
? "`%s' previously defined here"
: "`%s' previously declared here"));
+ return 0;
}
else if (TREE_CODE (newdecl) == TYPE_DECL
&& (DECL_IN_SYSTEM_HEADER (olddecl)
--- gcc/testsuite/gcc.dg/noncompile/20020220-1.c.jj Wed Feb 20 17:35:32 2002
+++ gcc/testsuite/gcc.dg/noncompile/20020220-1.c Wed Feb 20 17:35:28 2002
@@ -0,0 +1,12 @@
+/* PR c++/5713
+ Test that there are no ICEs after redeclaration error. */
+
+int foo (const char*, const char*);
+
+void bar (void)
+{
+ const char *s = "bar";
+ int i; /* { dg-error "previously declared here" } */
+ int size = 2;
+ int i = foo (s, s + size); /* { dg-error "redeclaration of" } */
+}
Jakub