aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/parser.c2
-rw-r--r--gcc/testsuite/g++.dg/template/template-keyword3.C11
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;
+}