diff options
author | Jason Merrill <jason@redhat.com> | 2009-03-31 17:50:03 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-03-31 17:50:03 -0400 |
commit | 51fc2d02c702abb039402ad02dd11ddaf39c1045 (patch) | |
tree | b19c1e8906a07afb485b4b834d248c7570bf6ea9 /gcc | |
parent | 824523999285e704ff2c549d8dbd8d20bb1c6ac0 (diff) | |
download | gcc-51fc2d02c702abb039402ad02dd11ddaf39c1045.zip gcc-51fc2d02c702abb039402ad02dd11ddaf39c1045.tar.gz gcc-51fc2d02c702abb039402ad02dd11ddaf39c1045.tar.bz2 |
C++ DR 613
C++ DR 613
* semantics.c (finish_non_static_data_member): Allow such references
without an associated object in sizeof/decltype/alignof.
From-SVN: r145375
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype3.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.ext/typeof2.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/sizeof2.C | 8 |
6 files changed, 34 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 21a5f07..adb5be3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5357077..038715b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 99a310b..b5f3099 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -26,6 +26,12 @@ 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 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype3.C b/gcc/testsuite/g++.dg/cpp0x/decltype3.C index 556ae70..6958afd 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype3.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype3.C @@ -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 }; diff --git a/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C b/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C index 2cc0d1c..008ecf6 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C @@ -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 (); }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C index d8ac60dd..cb3c9bb 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C @@ -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 } |