From: Roger Sayle Date: Sat, 22 May 2004 13:56:19 +0000 (+0000) Subject: name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by returning when TREE_TYP... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae5cbc332f60a4f9bcca56c4739410c9b2d3abf9;p=gcc.git name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by returning when TREE_TYPE is error_mark_node. * name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by returning when TREE_TYPE is error_mark_node. * typeck.c (require_complete_type): Return error_mark_node if value's type is an error_mark_node. * g++.dg/lookup/forscope2.C: New test case. From-SVN: r82133 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e4836fdc650..03cc5a86755 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2004-05-22 Roger Sayle + + * name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by + returning when TREE_TYPE is error_mark_node. + * typeck.c (require_complete_type): Return error_mark_node if + value's type is an error_mark_node. + 2005-05-20 Andrew Pinski * optimize.c (calls_setjmp_r): Remove. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b3cc1dedc1b..38888343189 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1151,6 +1151,10 @@ check_for_out_of_scope_variable (tree decl) return decl; DECL_ERROR_REPORTED (decl) = 1; + + if (TREE_TYPE (decl) == error_mark_node) + return decl; + if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) { error ("name lookup of `%D' changed for new ISO `for' scoping", diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 2bfd743e090..3e9c2cf590e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -96,6 +96,9 @@ require_complete_type (tree value) else type = TREE_TYPE (value); + if (type == error_mark_node) + return error_mark_node; + /* First, detect a valid value with a complete type. */ if (COMPLETE_TYPE_P (type)) return value; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95fc70c754e..13b309c02ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-05-22 Wolfgang Bangerth + Roger Sayle + + * g++.dg/lookup/forscope2.C: New test case. + 2004-05-22 Ben Elliston * gcc.dg/cpp/Wmissingdirs.c: New. diff --git a/gcc/testsuite/g++.dg/lookup/forscope2.C b/gcc/testsuite/g++.dg/lookup/forscope2.C new file mode 100644 index 00000000000..1fed957a041 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/forscope2.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +struct S { + void foo() { + for (_ptr; ;) {} // { dg-error "not declared" } + _ptr = 0; + } +}; +