diff options
author | Jason Merrill <jason@redhat.com> | 2014-12-09 21:51:03 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-12-09 21:51:03 -0500 |
commit | 59bce71381be24449aaf902bc1bc64a12b373bf4 (patch) | |
tree | 09fe07aae53645d23d0c5ddacb17942c5b4f1904 /gcc | |
parent | 9c78f8e6055b086b2e4317e3fe11071f27ef0cb2 (diff) | |
download | gcc-59bce71381be24449aaf902bc1bc64a12b373bf4.zip gcc-59bce71381be24449aaf902bc1bc64a12b373bf4.tar.gz gcc-59bce71381be24449aaf902bc1bc64a12b373bf4.tar.bz2 |
re PR c++/64129 (ICE on invalid: in grokfndecl, at cp/decl.c:7658)
PR c++/64129
* decl.c (grokdeclarator): Recover from variable template
specialization declared as function.
From-SVN: r218557
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/error56.C | 5 |
3 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a8b536..484dd28 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-12-09 Jason Merrill <jason@redhat.com> + PR c++/64129 + * decl.c (grokdeclarator): Recover from variable template + specialization declared as function. + PR c++/64222 * parser.c (cp_parser_unqualified_id): Don't declare fname while parsing function parms. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5639b3d..9659336 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10739,6 +10739,19 @@ grokdeclarator (const cp_declarator *declarator, return error_mark_node; } + if (TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR) + { + tree tmpl = TREE_OPERAND (unqualified_id, 0); + if (variable_template_p (tmpl)) + { + error ("specialization of variable template %qD " + "declared as function", tmpl); + inform (DECL_SOURCE_LOCATION (tmpl), + "variable template declared here"); + return error_mark_node; + } + } + /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */ function_context = (ctype != NULL_TREE) ? decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE; diff --git a/gcc/testsuite/g++.dg/parse/error56.C b/gcc/testsuite/g++.dg/parse/error56.C new file mode 100644 index 0000000..7c81ab4 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error56.C @@ -0,0 +1,5 @@ +// PR c++/64129 + +template <0> int __copy_streambufs_eof; // { dg-error "" } +class { + friend __copy_streambufs_eof <> ( // { dg-error "" } |