public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates
@ 2011-08-15 4:34 solodon at mail dot com
2011-08-15 9:07 ` [Bug c++/50080] [C++0x] " redi at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: solodon at mail dot com @ 2011-08-15 4:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
Bug #: 50080
Summary: error: 'template' (as a disambiguator) is only allowed
within templates
Classification: Unclassified
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: solodon@mail.com
Hi,
Consider the following code snippet compiled as:
g++ -std=c++0x test.cpp
In particular the two instantiations of B: one in the template context and the
other one in non-dependent scope.
template <typename T>
struct A
{
template <typename U>
struct B {};
};
template <typename T>
void test()
{
typename A<T>::template B<int> b;
}
int main()
{
typename A<double>::template B<int> b;
}
My GCC complains about the second instantiation saying:
error: 'template' (as a disambiguator) is only allowed within templates
and surely enough removing template there fixes the problem. The keyword
typename used for a similar purpose of disambiguating a type in a non-template
context is accepted even though redundant. Allowing typename seems to be in
line with the relaxed rule of C++0x. I think, however, that the template
keyword should similarly be allowed in non-dependent context accordingly to the
C++0x standard (and not allowed accordingly to C++03).
Here is a snippet from C++0x standard draft (FDIS n3291, section 14.2[5]) I
could get a hold of:
``A name prefixed by the keyword template shall be a template-id or the name
shall refer to a class template.
[ Note: The keyword template may not be applied to non-template members of
class templates. -end
note ] [ Note: As is the case with the typename prefix, the template prefix is
allowed in cases where it is
not strictly necessary; i.e., when the nested-name-specifier or the expression
on the left of the -> or . is not
dependent on a template-parameter, or the use does not appear in the scope of a
template. -end note ]''
I think that the second note implies that template keyword should have been
allowed in the example above in much the same way the typename is, please
correct me if I'm wrong.
The practical reason I need this behavior for is that I have a code snippet
that is generated by a macro. With template being allowed in non-dependent
context I can have a single macro that can be used in dependent and
non-dependent contexts, while without this behavior (as well as in C++03) I
will need to have 2 separate (largely duplicated) macros for each of the uses.
Thanks,
Yuriy
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [C++0x] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
@ 2011-08-15 9:07 ` redi at gcc dot gnu.org
2012-01-28 5:56 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-15 9:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-15 08:51:44 UTC ---
You're right, but g++ doesn't claim to support everything in C++11 yet,
especially not in the 4.5 release series which is nearly a year and half old,
the C++0x draft changed a lot in that time.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [C++0x] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
2011-08-15 9:07 ` [Bug c++/50080] [C++0x] " redi at gcc dot gnu.org
@ 2012-01-28 5:56 ` pinskia at gcc dot gnu.org
2012-01-28 6:14 ` [Bug c++/50080] [DR 468] " pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-28 5:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-28 05:46:23 UTC ---
Note typename was PR 22154.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [DR 468] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
2011-08-15 9:07 ` [Bug c++/50080] [C++0x] " redi at gcc dot gnu.org
2012-01-28 5:56 ` pinskia at gcc dot gnu.org
@ 2012-01-28 6:14 ` pinskia at gcc dot gnu.org
2012-10-05 16:15 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-28 6:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-28
Summary|[C++0x] error: 'template' |[DR 468] error: 'template'
|(as a disambiguator) is |(as a disambiguator) is
|only allowed within |only allowed within
|templates |templates
Ever Confirmed|0 |1
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-28 05:50:18 UTC ---
Confirmed.
http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#468 was the defect
report against the C++ standard.
Since we support other CD1 with -std=c++98, I am removing the C++0x marker.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [DR 468] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
` (2 preceding siblings ...)
2012-01-28 6:14 ` [Bug c++/50080] [DR 468] " pinskia at gcc dot gnu.org
@ 2012-10-05 16:15 ` paolo.carlini at oracle dot com
2012-10-15 16:48 ` paolo at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-05 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-05 16:15:22 UTC ---
Looking at cp_parser_optional_template_keyword, this seems very easy to fix.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [DR 468] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
` (3 preceding siblings ...)
2012-10-05 16:15 ` paolo.carlini at oracle dot com
@ 2012-10-15 16:48 ` paolo at gcc dot gnu.org
2012-10-15 16:49 ` paolo.carlini at oracle dot com
2012-10-15 19:14 ` paolo at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-10-15 16:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
--- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-10-15 16:48:01 UTC ---
Author: paolo
Date: Mon Oct 15 16:47:52 2012
New Revision: 192465
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192465
Log:
/cp
2012-10-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50080
* parser.c (cp_parser_optional_template_keyword): Implement
Core/468, allow outside template.
/testsuite
2012-10-15 Paolo Carlini <paolo.carlini@oracle.com>
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.
Added:
trunk/gcc/testsuite/g++.dg/parse/tmpl-outside2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/parse/tmpl-outside1.C
trunk/gcc/testsuite/g++.dg/template/qualttp18.C
trunk/gcc/testsuite/g++.old-deja/g++.pt/memtemp87.C
trunk/gcc/testsuite/g++.old-deja/g++.pt/overload13.C
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [DR 468] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
` (4 preceding siblings ...)
2012-10-15 16:48 ` paolo at gcc dot gnu.org
@ 2012-10-15 16:49 ` paolo.carlini at oracle dot com
2012-10-15 19:14 ` paolo at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-15 16:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.8.0
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-15 16:49:26 UTC ---
Done.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/50080] [DR 468] error: 'template' (as a disambiguator) is only allowed within templates
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
` (5 preceding siblings ...)
2012-10-15 16:49 ` paolo.carlini at oracle dot com
@ 2012-10-15 19:14 ` paolo at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-10-15 19:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50080
--- Comment #7 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-10-15 19:13:45 UTC ---
Author: paolo
Date: Mon Oct 15 19:13:41 2012
New Revision: 192470
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192470
Log:
/cp
2012-10-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50080 (again)
* parser.c (cp_parser_optional_template_keyword): When -pedantic
and C++98 mode restore pre-Core/468 behavior.
/testsuite
2012-10-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50080 (again)
* g++.dg/parse/tmpl-outside2.C: Tweak, error in C++98.
* g++.dg/parse/tmpl-outside1.C: Likewise.
* g++.dg/template/qualttp18.C: Likewise.
* g++.old-deja/g++.pt/memtemp87.C: Likewise.
* g++.old-deja/g++.pt/overload13.C: Likewise.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/parse/tmpl-outside1.C
trunk/gcc/testsuite/g++.dg/parse/tmpl-outside2.C
trunk/gcc/testsuite/g++.dg/template/qualttp18.C
trunk/gcc/testsuite/g++.old-deja/g++.pt/memtemp87.C
trunk/gcc/testsuite/g++.old-deja/g++.pt/overload13.C
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-10-15 19:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15 4:34 [Bug c++/50080] New: error: 'template' (as a disambiguator) is only allowed within templates solodon at mail dot com
2011-08-15 9:07 ` [Bug c++/50080] [C++0x] " redi at gcc dot gnu.org
2012-01-28 5:56 ` pinskia at gcc dot gnu.org
2012-01-28 6:14 ` [Bug c++/50080] [DR 468] " pinskia at gcc dot gnu.org
2012-10-05 16:15 ` paolo.carlini at oracle dot com
2012-10-15 16:48 ` paolo at gcc dot gnu.org
2012-10-15 16:49 ` paolo.carlini at oracle dot com
2012-10-15 19:14 ` paolo at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).