re PR c++/77791 (ICE on invalid C++11 code with redefined function parameter: tree...
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Oct 2016 15:34:16 +0000 (17:34 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 4 Oct 2016 15:34:16 +0000 (17:34 +0200)
PR c++/77791
* parser.c (cp_parser_lambda_declarator_opt): Only pedwarn
for C++11 on decls in the param_list.  Test cxx_dialect < cxx14 before
the loop just once.

* g++.dg/cpp0x/lambda/lambda-77791.C: New test.

From-SVN: r240751

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

index 48edc6e03efb41780c4e5bb6ba097a6d7a498c9b..637aed4a00bdd68cc17a8fc485f126a32d3399ad 100644 (file)
@@ -1,5 +1,10 @@
 2016-10-04  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77791
+       * parser.c (cp_parser_lambda_declarator_opt): Only pedwarn
+       for C++11 on decls in the param_list.  Test cxx_dialect < cxx14 before
+       the loop just once.
+
        * cp-tree.h (enum cp_tree_index): Remove CPTI_JAVA_*,
        CPTI_LANG_NAME_JAVA and CPTI_JCLASS.
        (java_byte_type_node, java_short_type_node, java_int_type_node,
index 16b895cf37a8365dfb1e4aeeeb020ce53e4ae7cd..8581375655c9b587a76c7659b407ce336d106b13 100644 (file)
@@ -10114,10 +10114,11 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
 
       /* Default arguments shall not be specified in the
         parameter-declaration-clause of a lambda-declarator.  */
-      for (tree t = param_list; t; t = TREE_CHAIN (t))
-       if (TREE_PURPOSE (t) && cxx_dialect < cxx14)
-         pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
-                  "default argument specified for lambda parameter");
+      if (cxx_dialect < cxx14)
+       for (tree t = param_list; t; t = TREE_CHAIN (t))
+         if (TREE_PURPOSE (t) && DECL_P (TREE_VALUE (t)))
+           pedwarn (DECL_SOURCE_LOCATION (TREE_VALUE (t)), OPT_Wpedantic,
+                    "default argument specified for lambda parameter");
 
       cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
 
index ef45ca1ca3b7ced9eddf54c9679d931ee5b113b3..3b2e14a9c9c131d97f5c251a8caf0ab538bd8689 100644 (file)
@@ -1,5 +1,8 @@
 2016-10-04  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77791
+       * g++.dg/cpp0x/lambda/lambda-77791.C: New test.
+
        * g++.dg/other/java3.C: Remove.
        * g++.dg/other/java1.C: Remove.
        * g++.dg/other/error12.C: Remove.
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-77791.C
new file mode 100644 (file)
index 0000000..0475d27
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/77791
+// { dg-do compile { target c++11 } }
+
+auto a = [] (int i, int i = 0) {};     // { dg-error "redefinition of" }