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++-11] User defined literals


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.


+ 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

Jason,

Here is a patch that fixes both issues noted in the previous email.
Also, I'm preventing user-defined literals in a preprocessor expression since there's no way we can tell they are integral or not. They could return anything (or nothing).


Ed

Attachment: patch32
Description: Text document

Attachment: CL_udlit_gcc_c-family
Description: Text document

Attachment: CL_udlit_gcc_cp
Description: Text document

Attachment: CL_udlit_gcc_testsuite
Description: Text document

Attachment: CL_udlit_libcpp
Description: Text document


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