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 to implement DR 613


Gerald Pfeifer wrote:
-ENOPATCH :-)

2009-03-31  Jason Merrill  <jason@redhat.com>

	C++ DR 613
	* semantics.c (finish_non_static_data_member): Allow such references
	without an associated object in sizeof/decltype/alignof.

Index: cp/semantics.c
===================================================================
*** cp/semantics.c	(revision 145360)
--- cp/semantics.c	(working copy)
*************** finish_non_static_data_member (tree decl
*** 1422,1427 ****
--- 1422,1437 ----
  {
    gcc_assert (TREE_CODE (decl) == FIELD_DECL);
  
+   if (!object && skip_evaluation)
+     {
+       /* DR 613: Can use non-static data members without an associated
+          object in sizeof/decltype/alignof.  */
+       tree scope = qualifying_scope;
+       if (scope == NULL_TREE)
+ 	scope = context_for_name_lookup (decl);
+       object = maybe_dummy_object (scope, NULL);
+     }
+ 
    if (!object)
      {
        if (current_function_decl
*************** finish_non_static_data_member (tree decl
*** 1433,1439 ****
  
        return error_mark_node;
      }
!   TREE_USED (current_class_ptr) = 1;
    if (processing_template_decl && !qualifying_scope)
      {
        tree type = TREE_TYPE (decl);
--- 1443,1450 ----
  
        return error_mark_node;
      }
!   if (current_class_ptr)
!     TREE_USED (current_class_ptr) = 1;
    if (processing_template_decl && !qualifying_scope)
      {
        tree type = TREE_TYPE (decl);
*************** finish_non_static_data_member (tree decl
*** 1443,1449 ****
        else
  	{
  	  /* Set the cv qualifiers.  */
! 	  int quals = cp_type_quals (TREE_TYPE (current_class_ref));
  
  	  if (DECL_MUTABLE_P (decl))
  	    quals &= ~TYPE_QUAL_CONST;
--- 1454,1462 ----
        else
  	{
  	  /* Set the cv qualifiers.  */
! 	  int quals = (current_class_ref
! 		       ? cp_type_quals (TREE_TYPE (current_class_ref))
! 		       : TYPE_UNQUALIFIED);
  
  	  if (DECL_MUTABLE_P (decl))
  	    quals &= ~TYPE_QUAL_CONST;
Index: testsuite/g++.old-deja/g++.other/sizeof2.C
===================================================================
*** testsuite/g++.old-deja/g++.other/sizeof2.C	(revision 145291)
--- testsuite/g++.old-deja/g++.other/sizeof2.C	(working copy)
***************
*** 3,15 ****
  
  struct S
  {
!   int j; // { dg-error "" } non-static data member
!   int i[2]; // { dg-error "" } non-static data member
  };
  
  void f ()
  {
!   sizeof (S::j); // { dg-error "" } used here
!   sizeof (S::i[0]); //  { dg-error "" } used here
  }
  
--- 3,15 ----
  
  struct S
  {
!   int j;
!   int i[2]; // { dg-error "" "" { xfail *-*-* } } non-static data member
  };
  
  void f ()
  {
!   sizeof (S::j);
!   sizeof (S::i[0]); //  { dg-error "" "" { xfail *-*-* } } used here
  }
  
Index: testsuite/g++.old-deja/g++.ext/typeof2.C
===================================================================
*** testsuite/g++.old-deja/g++.ext/typeof2.C	(revision 145291)
--- testsuite/g++.old-deja/g++.ext/typeof2.C	(working copy)
***************
*** 3,8 ****
  
  struct S
  {
!   int i; // { dg-error "" } non-static data member
!   __typeof( S::i ) f (); // { dg-error "" } referenced here
  };
--- 3,8 ----
  
  struct S
  {
!   int i;
!   __typeof( S::i ) f ();
  };
Index: testsuite/g++.dg/cpp0x/decltype3.C
===================================================================
*** testsuite/g++.dg/cpp0x/decltype3.C	(revision 145291)
--- testsuite/g++.dg/cpp0x/decltype3.C	(working copy)
*************** CHECK_DECLTYPE(decltype(caa.a), int);
*** 47,56 ****
  
  class B { 
  public:
!   int a;  // { dg-error "invalid use" }
    enum B_enum { b }; 
!   decltype(a) c; // { dg-error "from this location" }
!   decltype(a) foo() { } // { dg-error "from this location" }
    decltype(b) enums_are_in_scope() { return b; } // ok 
  }; 
  
--- 47,56 ----
  
  class B { 
  public:
!   int a;
    enum B_enum { b }; 
!   decltype(a) c;
!   decltype(a) foo() { }
    decltype(b) enums_are_in_scope() { return b; } // ok 
  }; 
  

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