re PR c++/51314 ([C++0x] sizeof... and parentheses)
authorMarc Glisse <marc.glisse@inria.fr>
Mon, 30 Apr 2012 16:36:37 +0000 (18:36 +0200)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 30 Apr 2012 16:36:37 +0000 (12:36 -0400)
PR c++/51314
* parser.c (cp_parser_sizeof_operand): Require parentheses for
sizeof...

From-SVN: r186988

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic76.C

index 8d99c17..282912a 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-30  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/51314
+       * parser.c (cp_parser_sizeof_operand): Require parentheses for
+       sizeof...
+
 2012-04-30  Dodji Seketeli  <dodji@redhat.com>
 
        Fix location for static class members
index f0f7e98..8fcbba6 100644 (file)
@@ -21969,6 +21969,9 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
                                 /*attrlist=*/NULL);
        }
     }
+  else if (pack_expansion_p)
+    permerror (cp_lexer_peek_token (parser->lexer)->location,
+              "%<sizeof...%> argument must be surrounded by parentheses");
 
   /* If the type-id production did not work out, then we must be
      looking at the unary-expression production.  */
index 7f895fd..6613970 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-30  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/51314
+       * g++.dg/cpp0x/vt-51314.C: New test.
+       * g++.dg/cpp0x/variadic76.C: Fix.
+
 2012-04-30  Greta Yorsh  <Greta.Yorsh@arm.com>
 
        * gcc.dg/pr52283.c: Add missing dg-warning and dg-options.
index a9f8eab..fb80244 100644 (file)
@@ -4,7 +4,8 @@
 
 template<int... N> int foo ()
 {
-  return sizeof... N ();       // { dg-error "cannot be used as a function" }
+  return sizeof... (N ());     // { dg-error "cannot be used as a function" }
+  return sizeof... (N) ();     // { dg-error "cannot be used as a function" }
 }
 
 int bar ()