public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Diego Novillo <dnovillo@google.com>
Cc: gcc-patches@gcc.gnu.org
Subject: PATCH to copy_statement_list for c++/47999 (ICE in testsuite on darwin)
Date: Mon, 16 May 2011 17:00:00 -0000	[thread overview]
Message-ID: <4DD13685.2010705@redhat.com> (raw)
In-Reply-To: <4DC0470D.9090303@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

On 05/03/2011 02:18 PM, Jason Merrill wrote:
> I also removed the recursion from copy_statement_list because it
> would just extra garbage STATEMENT_LISTs since they're already copied by
> the normal walk_tree.

I was wrong about this, the recursion is necessary because 
tsi_link_after destroys STATEMENT_LISTs.

Applying as obvious since it just restores code I removed before.

[-- Attachment #2: 47999.patch --]
[-- Type: text/x-patch, Size: 1674 bytes --]

commit 79330512f8ade4ecff47ab8cb8c050440d9648e0
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 8 08:46:41 2011 -0500

    	PR c++/47999
    	* semantics.c (finish_call_expr): Preserve reference semantics
    	in templates.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 53497f3..ce24d46 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2150,11 +2150,17 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
     /* A call where the function is unknown.  */
     result = cp_build_function_call_vec (fn, args, complain);
 
-  if (processing_template_decl)
+  if (processing_template_decl && result != error_mark_node)
     {
+      if (TREE_CODE (result) == INDIRECT_REF)
+	result = TREE_OPERAND (result, 0);
+      gcc_assert (TREE_CODE (result) == CALL_EXPR
+		  || TREE_CODE (fn) == PSEUDO_DTOR_EXPR
+		  || errorcount);
       result = build_call_vec (TREE_TYPE (result), orig_fn, orig_args);
       KOENIG_LOOKUP_P (result) = koenig_p;
       release_tree_vector (orig_args);
+      result = convert_from_reference (result);
     }
 
   return result;
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto22.C b/gcc/testsuite/g++.dg/cpp0x/auto22.C
new file mode 100644
index 0000000..66630e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto22.C
@@ -0,0 +1,21 @@
+// PR c++/47999
+// { dg-options -std=c++0x }
+
+int& identity(int& i)
+{
+  return i;
+}
+
+// In a function template, auto type deduction works incorrectly.
+template <typename = void>
+void f()
+{
+  int i = 0;
+  auto&& x = identity(i); // Type of x should be `int&`, but it is `int&&`.
+}
+
+int main (int argc, char* argv[])
+{
+  f();
+  return 0;
+}

  reply	other threads:[~2011-05-16 14:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 21:58 C++ PATCHes relating to c++/48834, c++/40975 (array new) Jason Merrill
2011-05-02 22:23 ` Eric Botcazou
2011-05-03  5:05   ` Jason Merrill
2011-05-03  7:01     ` Eric Botcazou
2011-05-03 15:27       ` Jason Merrill
2011-05-03 15:53         ` Eric Botcazou
2011-05-03 17:29           ` Jason Merrill
2011-05-03 18:32             ` RFA " Jason Merrill
2011-05-16 17:00               ` Jason Merrill [this message]
2011-05-04  8:15             ` Eric Botcazou
2011-05-04 15:49               ` Jason Merrill
2011-05-04 23:31                 ` Eric Botcazou
2011-05-05 14:24                   ` copy_tree_r and STATEMENT_LIST (was Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)) Jason Merrill
2011-05-05 16:42                     ` Richard Henderson
2011-05-07 19:52                     ` Eric Botcazou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DD13685.2010705@redhat.com \
    --to=jason@redhat.com \
    --cc=dnovillo@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).