This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] PR 31988
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 25 Oct 2007 20:03:29 -0700
- Subject: Re: [C++ Patch] PR 31988
- References: <46F479D7.70308@suse.de>
Paolo Carlini wrote:
> cp/
> 2007-09-21 Paolo Carlini <pcarlini@suse.de>
>
> PR c++/31988
> * decl2.c (coerce_new_type): Do not allow a default argument for
> the first parameter.
>
> testsuite/
> 2007-09-21 Paolo Carlini <pcarlini@suse.de>
>
> PR c++/31988
> * g++.dg/init/new25.C: New.
Thanks for fixing this bug.
We can make the code tidier than your version, though:
if (!args || args == void_list_node)
{
if (!same_type_p (TREE_VALUE (args), size_type_node)
{
e = 2;
...
}
else if (TREE_PURPOSE (args))
{
/* [basic.stc.dynamic.allocation]
The first parameter shall not have an associated default
argument. */
error (...);
/* Throw away the default argument. */
TREE_PURPOSE (args) = NULL_TREE;
}
}
This version avoids checking !args, etc., twice. It also gives a
justification for the error. (I didn't know this rule. It's always
nice to have a way to verify what the code is doing by having pointers
back to the standard.)
OK with that change, assuming it works. :-)
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713