aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-01-21 16:14:49 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-01-21 17:14:49 +0100
commitd597b3ce68d904078ca38bca09c5e8984d934364 (patch)
tree9c26f4fbfa6128e66099ace4205d1bd99cc4c3a3 /gcc/cp/decl2.c
parent210879b85b09194934eabcf5777cf2cff6e8dedc (diff)
downloadgcc-d597b3ce68d904078ca38bca09c5e8984d934364.zip
gcc-d597b3ce68d904078ca38bca09c5e8984d934364.tar.gz
gcc-d597b3ce68d904078ca38bca09c5e8984d934364.tar.bz2
re PR c++/26693 (Access checks not performed for types in templates)
gcc/ChangeLog: 2009-01-21 Dodji Seketeli <dodji@redhat.com> PR c++/26693 * c-decl.c: (clone_underlying_type): Move this ... * c-common.c (set_underlying_type): ... here. Also, make sure the function properly sets TYPE_STUB_DECL() on the newly created typedef variant type. (is_typedef_decl ): New entry point. * tree.h: Added a new member member_types_needing_access_check to struct tree_decl_non_common. (set_underlying_type): New entry point. (is_typedef_type): Likewise. gcc/cp/ChangeLog/ 2009-01-21 Dodji Seketeli <dodji@redhat.com> PR c++/26693 * decl2.c (grokfield): when a typedef appears in a class, create the typedef variant type node for it. (save_template_attributes): Creating typedef variant type node here is now useless. * decl.c (grokdeclarator): If the typedef'ed struct/class was anonymous, set the proper type name to all its type variants. * name-lookup.c (pushdecl_maybe_friend): Reuse the set_underlying_type function to install typedef variant types. * cp-tree.h (MEMBER_TYPES_NEEDING_ACCESS_CHECK): New template accessor macro. (append_type_to_template_for_access_check): New entry points. * semantics.c (check_accessibility_of_qualified_id): When a typedef that is a member of a class appears in a template, add it to the template. It will be ... * pt.c (instantiate_class_template, instantiate_template ): ... access checked at template instantiation time. (tsubst): Handle the case of being called with NULL args. (resolve_type_name_type): The type name should be the name of the main type variant. (append_type_to_template_for_access_check): New entry point. gcc/testsuite/ChangeLog 2009-01-21 Dodji Seketeli <dodji@redhat.com> PR c++/26693 * g++.dg/template/typedef11.C: New test. * g++.dg/template/typedef12.C: Likewise. * g++.dg/template/typedef13.C: Likewise. * g++.dg/template/typedef14.C: Likewise. * g++.dg/template/sfinae3.C: Compile this pedantically. The only errors expected should be the one saying the typedef is ill formed. * g++.old-deja/g++.pt/typename8.C: Likewise. * g++.dg/template/access11.C: Update this. libstdc++-v3/ChangeLog: 2009-01-21 Dodji Seketeli <dodji@redhat.com> * include/ext/bitmap_allocator.h: the typedefs should be made public if we want them to be accessible. This has been revealed by the patch that fixes PR c++/26693 in g++. From-SVN: r143546
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index c888725..22192a0 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -804,6 +804,9 @@ grokfield (const cp_declarator *declarator,
DECL_NONLOCAL (value) = 1;
DECL_CONTEXT (value) = current_class_type;
+ if (declspecs->specs[(int)ds_typedef])
+ set_underlying_type (value);
+
if (processing_template_decl)
value = push_template_decl (value);
@@ -1125,19 +1128,6 @@ save_template_attributes (tree *attr_p, tree *decl_p)
if (!late_attrs)
return;
- /* Give this type a name so we know to look it up again at instantiation
- time. */
- if (TREE_CODE (*decl_p) == TYPE_DECL
- && DECL_ORIGINAL_TYPE (*decl_p) == NULL_TREE)
- {
- tree oldt = TREE_TYPE (*decl_p);
- tree newt = build_variant_type_copy (oldt);
- DECL_ORIGINAL_TYPE (*decl_p) = oldt;
- TREE_TYPE (*decl_p) = newt;
- TYPE_NAME (newt) = *decl_p;
- TREE_USED (newt) = TREE_USED (*decl_p);
- }
-
if (DECL_P (*decl_p))
q = &DECL_ATTRIBUTES (*decl_p);
else