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: Mark Mitchell <mark at codesourcery dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail 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, 08 Feb 2009 14:17:59 -0800
- 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>
Manuel López-Ibáñez wrote:
>>> 2008-08-18 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
>>>
>>> PR c++/34758
>>> cp/
>>> * call.c (convert_default_argument): Take an additional last_arg
>>> argument. Clarify error message.
The function is convert_default_arg.
>>> (build_over_call): Update call to convert_default_arg.
>>> * typeck.c (convert_arguments): Update call to
>>> convert_default_arg.
>>> * cp-tree.h (convert_default_arg): Update declaration.
>>> * cp-gimplify.c (cxx_omp_clause_apply_fn): Update call to
>>> convert_default_arg.
>>> testsuite/
>>> * g++.dg/parse/pr34758.C: New.
>>>
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".
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713