This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch] PR 28293


Hi,

this is not a regression, but a rather annoying segmentation fault because no error messages are emitted at all. The fix is simple, but certainly a review is needed about the exact wording of the error message, for example. Tested x86_64-linux.

Paolo.

///////////////
/cp
2008-08-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/28293
	* decl.c (grokfield): Check for explicit template argument lists.

/testsuite
2008-08-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/28293
	* g++.dg/template/crash82.C: New.
Index: testsuite/g++.dg/template/crash82.C
===================================================================
*** testsuite/g++.dg/template/crash82.C	(revision 0)
--- testsuite/g++.dg/template/crash82.C	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ // PR c++/28293
+ 
+ template<int> void foo();
+ 
+ struct A
+ {
+   typedef void foo<0>(); // { dg-error "error: explicit template argument list not allowed" } 
+ };
Index: cp/decl2.c
===================================================================
*** cp/decl2.c	(revision 139126)
--- cp/decl2.c	(working copy)
*************** grokfield (const cp_declarator *declarat
*** 758,763 ****
--- 758,764 ----
    tree value;
    const char *asmspec = 0;
    int flags = LOOKUP_ONLYCONVERTING;
+   tree name;
  
    if (init
        && TREE_CODE (init) == TREE_LIST
*************** grokfield (const cp_declarator *declarat
*** 786,796 ****
        && DECL_CONTEXT (value) != current_class_type)
      return value;
  
!   if (DECL_NAME (value) != NULL_TREE
!       && IDENTIFIER_POINTER (DECL_NAME (value))[0] == '_'
!       && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value)), "_vptr"))
!     error ("member %qD conflicts with virtual function table field name",
! 	   value);
  
    /* Stash away type declarations.  */
    if (TREE_CODE (value) == TYPE_DECL)
--- 787,807 ----
        && DECL_CONTEXT (value) != current_class_type)
      return value;
  
!   name = DECL_NAME (value);
! 
!   if (name != NULL_TREE)
!     {
!       if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
! 	{
! 	  error ("explicit template argument list not allowed");
! 	  return error_mark_node;
! 	}
! 
!       if (IDENTIFIER_POINTER (name)[0] == '_'
! 	  && ! strcmp (IDENTIFIER_POINTER (name), "_vptr"))
! 	error ("member %qD conflicts with virtual function table field name",
! 	       value);
!     }
  
    /* Stash away type declarations.  */
    if (TREE_CODE (value) == TYPE_DECL)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]