re PR c++/59435 (sizeof...(T) as default value for an argument in the constructor...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 9 Dec 2013 22:59:33 +0000 (22:59 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 9 Dec 2013 22:59:33 +0000 (22:59 +0000)
/cp
2013-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/59435
* parser.c (cp_parser_cache_defarg): sizeof ... ( p ) can
occur in a default argument too.

/testsuite
2013-12-09  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/59435
* g++.dg/cpp0x/variadic-sizeof3.C: New.

From-SVN: r205836

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic-sizeof3.C [new file with mode: 0644]

index dd33b05..2acc8c7 100644 (file)
@@ -1,3 +1,9 @@
+2013-12-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59435
+       * parser.c (cp_parser_cache_defarg): sizeof ... ( p ) can
+       occur in a default argument too.
+
 2013-12-06  Caroline Tice  <cmtice@google.com>
 
        Submitting patch from Stephen Checkoway, s@cs.jhu.edu
index bd4ead7..063d2ac 100644 (file)
@@ -24513,7 +24513,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi)
        case CPP_CLOSE_SQUARE:
          if (depth == 0
              /* Handle correctly int n = sizeof ... ( p );  */
-             && !(nsdmi && token->type == CPP_ELLIPSIS))
+             && token->type != CPP_ELLIPSIS)
            done = true;
          /* Update DEPTH, if necessary.  */
          else if (token->type == CPP_CLOSE_PAREN
index ae5983a..b1b043c 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59435
+       * g++.dg/cpp0x/variadic-sizeof3.C: New.
+
 2013-12-09  David Malcolm  <dmalcolm@redhat.com>
 
        * g++.dg/plugin/selfassign.c (execute_warn_self_assign): Eliminate
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-sizeof3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-sizeof3.C
new file mode 100644 (file)
index 0000000..7296500
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/59435
+// { dg-require-effective-target c++11 }
+
+template <typename... E>
+struct T
+{
+  T(unsigned int i = sizeof...(E)){} // does not compile
+    
+  static constexpr unsigned int U = sizeof...(E);
+  T(unsigned int j, unsigned int i = U){} //  compile
+};
+
+template <typename... T>
+void test(int i = sizeof...(T)) // compile
+{}