Patchwork C++ PATCH for c++/57471 (bogus error with sizeof...)

login
register
mail settings
Submitter Jason Merrill
Date July 9, 2013, 9:51 p.m.
Message ID <51DC85F0.9010400@redhat.com>
Download mbox | patch
Permalink /patch/257868/
State New
Headers show

Comments

Jason Merrill - July 9, 2013, 9:51 p.m.
For some reason, the parser leaves parser->scope et al filled after the 
constructs that the explicit scopes apply to, and rely on later bits to 
clear them.  So we need to do that here.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 8b67a328cf8c69484d8971aededb22ca0de0b129
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jul 9 15:46:20 2013 -0400

    	PR c++/57471
    	* parser.c (cp_parser_sizeof_pack): Clear parser scopes.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 614cf43..4b683bf 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -23136,6 +23136,10 @@  cp_parser_sizeof_pack (cp_parser *parser)
 
   cp_token *token = cp_lexer_peek_token (parser->lexer);
   tree name = cp_parser_identifier (parser);
+  /* The name is not qualified.  */
+  parser->scope = NULL_TREE;
+  parser->qualifying_scope = NULL_TREE;
+  parser->object_scope = NULL_TREE;
   tree expr = cp_parser_lookup_name_simple (parser, name, token->location);
   if (expr == error_mark_node)
     cp_parser_name_lookup_error (parser, name, expr, NLE_NULL,
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-sizeof2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-sizeof2.C
new file mode 100644
index 0000000..dfc245d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-sizeof2.C
@@ -0,0 +1,14 @@ 
+// PR c++/57471
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+  static constexpr bool value = true;
+};
+
+template<typename... Types>
+struct B
+{
+  static_assert(A::value, "");
+  static_assert(sizeof...(Types) == 0, "");
+};