aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2006-12-06 22:54:51 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2006-12-06 22:54:51 +0000
commit277264f80cf2080c04bc9361a2bcd5706f50c2be (patch)
treeb04cd501e7e1b9fe4e479bc526a25393e9ee84f4
parent66863d89a10ffec862e86d79000360a4482e9785 (diff)
downloadgcc-277264f80cf2080c04bc9361a2bcd5706f50c2be.zip
gcc-277264f80cf2080c04bc9361a2bcd5706f50c2be.tar.gz
gcc-277264f80cf2080c04bc9361a2bcd5706f50c2be.tar.bz2
re PR c++/29730 (ICE on invalid declaration of template member)
PR c++/29730 * parser.c (cp_parser_init_declarator): Reject initialization of functions. PR c++/29730 * g++.dg/template/crash64.C: New test. * g++.dg/parse/crash27.C: Adjust error markers. From-SVN: r119601
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c20
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/parse/crash27.C3
-rw-r--r--gcc/testsuite/g++.dg/template/crash64.C6
5 files changed, 35 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9e63aca..07e6b63 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-06 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/29730
+ * parser.c (cp_parser_init_declarator): Reject initialization of
+ functions.
+
2006-12-05 Mark Mitchell <mark@codesourcery.com>
PR c++/29729
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 82ee887..cdb60f6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -11311,9 +11311,23 @@ cp_parser_init_declarator (cp_parser* parser,
is_non_constant_init = true;
if (is_initialized)
{
- if (function_declarator_p (declarator)
- && initialization_kind == CPP_EQ)
- initializer = cp_parser_pure_specifier (parser);
+ if (function_declarator_p (declarator))
+ {
+ if (initialization_kind == CPP_EQ)
+ initializer = cp_parser_pure_specifier (parser);
+ else
+ {
+ /* If the declaration was erroneous, we don't really
+ know what the user intended, so just silently
+ consume the initializer. */
+ if (decl != error_mark_node)
+ error ("initializer provided for function");
+ cp_parser_skip_to_closing_parenthesis (parser,
+ /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/true);
+ }
+ }
else
initializer = cp_parser_initializer (parser,
&is_parenthesized_init,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 58837bc..79f1dec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-06 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/29730
+ * g++.dg/template/crash64.C: New test.
+ * g++.dg/parse/crash27.C: Adjust error markers.
+
2006-12-06 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/30009
diff --git a/gcc/testsuite/g++.dg/parse/crash27.C b/gcc/testsuite/g++.dg/parse/crash27.C
index 1a13f81..0694366 100644
--- a/gcc/testsuite/g++.dg/parse/crash27.C
+++ b/gcc/testsuite/g++.dg/parse/crash27.C
@@ -3,6 +3,3 @@
void Dispatcher()
(__builtin_offsetof (ArgsType, largeMsgLen))
/* { dg-error "function " "function" { target *-*-* } 4 } */
- /* { dg-error "expected type" "expected 1" { target *-*-* } 4 } */
- /* { dg-error "expected `,' before" "expected 2" { target *-*-* } 4 } */
- /* { dg-error "expected `\\\)" "expected 3" { target *-*-* } 4 } */
diff --git a/gcc/testsuite/g++.dg/template/crash64.C b/gcc/testsuite/g++.dg/template/crash64.C
new file mode 100644
index 0000000..750e3da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash64.C
@@ -0,0 +1,6 @@
+// PR c++/29730
+
+struct A
+{
+ template<int> void foo()(0); // { dg-error "initializer" }
+};