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++] Fix 14075


Nathan Sidwell <nathan@codesourcery.com> writes:

| This patch fixes 14075, where we accepted a parenthesized string
| literal as an initializer.  As with the C front end, we're only
| pick about it when being pedantic.
| 
| booted & tested on i686-pc-linux-gnu.
| 
| nathan
| -- 
| Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
| nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk
| 
| 2004-12-16  Nathan Sidwell  <nathan@codesourcery.com>
| 
| 	PR c++/14075
| 	* decl.c (check_initializer): Check string initializer of array is
| 	not parenthesized.
| 	* cp-tree.h (PAREN_STRING_LITERAL_P): New.

[...]

|       case STRING_CST:
| +       if (PAREN_STRING_LITERAL_P (t))
| + 	pp_cxx_left_paren (cxx_pp);
| +       pp_c_constant (pp_c_base (cxx_pp), t);
| +       if (PAREN_STRING_LITERAL_P (t))
| + 	pp_cxx_right_paren (cxx_pp);
| +       break;

This is the wrong place to put that.  It should have been in 
gcc/c-pretty-print.c:pp_c_string_literal().

Also, we already have machinery to detect where users has written
expressions in parens; any reason why that machinery is not sufficient
and we need one more?

I'll prepare a patch to address the first issue, but I would
appreciate an answer for the second.  Since the issue is present in C
too, why do we need a C++-specific flag, instea one that is chared by
both fornt-ends?

-- Gaby


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