diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-05-29 11:51:13 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-05-29 11:51:13 +0000 |
commit | 724e517a7df51aa4921704083ef78a7a41999198 (patch) | |
tree | 731a7b08e739a79a9e0ce5c33bf9b7e2e7579620 /gcc | |
parent | 0a71c876a1ed4331002cdd3c09d09252de4d5d89 (diff) | |
download | gcc-724e517a7df51aa4921704083ef78a7a41999198.zip gcc-724e517a7df51aa4921704083ef78a7a41999198.tar.gz gcc-724e517a7df51aa4921704083ef78a7a41999198.tar.bz2 |
PR c++/80891 (#2)
PR c++/80891 (#2)
* tree.c (ovl_copy): Adjust assert, copy OVL_LOOKUP.
(ovl_used): New.
(lookup_keep): Call it.
PR c++/80891 (#2)
* g++.dg/lookup/pr80891-2.C: New.
From-SVN: r248570
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/tree.c | 27 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/pr80891-2.C | 29 |
4 files changed, 64 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e3530f..8f5dbc3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-05-26 Nathan Sidwell <nathan@acm.org> + PR c++/80891 (#2) + * tree.c (ovl_copy): Adjust assert, copy OVL_LOOKUP. + (ovl_used): New. + (lookup_keep): Call it. + Implement DR2061 * name-lookup.c (push_inline_namespaces): New. (push_namespace): Look inside inline namespaces. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 343708f..9951b28 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2139,12 +2139,13 @@ ovl_copy (tree ovl) else result = make_node (OVERLOAD); - gcc_assert (!OVL_NESTED_P (ovl) && !OVL_LOOKUP_P (ovl)); + gcc_checking_assert (!OVL_NESTED_P (ovl) && OVL_USED_P (ovl)); TREE_TYPE (result) = TREE_TYPE (ovl); OVL_FUNCTION (result) = OVL_FUNCTION (ovl); OVL_CHAIN (result) = OVL_CHAIN (ovl); OVL_HIDDEN_P (result) = OVL_HIDDEN_P (ovl); OVL_USING_P (result) = OVL_USING_P (ovl); + OVL_LOOKUP_P (result) = OVL_LOOKUP_P (ovl); return result; } @@ -2395,6 +2396,22 @@ lookup_maybe_add (tree fns, tree lookup) return lookup_add (fns, lookup); } +/* Regular overload OVL is part of a kept lookup. Mark the nodes on + it as immutable. */ + +static void +ovl_used (tree ovl) +{ + for (; + ovl && TREE_CODE (ovl) == OVERLOAD + && !OVL_USED_P (ovl); + ovl = OVL_CHAIN (ovl)) + { + gcc_checking_assert (!OVL_LOOKUP_P (ovl)); + OVL_USED_P (ovl) = true; + } +} + /* If KEEP is true, preserve the contents of a lookup so that it is available for a later instantiation. Otherwise release the LOOKUP nodes for reuse. */ @@ -2407,12 +2424,18 @@ lookup_keep (tree lookup, bool keep) && OVL_LOOKUP_P (lookup) && !OVL_USED_P (lookup); lookup = OVL_CHAIN (lookup)) if (keep) - OVL_USED_P (lookup) = true; + { + OVL_USED_P (lookup) = true; + ovl_used (OVL_FUNCTION (lookup)); + } else { OVL_FUNCTION (lookup) = ovl_cache; ovl_cache = lookup; } + + if (keep) + ovl_used (lookup); } /* Returns nonzero if X is an expression for a (possibly overloaded) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index accf635..b3f6773 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-29 Nathan Sidwell <nathan@acm.org> + + PR c++/80891 (#2) + * g++.dg/lookup/pr80891-2.C: New. + 2017-05-29 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/37131 diff --git a/gcc/testsuite/g++.dg/lookup/pr80891-2.C b/gcc/testsuite/g++.dg/lookup/pr80891-2.C new file mode 100644 index 0000000..fa48b0b --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr80891-2.C @@ -0,0 +1,29 @@ +// PR c++/80891 part 1 +// instantiation-time ADL for swap needs to copy a previous lookup +// node, but gets confused. + +void swap(); + +namespace boost { + void swap(); +} + +using namespace boost; + +template <typename T> +void reversible_container_test () +{ + using namespace boost; + T a; + swap (a); +} + +namespace boost { + struct A {}; + template <typename T> void swap(T); +} + +void test_ptr_vector() +{ + reversible_container_test<A>; +} |