aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-09-17 23:42:55 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-09-17 23:42:55 +0000
commit8458320833c8fbfb61d9261c411ce072461b639b (patch)
tree14040f001616060e51ea3ed9d68ba773cbc87412 /gcc
parent47aa0df47504bd7a24c0e5e3110e927233e4a96d (diff)
downloadgcc-8458320833c8fbfb61d9261c411ce072461b639b.zip
gcc-8458320833c8fbfb61d9261c411ce072461b639b.tar.gz
gcc-8458320833c8fbfb61d9261c411ce072461b639b.tar.bz2
re PR c++/12266 (incorrect instantiation of unneeded template during overload resolution)
PR c++/12266 * cp-tree.h (tsubst_flags_t): Add tf_conv. * class.c (standard_conversion): Pass tf_conv to instantiate_type. (resolve_address_of_overloaded_function): Do not call mark_used when just checking conversions. PR c++/12266 * g++.dg/overload/template1.C: New test. From-SVN: r71483
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c2
-rw-r--r--gcc/cp/class.c8
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/overload/template1.C12
6 files changed, 37 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 24f82d7..7d3ddc3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2003-09-17 Mark Mitchell <mark@codesourcery.com>
+ PR c++/12266
+ * cp-tree.h (tsubst_flags_t): Add tf_conv.
+ * class.c (standard_conversion): Pass tf_conv to
+ instantiate_type.
+ (resolve_address_of_overloaded_function): Do not call mark_used
+ when just checking conversions.
+
PR debug/12066
* cp-lang.c (LANG_HOOKS_BUILTIN_TYPE_DECLS): Define.
* cp-tree.h (cxx_builtin_type_decls): Declare.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 214fbae..4f86cc6 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -593,7 +593,7 @@ standard_conversion (tree to, tree from, tree expr)
if ((TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to))
&& expr && type_unknown_p (expr))
{
- expr = instantiate_type (to, expr, tf_none);
+ expr = instantiate_type (to, expr, tf_conv);
if (expr == error_mark_node)
return NULL_TREE;
from = TREE_TYPE (expr);
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1809f2d..b76e7db 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5937,7 +5937,13 @@ cannot resolve overloaded function `%D' based on conversion to type `%T'",
explained = 1;
}
}
- mark_used (fn);
+
+ /* If we're doing overload resolution purely for the purpose of
+ determining conversion sequences, we should not consider the
+ function used. If this conversion sequence is selected, the
+ function will be marked as used at this point. */
+ if (!(flags & tf_conv))
+ mark_used (fn);
if (TYPE_PTRFN_P (target_type) || TYPE_PTRMEMFUNC_P (target_type))
return build_unary_op (ADDR_EXPR, fn, 0);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dfa298f..ef38d55 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3034,9 +3034,13 @@ typedef enum tsubst_flags_t {
(lookup_template_class use) */
tf_stmt_expr_cmpd = 1 << 6, /* tsubsting the compound statement of
a statement expr. */
- tf_stmt_expr_body = 1 << 7 /* tsubsting the statements in the
+ tf_stmt_expr_body = 1 << 7, /* tsubsting the statements in the
body of the compound statement of a
statement expr. */
+ tf_conv = 1 << 8 /* We are determining what kind of
+ conversion might be permissible,
+ not actually performing the
+ conversion. */
} tsubst_flags_t;
/* The kind of checking we can do looking in a class hierarchy. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fae6be7..2bd53c5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-17 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/12266
+ * g++.dg/overload/template1.C: New test.
+
2003-09-17 Eric Botcazou <ebotcazou@libertysurf.fr>
* g++.dg/opt/cfg3.C: New test.
diff --git a/gcc/testsuite/g++.dg/overload/template1.C b/gcc/testsuite/g++.dg/overload/template1.C
new file mode 100644
index 0000000..5bfad84
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/template1.C
@@ -0,0 +1,12 @@
+template<typename T> T Foo (int) {T d;}
+
+void Baz (void (*)(int), int);
+
+int Foo ();
+int Baz (int (*)(), float);
+
+void Bar ()
+{
+ Baz (Foo, 1.0f);
+
+}