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]

Re: [C++ Patch] PR 34776


Hi,
> It's not a requirement for acceptance, but I think it would be even
> better to also (a) add a "gcc_assert (CLASS_TYPE_P (type))" to
> constructor_name_p, and (b) and change the documentation for
> constructor_name_p to say:
>
>  ... TYPE, which must be a class type.
>
> Those changes are pre-approved, provided they pass testing.
>   
Thanks. Actually, testing these changes revealed a nit: we can also have
TEMPLATE_TYPE_PARM, for example. I think IS_AGGR_TYPE is the proper
concept, right? I tested the below, on x86_64_linux.

Paolo.

////////////////////
/cp
2008-01-20  Paolo Carlini  <pcarlini@suse.de>

        PR c++/34776
	PR c++/34486
        * name-lookup.c (do_class_using_decl): Do not call constructor_name_p
	on non-aggregate type scope.
	(constructor_name_p): Assert IS_AGGR_TYPE.

/testsuite
2008-01-20  Paolo Carlini  <pcarlini@suse.de>

        PR c++/34776
	PR c++/34486
        * g++.dg/template/crash75.C: New.
        * g++.dg/template/crash76.C: Likewise.	
Index: testsuite/g++.dg/template/crash75.C
===================================================================
*** testsuite/g++.dg/template/crash75.C	(revision 0)
--- testsuite/g++.dg/template/crash75.C	(revision 0)
***************
*** 0 ****
--- 1,8 ----
+ // PR c++/34776
+ 
+ template<typename T> struct A
+ {
+   T::X<0> x; // { dg-error "non-template|T::template|base type" }
+ };
+ 
+ A<int*> a;
Index: testsuite/g++.dg/template/crash76.C
===================================================================
*** testsuite/g++.dg/template/crash76.C	(revision 0)
--- testsuite/g++.dg/template/crash76.C	(revision 0)
***************
*** 0 ****
--- 1,13 ----
+ // PR c++/34486
+ 
+ template<typename> struct A
+ {
+   typedef A* X;
+ };
+ 
+ template<typename T> struct B
+ {
+   using A<T>::X::Y; // { dg-error "not a base type" }
+ };
+ 
+ B<int> b;
Index: cp/name-lookup.c
===================================================================
*** cp/name-lookup.c	(revision 131679)
--- cp/name-lookup.c	(working copy)
*************** constructor_name (tree type)
*** 1730,1742 ****
    return name;
  }
  
! /* Returns TRUE if NAME is the name for the constructor for TYPE.  */
  
  bool
  constructor_name_p (tree name, tree type)
  {
    tree ctor_name;
  
    if (!name)
      return false;
  
--- 1730,1745 ----
    return name;
  }
  
! /* Returns TRUE if NAME is the name for the constructor for TYPE,
!    which must be an aggregate type.  */
  
  bool
  constructor_name_p (tree name, tree type)
  {
    tree ctor_name;
  
+   gcc_assert (IS_AGGR_TYPE (type));
+ 
    if (!name)
      return false;
  
*************** do_class_using_decl (tree scope, tree na
*** 2824,2830 ****
        error ("%<%T::%D%> names destructor", scope, name);
        return NULL_TREE;
      }
!   if (constructor_name_p (name, scope))
      {
        error ("%<%T::%D%> names constructor", scope, name);
        return NULL_TREE;
--- 2827,2833 ----
        error ("%<%T::%D%> names destructor", scope, name);
        return NULL_TREE;
      }
!   if (IS_AGGR_TYPE (scope) && constructor_name_p (name, scope))
      {
        error ("%<%T::%D%> names constructor", scope, name);
        return NULL_TREE;

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