name-lookup.c (check_for_out_of_scope_variable): Avoid ICE by returning when TREE_TYP...
authorRoger Sayle <sayle@gcc.gnu.org>
Sat, 22 May 2004 13:56:19 +0000 (13:56 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 22 May 2004 13:56:19 +0000 (13:56 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/forscope2.C [new file with mode: 0644]

index e4836fdc6502a771281b622a006ec9a7b11ee528..03cc5a86755395a523e191f5a30bdbc0a7ed338d 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-22  Roger Sayle  <roger@eyesopen.com>
+
+       * 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  <pinskia@physics.uc.edu>
 
        * optimize.c (calls_setjmp_r): Remove.
index b3cc1dedc1b327b1e1cf444322636389bab42d8b..388883431890978c6b38a06eff4bf6417c3884f2 100644 (file)
@@ -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",
index 2bfd743e0901b0d70ed03de023c3e67004cda147..3e9c2cf590ec4e3666ef2a20c5dcbf899f6590b8 100644 (file)
@@ -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;
index 95fc70c754e022eb7c66f8541d6d92979abd5df8..13b309c02ffa047d0c997eb4b24b302ac95a2815 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-22  Wolfgang Bangerth  <bangerth@dealii.org>
+           Roger Sayle  <roger@eyesopen.com>
+
+       * g++.dg/lookup/forscope2.C: New test case.
+
 2004-05-22  Ben Elliston  <bje@au.ibm.com>
 
        * 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 (file)
index 0000000..1fed957
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile }
+
+struct S {
+  void foo() {
+     for (_ptr; ;) {}  // { dg-error "not declared" }
+     _ptr = 0;
+    }
+};
+