From: Gabriel Dos Reis Date: Mon, 10 Nov 2003 08:32:16 +0000 (+0000) Subject: re PR c++/12832 (ICE: tree check: expected class 'd', have 'x' (error_mark) in locati... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64323f62a668e5e88d0efae2eec9165d0d4fb8da;p=platform%2Fupstream%2Fgcc.git re PR c++/12832 (ICE: tree check: expected class 'd', have 'x' (error_mark) in location_of, at cp/error.c:1962) PR c++/12832 * name-lookup.c (supplement_binding): Gracefully handle names used at non-class scope prior declaration. From-SVN: r73406 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f83578..a8fedc8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-11-10 Gabriel Dos Reis + + PR c++/12832 + * name-lookup.c (supplement_binding): Gracefully handle names + used at non-class scope prior declaration. + 2003-11-06 Matt Austern * decl.c (duplicate_decls): copy DECL_VISIBILITY field. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index add0d55..624e86e 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -435,10 +435,13 @@ supplement_binding (cxx_binding *binding, tree decl) if (TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl)) /* The new name is the type name. */ binding->type = decl; - else if (!bval) - /* This situation arises when push_class_level_binding moves an - inherited type-binding out of the way to make room for a new - value binding. */ + else if (!bval || bval == error_mark_node) + /* VALUE is null when push_class_level_binding moves an inherited + type-binding out of the way to make room for a new value binding. + It is an error_mark_node when DECL's name has been used in a + non-class scope prior declaration. In that case, we should have + already issued a diagnostic; for graceful error recovery purpose, + pretend this was the intended declaration for that name. */ binding->value = decl; else if (TREE_CODE (bval) == TYPE_DECL && DECL_ARTIFICIAL (bval)) { diff --git a/gcc/testsuite/g++.dg/lookup/used-before-declaration.C b/gcc/testsuite/g++.dg/lookup/used-before-declaration.C new file mode 100644 index 0000000..c1469ea --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/used-before-declaration.C @@ -0,0 +1,5 @@ +// Copyroght (C) 2003 Free Software Foundation +// Origin: PR/12832, Jonathan Wakely + +void f() { g(); } // { dg-error "undeclared" "" } +void g() { } // { dg-error "used" "" }