PR c++/47999
* semantics.c (finish_call_expr): Preserve reference semantics
in templates.
From-SVN: r171053
2011-03-16 Jason Merrill <jason@redhat.com>
2011-03-16 Jason Merrill <jason@redhat.com>
+ PR c++/47999
+ * semantics.c (finish_call_expr): Preserve reference semantics
+ in templates.
+
* call.c (convert_default_arg): Use LOOKUP_IMPLICIT.
2011-03-16 Jakub Jelinek <jakub@redhat.com>
* call.c (convert_default_arg): Use LOOKUP_IMPLICIT.
2011-03-16 Jakub Jelinek <jakub@redhat.com>
/* A call where the function is unknown. */
result = cp_build_function_call_vec (fn, args, complain);
/* 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 = 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);
+2011-03-16 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/auto22.C: New.
+
2011-03-16 Richard Guenther <rguenther@suse.de>
* gcc.dg/guality/vla-1.c (main): Use result of f1 to avoid
2011-03-16 Richard Guenther <rguenther@suse.de>
* gcc.dg/guality/vla-1.c (main): Use result of f1 to avoid
--- /dev/null
+// 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;
+}