public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ed Smith-Rowland <3dw4rd@verizon.net>
To: Jason Merrill <jason@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [C++-11] User defined literals
Date: Sun, 23 Oct 2011 22:29:00 -0000	[thread overview]
Message-ID: <4EA4830B.4040909@verizon.net> (raw)
In-Reply-To: <4EA1E218.6060404@redhat.com>

On 10/21/2011 05:20 PM, Jason Merrill wrote:
> I think we're down to minor cosmetic issues:
>
> On 10/21/2011 03:55 PM, Tom Tromey wrote:
>> There are a few spots like this that are missing a space before an open
>> paren.
>
>> +      if (DECL_LANGUAGE(decl) == lang_c)
>
> Another one.
>
>> -          if (warn_cxx0x_compat
>> - && C_RID_CODE (token->u.value) >= RID_FIRST_CXX0X
>> - && C_RID_CODE (token->u.value) <= RID_LAST_CXX0X)
> ....
>
> This code doesn't seem to have actually changed, so let's not adjust 
> its whitespace.
>
>> +  /* Fill in PARMVEC with all of the parameters.  */
>> +  parmvec = make_tree_vec (len);
>
> Let's call it 'charvec'; the characters are template arguments, not 
> parameters.
>
>> +/* Parse a user-defined numeric constant.  returns a call to a 
>> user-defined
>> +   literal operator.  */
>> +static tree
>> +cp_parser_userdef_numeric_literal (cp_parser *parser)
>
> Add a blank line between comment and function.
>
>> While looking at the embedded string issue I found that if you apply 
>> the suffix of a raw literal to a string it errors as it should but 
>> the error complained that there were too many arguments for the 
>> function.  This was not helpful so I made a nicer error message.
>
>> +  if (result == error_mark_node)
>> +    error ("invalid string literal prefix %<\"%s\"%> for user-defined"
>> +          " raw literal operator %qD", TREE_STRING_POINTER (value), 
>> name);
>
> I think that we want a combination of the two errors; the new error 
> doesn't help the user to fix their code as much.  It should remind 
> them that for a string literal the function is called with a length 
> argument as well.
>
Concerning this error, the only way to get here is to mis-use a raw 
literal operator by giving it a quoted string.  The prefix must be 
interpretable as a number of some kind.  I think I'll tell the user to 
drop the quotes.
The length of a string literal is supplied implicitly by the compiler to 
a string literal operator when a string user defined literal is 
encountered.  The user doesn't explicitly call the operator (not here 
anyway).

>> +       error ("literal operator template %qD has invalid parameter 
>> list",
>> +              decl);
>
> Similarly, this message should say that the parameter list needs to be 
> <char...>
>
>>
>> +
>> +/* Return true if a user-defined literal operator is a raw 
>> operator.  */
>> +
>
> We don't need the extra newline before the comment.
>
> Should be ready to go with these tweaks.
>
> Jason
>
I've made these corrections.  They'll be in the next patch.

Unfortunately, as I was testing raw operators on very long strings I 
observed two things:
1. A bad error - the argument to a raw literal operator must be a 
null-terminated string.
2. If a very long number is given as the prefix to a numeric literal, a 
warning is issued ("integer constant is too large for its type")
If the receiving operator is either the raw operator or the operator 
template then this should not be given.  I anticipate people might like 
to have multi-precision numbers someday, for example.

Before I release another patch I have to fix 1.  The warning might be 
fixed in-tree if that's OK.

Ed

  reply	other threads:[~2011-10-23 21:11 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 21:12 3dw4rd
2011-10-15 23:13 ` Jason Merrill
2011-10-16  7:59 ` Jason Merrill
2011-10-21 14:56   ` Ed Smith-Rowland
2011-10-21 21:20     ` Tom Tromey
2011-10-21 23:38       ` Jason Merrill
2011-10-23 22:29         ` Ed Smith-Rowland [this message]
2011-10-24 15:41         ` Ed Smith-Rowland
2011-10-25 23:38           ` Jason Merrill
2011-10-26  9:16             ` Ed Smith-Rowland
2011-10-26 20:13               ` Jason Merrill
2011-10-27 19:15                 ` Ed Smith-Rowland
2011-10-27 19:55                 ` Ed Smith-Rowland
2011-10-27 20:37                   ` Jason Merrill
2011-10-30 19:10                     ` Ed Smith-Rowland
2011-10-31 17:52                       ` Jason Merrill
2011-10-25  7:07         ` Ed Smith-Rowland
  -- strict thread matches above, loose matches on Subject: below --
2011-10-31 17:58 3dw4rd
2011-10-31 20:20 ` Jason Merrill
2011-10-26 20:33 3dw4rd
2011-10-26 20:46 ` Jason Merrill
2011-10-21 17:04 3dw4rd
2011-09-13 15:36 Ed Smith-Rowland
2011-09-13 16:43 ` Jason Merrill
2011-09-14  8:00 ` Jason Merrill
2011-09-19  8:33   ` Ed Smith-Rowland
2011-09-19 22:43     ` Jason Merrill
2011-09-20  7:23       ` Ed Smith-Rowland
2011-09-20 21:48         ` Jason Merrill
2011-10-05 15:57           ` Ed Smith-Rowland
2011-10-05 21:24             ` Jason Merrill
2011-10-08 21:38               ` Ed Smith-Rowland
2011-10-09  1:18                 ` Jason Merrill
2011-10-09 23:46                   ` Ed Smith-Rowland
2011-10-11 19:20                     ` Jason Merrill
2011-10-11 17:39                       ` Jason Merrill
2011-10-12  6:51                         ` Ed Smith-Rowland
2011-10-12 18:49                           ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EA4830B.4040909@verizon.net \
    --to=3dw4rd@verizon.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).