Hi again...

On 17/11/18 12:56, Paolo Carlini wrote:
Never mind, got confused for various reasons... too bad anyway that we unconditionally reject such member name even when there is no virtual pointer around. Anyway, I'll send a new, straightforward patch only fixing the two locations.

... earlier today - I was running some errands - it occurred to me that, for example, gdb would have issues with a _vptr member, but that's not the case. Thus, all in all, I'm still not convinced that we want that old check. Anyway, in case we want to go for something super-safe at this stage, I'm attaching the promised patchlet only taking care of the locations.

Paolo.

/////////////////

Index: cp/decl2.c
===================================================================
--- cp/decl2.c  (revision 266233)
+++ cp/decl2.c  (working copy)
@@ -836,14 +836,16 @@ grokfield (const cp_declarator *declarator,
     {
       if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
        {
-         error ("explicit template argument list not allowed");
+         error_at (declarator->id_loc,
+                   "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,
+                 "member %qD conflicts with virtual function "
+                 "table field name", value);
     }
 
   /* Stash away type declarations.  */
Index: testsuite/g++.dg/other/vptr.C
===================================================================
--- testsuite/g++.dg/other/vptr.C       (nonexistent)
+++ testsuite/g++.dg/other/vptr.C       (working copy)
@@ -0,0 +1,4 @@
+struct S
+{
+  virtual void _vptr() = 0;  // { dg-error "16:member .virtual void 
S::_vptr\\(\\). conflicts with virtual function table field name" }
+};
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" } 
 };

Reply via email to