This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix test-suite fallout of default -Wreturn-type.


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?
Thanks,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]