summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-25 09:12:22 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-25 09:12:22 +0000
commit6bed615df25df9b337a34355d1899766e6c01585 (patch)
tree5860e18219756b6ce39469e5066e212b60843bec
parent59d4eb166403c31192fd8b050eabbb6ccac37fed (diff)
downloadgcc-6bed615df25df9b337a34355d1899766e6c01585.tar.gz
/cp
2012-10-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/34892 * parser.c (cp_parser_template_parameter): When cp_parser_parameter_declaration parsed a default argument don't see if *is_parameter_pack needs setting. /testsuite 2012-10-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/34892 * g++.dg/template/crash114.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192802 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c15
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/template/crash114.C5
4 files changed, 30 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9e8d933e745..9d5dde7ba92 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/34892
+ * parser.c (cp_parser_template_parameter): When
+ cp_parser_parameter_declaration parsed a default argument don't
+ see if *is_parameter_pack needs setting.
+
2012-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54922
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 853d789f987..940356377a0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12258,12 +12258,21 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type,
parameter_declarator->declarator->parameter_pack_p = false;
}
+ if (parameter_declarator
+ && parameter_declarator->default_argument)
+ {
+ /* Can happen in some cases of erroneous input (c++/34892). */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
+ /* Consume the `...' for better error recovery. */
+ cp_lexer_consume_token (parser->lexer);
+ }
/* If the next token is an ellipsis, and we don't already have it
marked as a parameter pack, then we have a parameter pack (that
has no declarator). */
- if (!*is_parameter_pack
- && cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)
- && declarator_can_be_parameter_pack (parameter_declarator->declarator))
+ else if (!*is_parameter_pack
+ && cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)
+ && (declarator_can_be_parameter_pack
+ (parameter_declarator->declarator)))
{
/* Consume the `...'. */
cp_lexer_consume_token (parser->lexer);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b41a4dce82d..bcbc0f28c83 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,7 +1,12 @@
+2012-10-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/34892
+ * g++.dg/template/crash114.C: New.
+
2012-10-24 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/55049
- * gcc.target/i386/pr55049-1.c: New test.
+ * gcc.target/i386/pr55049-1.c: New test.
2012-10-24 Janus Weil <janus@gcc.gnu.org>
diff --git a/gcc/testsuite/g++.dg/template/crash114.C b/gcc/testsuite/g++.dg/template/crash114.C
new file mode 100644
index 00000000000..cf894ba6967
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash114.C
@@ -0,0 +1,5 @@
+// PR c++/34892
+
+template<int=..., int=0> struct A {}; // { dg-error "expected primary" }
+
+A<0> a;