diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2019-02-13 19:08:52 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2019-02-13 19:08:52 +0000 |
commit | 10839133ce6c196c9f338086ede5b3b192fc1944 (patch) | |
tree | 54e2d383f0b27c7412bfbe76403065f4ca8ce94b /gcc/cp/search.c | |
parent | 60378a964a2a6b32b9d05de053e181d691f68d52 (diff) | |
download | gcc-10839133ce6c196c9f338086ede5b3b192fc1944.zip gcc-10839133ce6c196c9f338086ede5b3b192fc1944.tar.gz gcc-10839133ce6c196c9f338086ede5b3b192fc1944.tar.bz2 |
[PR86379] do not use TREE_TYPE for USING_DECL_SCOPE
It's too risky to reuse the type field for USING_DECL_SCOPE.
Language-independent parts of the compiler, such as location and
non-lvalue wrappers, happily take the TREE_TYPE of a USING_DECL as if
it was a type rather than an unrelated scope.
For better or worse, USING_DECLs use the non-common struct so we can
use the otherwise unused result field. Adjust fallout, from uses of
TREE_TYPE that were supposed to be USING_DECL_SCOPE, to other
accidental uses of TREE_TYPE of a USING_DECL.
for gcc/cp/ChangeLog
PR c++/86379
* cp-tree.h (USING_DECL_SCOPE): Use result rather than type.
* name-lookup.c (strip_using_decl): Use USING_DECL_SCOPE.
* search.c (protected_accessible_p): Follow USING_DECL_DECLS.
(shared_member_p): Likewise.
(lookup_member): Likewise.
* decl.c (grok_special_member_properties): Skip USING_DECLs.
* semantics.c (finish_omp_declare_simd_methods): Likewise.
(finish_qualified_id_expr): Do not call shared_member_p with
a dependent expr.
for gcc/testsuite/ChangeLog
PR c++/86379
* g++.dg/cpp0x/pr86379.C: New.
From-SVN: r268851
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r-- | gcc/cp/search.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0367e49..4c3fffd 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -623,6 +623,11 @@ protected_accessible_p (tree decl, tree derived, tree type, tree otype) if (!DERIVED_FROM_P (type, derived)) return 0; + /* DECL_NONSTATIC_MEMBER_P won't work for USING_DECLs. */ + decl = strip_using_decl (decl); + /* We don't expect or support dependent decls. */ + gcc_assert (TREE_CODE (decl) != USING_DECL); + /* [class.protected] When a friend or a member function of a derived class references @@ -928,8 +933,13 @@ shared_member_p (tree t) if (is_overloaded_fn (t)) { for (ovl_iterator iter (get_fns (t)); iter; ++iter) - if (DECL_NONSTATIC_MEMBER_FUNCTION_P (*iter)) - return 0; + { + tree decl = strip_using_decl (*iter); + /* We don't expect or support dependent decls. */ + gcc_assert (TREE_CODE (decl) != USING_DECL); + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)) + return 0; + } return 1; } return 0; @@ -1177,7 +1187,10 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type, && !really_overloaded_fn (rval)) { tree decl = is_overloaded_fn (rval) ? get_first_fn (rval) : rval; - if (!DECL_NONSTATIC_MEMBER_FUNCTION_P (decl) + decl = strip_using_decl (decl); + /* A dependent USING_DECL will be checked after tsubsting. */ + if (TREE_CODE (decl) != USING_DECL + && !DECL_NONSTATIC_MEMBER_FUNCTION_P (decl) && !perform_or_defer_access_check (basetype_path, decl, decl, complain, afi)) rval = error_mark_node; |