This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix test-suite fallout of default -Wreturn-type.
- From: Jason Merrill <jason at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>
- Cc: Jakub Jelinek <jakub at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, Jonathan Wakely <jwakely at redhat dot com>
- Date: Fri, 3 Nov 2017 11:29:35 -0400
- Subject: Re: [PATCH] Fix test-suite fallout of default -Wreturn-type.
- Authentication-results: sourceware.org; auth=none
- References: <31ddd79e-1152-9dd9-663b-acd8d1bcd4ab@suse.cz> <CADzB+2=fe6aDbFM3W3_=xog_VZh2iV1jR6dyBHEuu25-ttn5uw@mail.gmail.com> <a5543eb7-6774-a58a-38e7-33d3edf23fa2@suse.cz> <CADzB+2koi_th-P6S6=91NeA41LJoqPNk9GVWZP9Oq5PdQd6FtQ@mail.gmail.com> <a20e5418-a0af-d235-721b-9869c50f963a@suse.cz> <20171012084834.GS14653@tucnak> <92e13852-7395-94ea-9aa3-ea2be6dadb5b@suse.cz> <90831769-0a57-f556-0c90-2ca8e9ce8dac@redhat.com> <087b9e2a-6eb5-eb37-6788-9810243afe32@suse.cz>
On Thu, Oct 26, 2017 at 8:14 AM, Martin Liška <mliska@suse.cz> wrote:
> On 10/24/2017 04:39 PM, Jason Merrill wrote:
>> On 10/18/2017 08:48 AM, Martin Liška wrote:
>>> This is second patch that addresses test-suite fallout. All these tests fail because -Wreturn-type is
>>> now on by default.
>>
>>> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C
>>> -constexpr T g(T t) { return f(t); } // { dg-error "f.int" }
>>> +constexpr T g(T t) { return f(t); } // { dg-error "f.int" "" { target c++14_only } }
>>
>>> +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C
>>> - constexpr int bar() { return a.foo(); } // { dg-error "foo" }
>>> + constexpr int bar() { return a.foo(); } // { dg-error "foo" "" { target c++14_only } }
>>
>> Why are these changes needed? They aren't "Return a value for functions with non-void return type, or change type to void, or add -Wno-return-type for test."
>>
>> The rest of the patch is OK.
>>
>> Jason
>
> Hi.
>
> Sorry, I forgot to describe this change. With -std=c++11 we do:
>
> #0 massage_constexpr_body (fun=0x7ffff6955500, body=0x7ffff6813eb8) at ../../gcc/cp/constexpr.c:708
> #1 0x000000000087700b in explain_invalid_constexpr_fn (fun=0x7ffff6955500) at ../../gcc/cp/constexpr.c:896
> #2 0x00000000008799dc in cxx_eval_call_expression (ctx=0x7fffffffd150, t=0x7ffff6820118, lval=false, non_constant_p=0x7fffffffd1cf, overflow_p=0x7fffffffd1ce) at ../../gcc/cp/constexpr.c:1558
> #3 0x00000000008843fe in cxx_eval_constant_expression (ctx=0x7fffffffd150, t=0x7ffff6820118, lval=false, non_constant_p=0x7fffffffd1cf, overflow_p=0x7fffffffd1ce, jump_target=0x0) at ../../gcc/cp/constexpr.c:4069
>
> static tree
> massage_constexpr_body (tree fun, tree body)
> {
> if (DECL_CONSTRUCTOR_P (fun))
> body = build_constexpr_constructor_member_initializers
> (DECL_CONTEXT (fun), body);
> else if (cxx_dialect < cxx14)
> {
> if (TREE_CODE (body) == EH_SPEC_BLOCK)
> body = EH_SPEC_STMTS (body);
> if (TREE_CODE (body) == MUST_NOT_THROW_EXPR)
> body = TREE_OPERAND (body, 0);
> body = constexpr_fn_retval (body);
> }
> return body;
> }
>
> and we end up with error_mark_node and thus potential_constant_expression_1 does bail out.
> That's why we don't print the later error with -std=c++11.
>
> What should we do with that?
Fix constexpr_fn_retval to ignore the call to __builtin_unreachable.
Jason