diff options
author | Dodji Seketeli <dodji@redhat.com> | 2009-04-02 09:24:19 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2009-04-02 11:24:19 +0200 |
commit | d0940d56623ac8e6e6f43c873d039c2466bb6798 (patch) | |
tree | 4ae7dcdc112d00327f2e63a2d51dc32abfd729db /gcc/c-decl.c | |
parent | bf1cbdc6e43e3a62ef6ecac786ac70ecf5851ef6 (diff) | |
download | gcc-d0940d56623ac8e6e6f43c873d039c2466bb6798.zip gcc-d0940d56623ac8e6e6f43c873d039c2466bb6798.tar.gz gcc-d0940d56623ac8e6e6f43c873d039c2466bb6798.tar.bz2 |
re PR c++/26693 (Access checks not performed for types in templates)
gcc/ChangeLog:
2009-04-02 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.
* c-common.h (is_typedef_decl, set_underlying_type): Declare ...
* c-common.c (is_typedef_decl, set_underlying_type): ... new entry points.
gcc/cp/ChangeLog:
2009-04-02 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.
(xref_basetypes) : Fixup the variant types after setting
TYPE_BINFO on REF.
* 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 ...
* class.c (finish_struct_bits): Split type variant fixup into ...
(fixup_type_variants): A new entry point.
* pt.c (instantiate_class_template, instantiate_template ): ... access
checked at template instantiation time.
(resolve_type_name_type): The type name should be the name of the
main type variant.
(retrieve_specialization): Specializations of template typedefs aren't
to be looked up in DECL_TEMPLATE_INSTANTIATIONS (tmpl).
(append_type_to_template_for_access_check): New entry point.
(tsubst_decl): For typedefs, build the variant type from the correct
original type.
(get_class_bindings): Fix function comment.
(perform_typedefs_access_check): New entry point.
gcc/testsuite/ChangeLog:
2009-04-02 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/typedef15.C: Likewise.
* g++.dg/template/typedef16.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-04-02 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: r145440
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 63 |
1 files changed, 1 insertions, 62 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9202feb..8930d93 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2002,67 +2002,6 @@ warn_if_shadowing (tree new_decl) } } - -/* Subroutine of pushdecl. - - X is a TYPE_DECL for a typedef statement. Create a brand new - ..._TYPE node (which will be just a variant of the existing - ..._TYPE node with identical properties) and then install X - as the TYPE_NAME of this brand new (duplicate) ..._TYPE node. - - The whole point here is to end up with a situation where each - and every ..._TYPE node the compiler creates will be uniquely - associated with AT MOST one node representing a typedef name. - This way, even though the compiler substitutes corresponding - ..._TYPE nodes for TYPE_DECL (i.e. "typedef name") nodes very - early on, later parts of the compiler can always do the reverse - translation and get back the corresponding typedef name. For - example, given: - - typedef struct S MY_TYPE; - MY_TYPE object; - - Later parts of the compiler might only know that `object' was of - type `struct S' if it were not for code just below. With this - code however, later parts of the compiler see something like: - - struct S' == struct S - typedef struct S' MY_TYPE; - struct S' object; - - And they can then deduce (from the node for type struct S') that - the original object declaration was: - - MY_TYPE object; - - Being able to do this is important for proper support of protoize, - and also for generating precise symbolic debugging information - which takes full account of the programmer's (typedef) vocabulary. - - Obviously, we don't want to generate a duplicate ..._TYPE node if - the TYPE_DECL node that we are now processing really represents a - standard built-in type. */ - -static void -clone_underlying_type (tree x) -{ - if (DECL_IS_BUILTIN (x)) - { - if (TYPE_NAME (TREE_TYPE (x)) == 0) - TYPE_NAME (TREE_TYPE (x)) = x; - } - else if (TREE_TYPE (x) != error_mark_node - && DECL_ORIGINAL_TYPE (x) == NULL_TREE) - { - tree tt = TREE_TYPE (x); - DECL_ORIGINAL_TYPE (x) = tt; - tt = build_variant_type_copy (tt); - TYPE_NAME (tt) = x; - TREE_USED (tt) = TREE_USED (x); - TREE_TYPE (x) = tt; - } -} - /* Record a decl-node X as belonging to the current lexical scope. Check for errors (such as an incompatible declaration for the same name already seen in the same scope). @@ -2288,7 +2227,7 @@ pushdecl (tree x) skip_external_and_shadow_checks: if (TREE_CODE (x) == TYPE_DECL) - clone_underlying_type (x); + set_underlying_type (x); bind (name, x, scope, /*invisible=*/false, nested, locus); |