This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Paolo Carlini <paolo dot carlini at oracle dot com>, reichelt at gcc dot gnu dot org
- Date: Sun, 8 Feb 2009 23:32:07 +0100
- Subject: Re: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument
- References: <6c33472e0808222111t52ce1c2fqb0a0ebfd266b045@mail.gmail.com> <6c33472e0810210844h783c4267ubeb9a4d51a7a7e31@mail.gmail.com> <6c33472e0902061317q2de450e9j2c725f68f344dbf7@mail.gmail.com> <498F5A17.1030204@codesourcery.com>
2009/2/8 Mark Mitchell <mark@codesourcery.com>:
> Manuel López-Ibáñez wrote:
>
> I don't understand:
>
> + if (parmnum != 0 || !last_arg)
> + error ("%qD needs to be declared before called with a default argument "
> + "for parameter %d", fn, parmnum + 1);
> + else
> + error ("%qD needs to be declared before called with default argument",
> + fn);
>
> Why are the first argument (parmnum == 0) and the last argument treated
> specially? Is parmnum actually 0-based or 1-based? (That's not
> documented at present; your patch should clarify that documentation.)
> In convert_for_initialization, parmnum is treated as 1-based; there is
> no "+1".
if parmnum == 0 && last_arg is true then there is only one argument,
so we give the second message. In any other case, there is more than
one argument, so we give the first message.
parmnum is 0-based, I can document that in the function comment.
Cheers,
Manuel.