aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
authorVille Voutilainen <ville.voutilainen@gmail.com>2016-05-27 17:59:01 +0300
committerVille Voutilainen <ville@gcc.gnu.org>2016-05-27 17:59:01 +0300
commit7d67159b48803e2558f33600e2f015f4e251a3e1 (patch)
tree5a2c297fd37b69d9c6efc9a705000ebc7a8bca8b /gcc/cp/name-lookup.c
parent9b2bf368d7983b683867656160b8f79870daeb97 (diff)
downloadgcc-7d67159b48803e2558f33600e2f015f4e251a3e1.zip
gcc-7d67159b48803e2558f33600e2f015f4e251a3e1.tar.gz
gcc-7d67159b48803e2558f33600e2f015f4e251a3e1.tar.bz2
re PR c++/69855 (Missing diagnostic for overload that only differs by return type)
/cp PR c++/69855 * name-lookup.c (pushdecl_maybe_friend_1): Push local function decls into the global scope after stripping template bits and setting DECL_ANTICIPATED. /testsuite PR c++/69855 * g++.dg/overload/69855.C: New. * g++.old-deja/g++.law/missed-error2.C: Adjust. * g++.old-deja/g++.pt/crash3.C: Likewise. From-SVN: r236826
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index eb128db..568c75e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -929,6 +929,24 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
DECL_ANTICIPATED (t) = 1;
DECL_HIDDEN_FRIEND_P (t) = 1;
}
+
+ if (TREE_CODE (x) == FUNCTION_DECL
+ && DECL_LOCAL_FUNCTION_P (x)
+ && !DECL_OMP_DECLARE_REDUCTION_P (x)
+ && !type_dependent_expression_p (x))
+ {
+ /* PR c++/69855, a local function declaration
+ is stripped from template info and pushed to
+ the local scope as a hidden declaration. This
+ allows ill-formed overloads even in other scopes
+ to be diagnosed both at the local declaration site
+ and after it. */
+ tree t2 = copy_decl (t);
+ DECL_USE_TEMPLATE (t2) = 0;
+ DECL_TEMPLATE_INFO (t2) = NULL_TREE;
+ DECL_ANTICIPATED (t2) = 1;
+ push_overloaded_decl (t2, PUSH_GLOBAL, is_friend);
+ }
}
if (t != x || DECL_FUNCTION_TEMPLATE_P (t))