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][c++/PR 31743]


Dave Brolley wrote:
> Hi Mark,
> 
> Thanks for reviewing this.
> 
> Mark Mitchell wrote:
>> Thanks for working on this.  A cleaner fix would be to but a call to
>> require_complete_type in build_new (rather than build_new_1).
>>
>> The TYPE argument to build_new is either the type being allocated, or
>> the type of the array elements.  In either case, it must be a complete
>> type.  So, after the other checks (for REFERENCE_TYPE and FUNCTION_TYPE)
>> in build_new, you could just do:
>>
>>   type = require_complete_type (type);
>>   if (type == error_mark_node)
>>     return error_mark_node;
>>
>> Then, remove the complete_type_or_else call from build_new_1.  (The only
>> caller of build_new_1 is build_new.)
>>   
> I tried this and it yields the inaccurate diagnostic
> 31743.C:2: error: cannot convert ‘int*’ to ‘int (*)[]’ in initialization
> 
> The problem is that require_complete_type expects an *expression* but
> the tree we have in build_new represents a *type*. 

Excellent point.  In that context, then, one should do:

  if (!complete_type_or_else(type, NULL_TREE))
    return error_mark_node;

That routine is explicitly for the case where you may not have a value.

Does using that work better?

> Sorry. I figured the test case in the bug report was sufficient. Attaching a test case to this message.

No problem.  It's just easier for me to review if it's all in one place,
and part of the goal is that later readers of gcc-patches can easily see
what was checked in.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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