From: Gabriel Dos Reis Date: Fri, 11 Oct 2002 18:25:10 +0000 (+0000) Subject: PRs C++/6803, C++/7721 and C++/7803 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ee366b54aaf49c79bb52f1ea37fe9b67189f05b;p=gcc.git PRs C++/6803, C++/7721 and C++/7803 PRs C++/6803, C++/7721 and C++/7803 * decl.c (grokdeclarator): Gracefully handle template-name as decl-specifier. From-SVN: r58058 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 01f8551c10c..200bc393775 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-10-11 Gabriel Dos Reis + + PRs C++/6803, C++/7721 and C++/7803 + * decl.c (grokdeclarator): Gracefully handle template-name as + decl-specifier. + 2002-10-11 Jason Molenda * init.c (build_field_list): Provide uses_unions_p with a default diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f4651dbefcd..f8202b46e46 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10249,6 +10249,15 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) case BASELINK: next = &BASELINK_FUNCTIONS (decl); break; + + case TEMPLATE_DECL: + /* Sometimes, we see a template-name used as part of a + decl-specifier like in + std::allocator alloc; + Handle that gracefully. */ + error ("invalid use of template-name '%E' in a declarator", decl); + return error_mark_node; + break; default: my_friendly_assert (0, 20020917); diff --git a/gcc/testsuite/g++.dg/parse/decl-specifier-1.C b/gcc/testsuite/g++.dg/parse/decl-specifier-1.C new file mode 100644 index 00000000000..e81fbabf2c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/decl-specifier-1.C @@ -0,0 +1,16 @@ +// Contributed by Gabriel Dos Reis +// Origin: PRs 7721 and 7803 +// { dg-do compile } + +namespace N +{ + template + struct X { }; +} + +N::X X; // { dg-error "" "" } + +int main() +{ + return sizeof(X); // { dg-error "" "" } +}