diff mbox

[C++] PR 57673

Message ID 51F7FD79.6060103@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 30, 2013, 5:52 p.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/57673
	* g++.dg/cpp0x/nsdmi-sizeof.C: New.

Comments

Jason Merrill July 30, 2013, 7:36 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

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 );
+};