Message ID | 6a0fd1cd-d933-b66f-1c10-19215db8d942@oracle.com |
---|---|
State | New |
Headers | show |
Series | [C++] PR 68754 ("Explicitly defaulted constexpr assignment operator fails to compile") | expand |
On 09/29/2017 10:04 AM, Paolo Carlini wrote: > Hi, > > the main issue, a C++14 rejects-valid, is already fixed in trunk, and a > while ago I added a testcase for that. However, Andrew noticed that in > C++11 mode we emit redundant and also a bit puzzling diagnostic (ending > with one of those annoying "... because:" and nothing after which > unfortunately we emit in some other cases too). Comparing to, eg, clang > too, I think we can make progress by simply returning early after the > first hard error. Also, as an additional tweak, we might replace the > second error with an inform, per the usual scheme. Tested x86_64-linux. Looks good, thanks. nathan
Index: cp/method.c =================================================================== --- cp/method.c (revision 253283) +++ cp/method.c (working copy) @@ -2191,9 +2191,11 @@ defaulted_late_check (tree fn) || !compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)), TYPE_ARG_TYPES (TREE_TYPE (implicit_fn)))) { - error ("defaulted declaration %q+D", fn); - error_at (DECL_SOURCE_LOCATION (fn), - "does not match expected signature %qD", implicit_fn); + error ("defaulted declaration %q+D does not match the " + "expected signature", fn); + inform (DECL_SOURCE_LOCATION (fn), + "expected signature: %qD", implicit_fn); + return; } if (DECL_DELETED_FN (implicit_fn)) Index: testsuite/g++.dg/cpp0x/constexpr-68754.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-68754.C (revision 253283) +++ testsuite/g++.dg/cpp0x/constexpr-68754.C (working copy) @@ -1,7 +1,7 @@ // PR c++/68754 -// { dg-do compile { target c++14 } } +// { dg-do compile { target c++11 } } struct base { }; struct derived : base { - constexpr derived& operator=(derived const&) = default; + constexpr derived& operator=(derived const&) = default; // { dg-error "defaulted declaration" "" { target { ! c++14 } } } }; Index: testsuite/g++.dg/cpp1y/constexpr-68754.C =================================================================== --- testsuite/g++.dg/cpp1y/constexpr-68754.C (revision 253283) +++ testsuite/g++.dg/cpp1y/constexpr-68754.C (working copy) @@ -1,7 +0,0 @@ -// PR c++/68754 -// { dg-do compile { target c++14 } } - -struct base { }; -struct derived : base { - constexpr derived& operator=(derived const&) = default; -};