aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-05-29 14:08:04 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-05-29 14:08:04 +0000
commite514ab0c32480f03cbba49160caa822e7e5b3c94 (patch)
tree36db105ffe2c19aa65a5d17c2074a3f14052c5ac /gcc
parent58dec010560be6fc090a2b5a65e5b4349b88748b (diff)
downloadgcc-e514ab0c32480f03cbba49160caa822e7e5b3c94.zip
gcc-e514ab0c32480f03cbba49160caa822e7e5b3c94.tar.gz
gcc-e514ab0c32480f03cbba49160caa822e7e5b3c94.tar.bz2
PR c++/80891 (#1)
PR c++/80891 (#1) * pt.c (most_specialized_instantiation): Cope with duplicate instantiations. PR c++/80891 (#1) * g++.dg/lookup/pr80891-1.C: New. From-SVN: r248573
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c41
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/lookup/pr80891-1.C19
4 files changed, 47 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 67d86fa..d538c3e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2017-05-29 Nathan Sidwell <nathan@acm.org>
+ PR c++/80891 (#1)
+ * pt.c (most_specialized_instantiation): Cope with duplicate
+ instantiations.
+
PR c++/80891 (#3)
* cp-tree.h (build_min_nt_call_vec): Declare.
* decl.c (build_offset_ref_call_from_tree): Call it.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9c423366..d3a0d7a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21728,31 +21728,32 @@ most_specialized_instantiation (tree templates)
champ = templates;
for (fn = TREE_CHAIN (templates); fn; fn = TREE_CHAIN (fn))
- {
- int fate = more_specialized_inst (TREE_VALUE (champ), TREE_VALUE (fn));
- if (fate == -1)
- champ = fn;
- else if (!fate)
- {
- /* Equally specialized, move to next function. If there
- is no next function, nothing's most specialized. */
- fn = TREE_CHAIN (fn);
+ if (TREE_VALUE (champ) != TREE_VALUE (fn))
+ {
+ int fate = more_specialized_inst (TREE_VALUE (champ), TREE_VALUE (fn));
+ if (fate == -1)
champ = fn;
- if (!fn)
- break;
- }
- }
+ else if (!fate)
+ {
+ /* Equally specialized, move to next function. If there
+ is no next function, nothing's most specialized. */
+ fn = TREE_CHAIN (fn);
+ champ = fn;
+ if (!fn)
+ break;
+ }
+ }
if (champ)
/* Now verify that champ is better than everything earlier in the
instantiation list. */
- for (fn = templates; fn != champ; fn = TREE_CHAIN (fn)) {
- if (more_specialized_inst (TREE_VALUE (champ), TREE_VALUE (fn)) != 1)
- {
- champ = NULL_TREE;
- break;
- }
- }
+ for (fn = templates; fn != champ; fn = TREE_CHAIN (fn))
+ if (TREE_VALUE (champ) != TREE_VALUE (fn)
+ && more_specialized_inst (TREE_VALUE (champ), TREE_VALUE (fn)) != 1)
+ {
+ champ = NULL_TREE;
+ break;
+ }
processing_template_decl--;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d8603f8a..98e06f9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2017-05-29 Nathan Sidwell <nathan@acm.org>
+ PR c++/80891 (#1)
+ * g++.dg/lookup/pr80891-1.C: New.
+
PR c++/80891 (#3)
* g++.dg/lookup/pr80891-3.C: New.
diff --git a/gcc/testsuite/g++.dg/lookup/pr80891-1.C b/gcc/testsuite/g++.dg/lookup/pr80891-1.C
new file mode 100644
index 0000000..725ca19
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/pr80891-1.C
@@ -0,0 +1,19 @@
+// PR c++/80891 part 1
+// std::endl is found via two paths and most_specialized_instantiation
+// gets confused.
+
+namespace std {
+ struct A {
+ void operator<<(A(A));
+ };
+ template <typename _CharT, typename _Traits> _CharT endl(_Traits);
+ A a;
+}
+
+using std::endl;
+
+void chi_squared_sample_sized()
+{
+ using namespace std;
+ a << endl;
+}