This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/42701 (ice after error with ill-formed constructor call)


I'm not sure why I thought i could free the argument vector at that point.

Tested x86_64-pc-linux-gnu, applied to trunk.

commit 69fb794b0f5791da6b989bdd8ea1277e7f6ac41b
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 14 17:06:11 2010 -0500

    	PR c++/42701
    	* call.c (build_new_method_call): Don't free the vec here.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 935aea8..54254c3 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6256,11 +6256,10 @@ build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args,
       permerror (input_location,
 		 "cannot call constructor %<%T::%D%> directly",
 		 basetype, name);
-      inform (input_location, "for a function-style cast, remove the "
-	      "redundant %<::%D%>", name);
+      permerror (input_location, "  for a function-style cast, remove the "
+		 "redundant %<::%D%>", name);
       call = build_functional_cast (basetype, build_tree_list_vec (user_args),
 				    complain);
-      release_tree_vector (user_args);
       return call;
     }
 
diff --git a/gcc/testsuite/g++.dg/overload/error3.C b/gcc/testsuite/g++.dg/overload/error3.C
new file mode 100644
index 0000000..e0003dd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/error3.C
@@ -0,0 +1,41 @@
+// PR c++/42701
+// Test for error-recovery on code that is ill-formed by DR 147.
+
+namespace Glib {
+    class ustring {
+    public:
+        typedef unsigned size_type;
+        ustring(const char* src, size_type n);
+        ustring(const char* src);
+    };
+}
+namespace Gdk {
+    class Color {
+    public:
+        explicit Color(const Glib::ustring& value);
+    };
+}
+namespace Gtk {
+    enum StateType { STATE_NORMAL };
+    class Widget   {
+    public:
+        void modify_bg(StateType state, const Gdk::Color& color);
+    };
+    class Label {
+    public:
+        void set_text(const Glib::ustring &str);
+    };
+}
+typedef enum Result { eSuccess = 0 } Result;
+class MainWindow  {
+    void update_status(Result result);
+    Gtk::Widget status_frame;
+    Gtk::Label status_label;
+};
+void MainWindow::update_status(Result result) {
+    switch (result) {
+        status_frame.modify_bg(Gtk::STATE_NORMAL,Gdk::Color::Color("green")); // { dg-error "" }
+        status_frame.modify_bg(Gtk::STATE_NORMAL,Gdk::Color::Color("red")); // { dg-error "" }
+        status_label.set_text("Out of memory");
+    }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]