re PR c++/13663 (gcc segfaults on invalid use of member)
authorMark Mitchell <mark@codesourcery.com>
Mon, 26 Jan 2004 20:11:46 +0000 (20:11 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 26 Jan 2004 20:11:46 +0000 (20:11 +0000)
PR c++/13663
* semantics.c (finish_for_expr): Check for unresolved overloaded
functions.

PR c++/13363
* g++.dg/expr/for1.C: New test.

From-SVN: r76659

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/for1.C [new file with mode: 0644]

index 917457b18046da9297af2789592b6575e6ddb4f5..a6248b68735f69a140a69afcc0d2de605d07128a 100644 (file)
@@ -1,5 +1,9 @@
 2004-01-26  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13663
+       * semantics.c (finish_for_expr): Check for unresolved overloaded
+       functions.
+
        * class.c (add_method): Just check processing_template_decl to
        determine whether or not we are within a template.
        * decl2.c (maybe_retrofit_in_chrg): Likewise.
index 69364d8f673825e4a0d968fbb27db7fdd3f93301..deb5b820ed4a317d06494a1a814f69a4e422daa3 100644 (file)
@@ -678,6 +678,13 @@ finish_for_cond (tree cond, tree for_stmt)
 void
 finish_for_expr (tree expr, tree for_stmt)
 {
+  /* If EXPR is an overloaded function, issue an error; there is no
+     context available to use to perform overload resolution.  */
+  if (expr && type_unknown_p (expr))
+    {
+      cxx_incomplete_type_error (expr, TREE_TYPE (expr));
+      expr = error_mark_node;
+    }
   FOR_EXPR (for_stmt) = expr;
 }
 
index 5618d1de3c450cfbf712671707e4397920d42f74..3d25f199c21686def1555db4a868bd42decd8165 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-26  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13363
+       * g++.dg/expr/for1.C: New test.
+
 2004-01-26  Fariborz Jahanian <fjahanian@apple.com>
 
        PR middle-end/13779
diff --git a/gcc/testsuite/g++.dg/expr/for1.C b/gcc/testsuite/g++.dg/expr/for1.C
new file mode 100644 (file)
index 0000000..baffd42
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/13663
+
+struct S {
+  void f();
+};
+
+void g(int);
+void g(double);
+
+void h () {
+  S s;
+  for (;;s.f); // { dg-error "" }
+  for (;;g); // { dg-error "" }
+}