From patchwork Mon Oct 15 15:07:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] PR 50080 From: Paolo Carlini X-Patchwork-Id: 191570 Message-Id: <507C26A1.4060001@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill Date: Mon, 15 Oct 2012 17:07:13 +0200 Hi, thus, if I understand correctly the resolution of Core/468 [CD1], we can simplify a bit the parser and just accept these 'template' outside templates. Tested x86_64-linux. Thanks, Paolo. /////////////////////// /cp 2012-10-15 Paolo Carlini PR c++/50080 * parser.c (cp_parser_optional_template_keyword): Implement Core/468, allow outside template. /testsuite 2012-10-15 Paolo Carlini PR c++/50080 * g++.dg/parse/tmpl-outside2.C: New. * g++.dg/parse/tmpl-outside1.C: Adjust. * g++.dg/template/qualttp18.C: Likewise. * g++.old-deja/g++.pt/memtemp87.C: Likewise. * g++.old-deja/g++.pt/overload13.C: Likewise. Index: testsuite/g++.old-deja/g++.pt/memtemp87.C =================================================================== --- testsuite/g++.old-deja/g++.pt/memtemp87.C (revision 192455) +++ testsuite/g++.old-deja/g++.pt/memtemp87.C (working copy) @@ -12,5 +12,4 @@ class Q { template class> class Y { }; -Q::template X x; // { dg-error "" } template syntax - +Q::template X x; Index: testsuite/g++.old-deja/g++.pt/overload13.C =================================================================== --- testsuite/g++.old-deja/g++.pt/overload13.C (revision 192455) +++ testsuite/g++.old-deja/g++.pt/overload13.C (working copy) @@ -7,5 +7,5 @@ struct A { int main () { A a; - return a.template f (0); // { dg-error "" } + return a.template f (0); } Index: testsuite/g++.dg/parse/tmpl-outside2.C =================================================================== --- testsuite/g++.dg/parse/tmpl-outside2.C (revision 0) +++ testsuite/g++.dg/parse/tmpl-outside2.C (working copy) @@ -0,0 +1,19 @@ +// PR c++/50080 + +template +struct A +{ + template + struct B {}; +}; + +template +void test() +{ + typename A::template B b; +} + +int main() +{ + typename A::template B b; +} Index: testsuite/g++.dg/parse/tmpl-outside1.C =================================================================== --- testsuite/g++.dg/parse/tmpl-outside1.C (revision 192455) +++ testsuite/g++.dg/parse/tmpl-outside1.C (working copy) @@ -7,4 +7,4 @@ struct X template struct Y {}; }; -typedef X::template Y<0> y; // { dg-error "template|invalid" } +typedef X::template Y<0> y; Index: testsuite/g++.dg/template/qualttp18.C =================================================================== --- testsuite/g++.dg/template/qualttp18.C (revision 192455) +++ testsuite/g++.dg/template/qualttp18.C (working copy) @@ -14,7 +14,7 @@ template