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: [C++ Patch] PR 31988


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


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