summaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-23 22:36:54 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-23 22:36:54 +0000
commit88a3ea34080ad3087a8191fbf479543153175d59 (patch)
tree34eaec34d3588e09f9a77abba776266f124dc823 /gcc/cp/name-lookup.c
parent25e15aaed275cdfef34b3ee6eb3cb4b43a48d44f (diff)
parente65055a558093bd4fc0b1b0024b7814cc187b8e8 (diff)
downloadgccgo.tar.gz
Merge from trunk revision 257954.gccgo
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gccgo@257955 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index e5a34003702..9117e0b30eb 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3071,6 +3071,7 @@ do_pushdecl (tree decl, bool is_friend)
old = OVL_CHAIN (old);
check_template_shadow (decl);
+ bool visible_injection = false;
if (DECL_DECLARES_FUNCTION_P (decl))
{
@@ -3079,14 +3080,20 @@ do_pushdecl (tree decl, bool is_friend)
if (is_friend)
{
if (level->kind != sk_namespace)
- /* In a local class, a friend function declaration must
- find a matching decl in the innermost non-class scope.
- [class.friend/11] */
- error ("friend declaration %qD in local class without "
- "prior local declaration", decl);
- else if (!flag_friend_injection)
+ {
+ /* In a local class, a friend function declaration must
+ find a matching decl in the innermost non-class scope.
+ [class.friend/11] */
+ error ("friend declaration %qD in local class without "
+ "prior local declaration", decl);
+ /* Don't attempt to push it. */
+ return error_mark_node;
+ }
+ if (!flag_friend_injection)
/* Hide it from ordinary lookup. */
DECL_ANTICIPATED (decl) = DECL_HIDDEN_FRIEND_P (decl) = true;
+ else
+ visible_injection = true;
}
}
@@ -3138,6 +3145,9 @@ do_pushdecl (tree decl, bool is_friend)
}
else if (VAR_P (decl))
maybe_register_incomplete_var (decl);
+ else if (visible_injection)
+ warning (0, "injected friend %qD is visible"
+ " due to %<-ffriend-injection%>", decl);
if ((VAR_P (decl) || TREE_CODE (decl) == FUNCTION_DECL)
&& DECL_EXTERN_C_P (decl))