This is the mail archive of the 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/05/2011 05:08 PM, Jason Merrill wrote:
On 10/05/2011 11:55 AM, Ed Smith-Rowland wrote:
+         int num_parms = TREE_VEC_LENGTH (parameter_list);
+         if (num_parms != 1)
+           ok = false;
+         else
+           {
+             tree parm_list = TREE_VEC_ELT (parameter_list, 0);
+             tree parm = INNERMOST_TEMPLATE_PARMS (parm_list);

This is backwards; you want to do INNERMOST_TEMPLATE_PARMS before looking at the number of parms or pulling out the one at index 0.

Now I'm confused. In an earlier email you said (3/30/2011 in response to how to check template parms):
If you're looking at the PARM_DECL for the template parameter, you want to check that TREE_TYPE (decl) is char_type_node and that TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (decl)) is true. Does that help?
Also, In spite of the documentation cp_parser_template_parameter_list returns a TREE_VEC not a TREE_LIST. This happens inside end_template_parm_list called inside the former. So parameter_list is a TREE_VEC, parm_list is a TREE_LIST, parm is a PARM_DECL, etc.
+struct GTY(()) tree_userdef_literal {
+  struct tree_common common;

I think you can use tree_base instead of tree_common here, since you aren't using TREE_TYPE or TREE_CHAIN.

One thing doesn't work. Earlier I had said that friend declarations failed. Not true. What fails is defining the function body in the class definition. The function is simply not recorded. I'm trying to track this down but pointers would be helpful. If I write the function body outside the class definition friend works perfectly.

About friends. The lookup for user-defined literal operators isn't ADL. They are a lot like normal functions because of the suffix-id as opposed to operator<< in this regard. Thus a friend literal operator should be accessible both as an explicit operator call and via a literal. Both are tested and except as noted above about inline defs the tests pass.

A function that is only declared in a friend declaration can only be found by ADL, so that doesn't sound like a failure to me; it sounds like it's working the way it should. However, if you declare the function earlier and then define it in the friend declaration it ought to work.

Ok. Then things really do work all around. I almost never use friend. ;-)

I'm still looking for a fix for duplicate errors/warnings coming from cp_parser_operator. I tried cp_parser_error and lost the errors. I'll look for different code paths for the two invocations and see if I can either move something up or see if something is set differently between the two that would be useful for a flag.

Then I think this thing is really done.


Attachment: patch26
Description: Text document

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