Re: [C++ Patch] PR 57673

2013-07-31 Thread Paolo Carlini

On 07/30/2013 09:36 PM, Jason Merrill wrote:

OK.

Thanks, installed.

Today I had a look to the error recovery in cp_parser_sizeof_pack and 
noticed a few cases in which we could do better. A very simple issue is 
the following: when cp_parser_identifier returns error_mark_node we 
don't notice and we get to cp_parser_lookup_name_simple. Then it's 
pretty easy to have error messages with a final redundant:


  error: ‘expression error’ has not been declared

The below passes testing.

Thanks,
Paolo.


Index: parser.c
===
--- parser.c(revision 201363)
+++ parser.c(working copy)
@@ -23140,6 +23140,8 @@ cp_parser_sizeof_pack (cp_parser *parser)
 
   cp_token *token = cp_lexer_peek_token (parser-lexer);
   tree name = cp_parser_identifier (parser);
+  if (name == error_mark_node)
+return error_mark_node;
   /* The name is not qualified.  */
   parser-scope = NULL_TREE;
   parser-qualifying_scope = NULL_TREE;


Re: [C++ Patch] PR 57673

2013-07-31 Thread Jason Merrill

OK.

Jason


[C++ Patch] PR 57673

2013-07-30 Thread Paolo Carlini

Hi,

we currently fail to parse this rather simple NSDMI usage (note that 
wrapping the whole initializer in parentheses works around the problem 
because cp_parser_cache_group handles the special case).


Simply detecting that we are parsing an ellipsis in an nsdmi and not 
ending the main while loop in that case appears to work fine. If we 
think we must be stricter we may consider keeping memory that the 
previous token was a sizeof or... something else.


Tested x86_64-linux.

Thanks,
Paolo.


/cp
2013-07-30  Paolo Carlini  paolo.carl...@oracle.com

PR c++/57673
* parser.c (cp_parser_cache_defarg): In an NSDMI don't stop when
token-type == CPP_ELLIPSIS.

/testsuite
2013-07-30  Paolo Carlini  paolo.carl...@oracle.com

PR c++/57673
* g++.dg/cpp0x/nsdmi-sizeof.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 201343)
+++ cp/parser.c (working copy)
@@ -24145,7 +24145,9 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns
case CPP_SEMICOLON:
case CPP_CLOSE_BRACE:
case CPP_CLOSE_SQUARE:
- if (depth == 0)
+ if (depth == 0
+ /* Handle correctly int n = sizeof ... ( p );  */
+  !(nsdmi  token-type == CPP_ELLIPSIS))
done = true;
  /* Update DEPTH, if necessary.  */
  else if (token-type == CPP_CLOSE_PAREN
Index: testsuite/g++.dg/cpp0x/nsdmi-sizeof.C
===
--- testsuite/g++.dg/cpp0x/nsdmi-sizeof.C   (revision 0)
+++ testsuite/g++.dg/cpp0x/nsdmi-sizeof.C   (working copy)
@@ -0,0 +1,7 @@
+// PR c++/57673
+// { dg-do compile { target c++11 } }
+
+template int ... p 
+struct d {
+  int n = sizeof ... ( p );
+};


Re: [C++ Patch] PR 57673

2013-07-30 Thread Jason Merrill

OK.

Jason