This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, C++] Fix pr43779
On Thu, Apr 29, 2010 at 10:33 PM, Shujing Zhao <pearly.zhao@oracle.com> wrote:
> On 04/29/2010 06:22 PM, Gabriel Dos Reis wrote:
>>
>> On Thu, Apr 29, 2010 at 2:54 AM, Shujing Zhao <pearly.zhao@oracle.com>
>> wrote:
>>>
>>> On 04/28/2010 06:49 PM, Manuel LÃpez-IbÃÅez wrote:
>>>>
>>>> On 28 April 2010 12:48, Manuel LÃpez-IbÃÅez <lopezibanez@gmail.com>
>>>> wrote:
>>>>>
>>>>> On 28 April 2010 12:01, Shujing Zhao <pearly.zhao@oracle.com> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> This patch fixed pr43779 that emits the diagnostic for easy
>>>>>> translation.
>>>>>> Tested on i686-pc-linux-gnu with no regression. OK for trunk?
>>>>>> Since it is reported for 4.5.0, should gcc-4_5-branch be fixed too?
>>>>>
>>>>> Being picky, a static function that abstracts out this code with a
>>>>> boolean for fewer/too many will be shorter (check the boolean last to
>>>>> choose the appropriate string), and make the original function shorter
>>>>> as well.
>>>>
>>>> In fact, that the function takes a location parameter would be even
>>>> better, so when we get the correct location, only the calls need to be
>>>> updated.
>>>>
>>>> Âerror_at (loc,
>>>> Â Â Â Â Â Â(too_many_p)
>>>> Â Â Â Â Â Â? _("too many arguments to constructor %q#D")
>>>> Â Â Â Â Â Â: _("too few arguments to constructor %q#D"),
>>>> Â Â Â Â Âfndecl);
>>>>
>>> Manuel, thanks for the reply.
>>> The updated patch is add a static function warn_args_num to print the
>>> diagnostics. Tested on i686-pc-linux-gnu and no regression.
>>>
>>> Is it ok?
>>
>> Make sure you follow the GCC coding standard for the ternary operator
>> " ? : " when the arguments spans multiple lines. ÂOK.
>
> Ok. Fix the problems and Retested.
> Change
>
> + Â Â Â Â Â error_at (loc, too_many_p
> + Â Â Â Â Â Â Â Â Â Â ? G_("too many arguments to constructor %q#D")
> + Â Â Â Â Â Â Â Â Â Â : G_("too few arguments to constructor %q#D"),
>
> to
>
> + Â Â Â Â Â error_at (loc,
> + Â Â Â Â Â Â Â Â Â Â too_many_p
> + Â Â Â Â Â Â Â Â Â Â ? G_("too many arguments to constructor %q#D")
> + Â Â Â Â Â Â Â Â Â Â : G_("too few arguments to constructor %q#D"),
>
> Change
> + Â Â Â Â Â warn_args_num (input_location, fndecl, true /* too_manay_p */);
> to
> + Â Â Â Â Â warn_args_num (input_location, fndecl, /*too_many_p=*/true);
>
> Change
> + Â Âerror (too_many_p ? G_("too many arguments to function")
> to
> + Â Âerror_at (loc, too_many_p ? G_("too many arguments to function")
>
> Is it ok?
Yes.