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++/56177 ( ICE with return type deduction)


When we start processing a function and find that it was declared previously, we use the old declaration. In that case we should use the old version of the return type, as well.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3589139ea249533cc5ebb5ef9c38d72fc159f6fd
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 5 14:40:56 2013 -0500

    	PR c++/56177
    	* decl.c (start_preparsed_function): Update restype if we change
    	decl1.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 9b40018..cfee0f8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13116,6 +13116,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
 	    DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1));
 	}
       fntype = TREE_TYPE (decl1);
+      restype = TREE_TYPE (fntype);
 
       /* If #pragma weak applies, mark the decl appropriately now.
 	 The pragma only applies to global functions.  Because
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C
new file mode 100644
index 0000000..e7e8699
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn14.C
@@ -0,0 +1,5 @@
+// PR c++/56177
+// { dg-options "-std=c++1y" }
+
+auto f ();
+auto f () { return 33; }

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