Patchwork C++ PATCH for c++/56177 ( ICE with return type deduction)

login
register
mail settings
Submitter Jason Merrill
Date Feb. 6, 2013, 3:29 a.m.
Message ID <5111CE18.5080503@redhat.com>
Download mbox | patch
Permalink /patch/218481/
State New
Headers show

Comments

Jason Merrill - Feb. 6, 2013, 3:29 a.m.
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.

Patch

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; }