Hi,while I was working on some location issues I noticed this check which seems obsolete to me and means that we unnecessarily reject kosher code: indeed we don't test for it anywhere and neither ICC nor clang enforce it. I also went through the SVN history and the check is *extremely* old, I think rms is the last person who touched it. The location fix is rather obvious (in principle we could do the same for the check I'm proposing to remove).
Tested 86_64-linux. Thanks, Paolo. /////////////////////
/cp 2018-11-17 Paolo Carlini <paolo.carl...@oracle.com> * decl2.c (grokfield): Remove obsolete _vptr check; fix explicit template argument list error location. /testsuite 2018-11-17 Paolo Carlini <paolo.carl...@oracle.com> * g++.dg/template/crash91.C: Check location too.
Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 266233) +++ cp/decl2.c (working copy) @@ -804,7 +804,6 @@ grokfield (const cp_declarator *declarator, tree value; const char *asmspec = 0; int flags; - tree name; if (init && TREE_CODE (init) == TREE_LIST @@ -829,21 +828,12 @@ grokfield (const cp_declarator *declarator, if (value == void_type_node) return value; - - name = DECL_NAME (value); - - if (name != NULL_TREE) + if (DECL_NAME (value) + && TREE_CODE (DECL_NAME (value)) == TEMPLATE_ID_EXPR) { - if (TREE_CODE (name) == TEMPLATE_ID_EXPR) - { - error ("explicit template argument list not allowed"); - return error_mark_node; - } - - if (IDENTIFIER_POINTER (name)[0] == '_' - && id_equal (name, "_vptr")) - error ("member %qD conflicts with virtual function table field name", - value); + error_at (declarator->id_loc, + "explicit template argument list not allowed"); + return error_mark_node; } /* Stash away type declarations. */ Index: testsuite/g++.dg/template/crash91.C =================================================================== --- testsuite/g++.dg/template/crash91.C (revision 266231) +++ testsuite/g++.dg/template/crash91.C (working copy) @@ -4,5 +4,5 @@ template<int> void foo(); struct A { - typedef void foo<0>(); // { dg-error "explicit template argument list not allowed" } + typedef void foo<0>(); // { dg-error "16:explicit template argument list not allowed" } };