diff options
author | Marek Polacek <polacek@redhat.com> | 2020-08-04 09:35:25 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-08-04 13:41:36 -0400 |
commit | 97def1f34c134d78d4423e9ac3e9b262417ea390 (patch) | |
tree | 54684fc3e421aa904b15fe7674906fc4f004313d /gcc | |
parent | acf83db025cfd4a67724838e9dbd19813f4f5960 (diff) | |
download | gcc-97def1f34c134d78d4423e9ac3e9b262417ea390.zip gcc-97def1f34c134d78d4423e9ac3e9b262417ea390.tar.gz gcc-97def1f34c134d78d4423e9ac3e9b262417ea390.tar.bz2 |
c++: Template keyword following :: [PR96082]
In r9-4235 I tried to make sure that the template keyword follows
a nested-name-specifier. :: is a valid nested-name-specifier, so
I also have to check 'globalscope' before giving the error.
gcc/cp/ChangeLog:
PR c++/96082
* parser.c (cp_parser_elaborated_type_specifier): Allow
'template' following ::.
gcc/testsuite/ChangeLog:
PR c++/96082
* g++.dg/template/template-keyword3.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/template-keyword3.C | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 1e7cd19..981c625 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -18840,7 +18840,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, if (!template_p) cp_parser_parse_tentatively (parser); /* The `template' keyword must follow a nested-name-specifier. */ - else if (!nested_name_specifier) + else if (!nested_name_specifier && !globalscope) { cp_parser_error (parser, "%<template%> must follow a nested-" "name-specifier"); diff --git a/gcc/testsuite/g++.dg/template/template-keyword3.C b/gcc/testsuite/g++.dg/template/template-keyword3.C new file mode 100644 index 0000000..91af2b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/template-keyword3.C @@ -0,0 +1,11 @@ +// PR c++/96082 +// { dg-do compile { target c++11 } } + +template <class> class A {}; + +void +f () +{ + typename::template A <int> a; + ::template A <int> a2; +} |