]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
C++ DR 613
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Mar 2009 21:50:03 +0000 (21:50 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 31 Mar 2009 21:50:03 +0000 (21:50 +0000)
        * semantics.c (finish_non_static_data_member): Allow such references
        without an associated object in sizeof/decltype/alignof.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145375 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype3.C
gcc/testsuite/g++.old-deja/g++.ext/typeof2.C
gcc/testsuite/g++.old-deja/g++.other/sizeof2.C

index 21a5f07f4145e77f5f3fc91cfa115cb9b6e1e051..adb5be358ad48f2bf9b02ff81f55bbae876c076d 100644 (file)
@@ -1,5 +1,9 @@
 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.
+
        * ptree.c (cxx_print_decl): Pretty-print full name of
        function/template.
        (cxx_print_type): Pretty-print full name of class.
index 5357077504221877fbfcdb4cc3f40cd3b8b2a5e1..038715ba2b11e4718facecc3d9bf9ca4e468b538 100644 (file)
@@ -1422,6 +1422,16 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
 {
   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
@@ -1433,7 +1443,8 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
 
       return error_mark_node;
     }
-  TREE_USED (current_class_ptr) = 1;
+  if (current_class_ptr)
+    TREE_USED (current_class_ptr) = 1;
   if (processing_template_decl && !qualifying_scope)
     {
       tree type = TREE_TYPE (decl);
@@ -1443,7 +1454,9 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
       else
        {
          /* Set the cv qualifiers.  */
-         int quals = cp_type_quals (TREE_TYPE (current_class_ref));
+         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 99a310be5ad091ba7ee05ad7d5c652aa2d26ca00..b5f3099288165e0d50b1d3a7e516b323312cc39d 100644 (file)
 
 2009-03-31  Jason Merrill  <jason@redhat.com>
 
+       C++ DR 613
+       * g++.old-deja/g++.dg/cpp0x/decltype3.C: Remove expected errors.
+       * g++.old-deja/g++.ext/typeof2.C: Remove expected errors.
+       * g++.old-deja/g++.other/sizeof2.C: Remove some expected errors,
+       xfail others.
+
        * g++.dg/other/typedef2.C: New test.
 
        PR c++/37806
index 556ae700320904b3b7f2530e825a68746112d2db..6958afd007103bee446f2047826ef01d7c1a086e 100644 (file)
@@ -47,10 +47,10 @@ CHECK_DECLTYPE(decltype(caa.a), int);
 
 class B { 
 public:
-  int a;  // { dg-error "invalid use" }
+  int a;
   enum B_enum { b }; 
-  decltype(a) c; // { dg-error "from this location" }
-  decltype(a) foo() { } // { dg-error "from this location" }
+  decltype(a) c;
+  decltype(a) foo() { }
   decltype(b) enums_are_in_scope() { return b; } // ok 
 }; 
 
index 2cc0d1cd8c996d0a4f4cf361c4024b8029398f87..008ecf6da0c27227730e0e85ee287ecd4bcfc445 100644 (file)
@@ -3,6 +3,6 @@
 
 struct S
 {
-  int i; // { dg-error "" } non-static data member
-  __typeof( S::i ) f (); // { dg-error "" } referenced here
+  int i;
+  __typeof( S::i ) f ();
 };
index d8ac60dd3c02242725cf6dcbbf09042013b750eb..cb3c9bb721f7113b7b4d1d8d7e76f764842f3daf 100644 (file)
@@ -3,13 +3,13 @@
 
 struct S
 {
-  int j; // { dg-error "" } non-static data member
-  int i[2]; // { dg-error "" } non-static data member
+  int j;
+  int i[2]; // { dg-error "" "" { xfail *-*-* } } non-static data member
 };
 
 void f ()
 {
-  sizeof (S::j); // { dg-error "" } used here
-  sizeof (S::i[0]); //  { dg-error "" } used here
+  sizeof (S::j);
+  sizeof (S::i[0]); //  { dg-error "" "" { xfail *-*-* } } used here
 }