[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers

2015-05-22 Thread anders at sjogren dot info
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60943

--- Comment #4 from Anders Sjögren anders at sjogren dot info ---
Thanks for fixing the bug!

It seems that the test file
https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/testsuite/g%2B%2B.dg/cpp1y/pr60943.C?view=markuppathrev=223502
contains an error.

It contains:
void Bar (A a)
{
  a.f ();
}

My guess is that it was meant to call the member function from an R-value
object a. However, as an l-value at the site of the call, and both Foo and Bar
will select the l-value version. Something like std::move(a).f() or just
A{}.f(); should do the trick.

[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers

2015-05-22 Thread anders at sjogren dot info
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60943

--- Comment #6 from Anders Sjögren anders at sjogren dot info ---
An alternative test case, which also tests that the correct version is
selected, could be:

#include type_traits

using expected_lvalue_res_t = int;
using expected_rvalue_res_t = double;

struct A {
  auto f()  {return expected_lvalue_res_t{};}
  auto f()  {return expected_rvalue_res_t{};}
};

void lvalue_assert()
{
  A a;
  a.f();
  static_assert(std::is_samedecltype(a.f()),
expected_lvalue_res_t::value,);
}

void rvalue_assert()
{
  A{}.f();
  static_assert(std::is_samedecltype(A{}.f()),
expected_rvalue_res_t::value,);
}

[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers

2015-05-22 Thread anders at sjogren dot info
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60943

--- Comment #5 from Anders Sjögren anders at sjogren dot info ---
A typo snuck in...
However, as an l-value at the site of the call[...]
should be
However, a is an l-value at the site of the call[...]

[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers

2015-05-21 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60943

Nathan Sidwell nathan at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Nathan Sidwell nathan at gcc dot gnu.org ---
Propagate ref qualifier to new function type.


[Bug c++/60943] [C++14] Return type deduction interferes with ref-qualifiers

2015-05-21 Thread nathan at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60943

--- Comment #2 from Nathan Sidwell nathan at gcc dot gnu.org ---
Author: nathan
Date: Thu May 21 20:50:45 2015
New Revision: 223502

URL: https://gcc.gnu.org/viewcvs?rev=223502root=gccview=rev
Log:
cp/
PR c++/60943
* decl2.c (change_return_type): Propagate FUNCTION_REF_QUALIFIED.

testsuite/
* g++.dg/cpp1y/pr60943.C: New.

Added:
trunk/gcc/testsuite/g++.dg/cpp1y/pr60943.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl2.c
trunk/gcc/testsuite/ChangeLog