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: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument


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


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