re PR c++/40740 (template-id forgotten with arg-dep lookup)

PR c++/40740
	* semantics.c (perform_koenig_lookup): Handle empty template args.

From-SVN: r149636
This commit is contained in:
Jason Merrill 2009-07-14 14:15:35 -04:00 committed by Jason Merrill
parent b35c816088
commit 4e6a97250c
4 changed files with 35 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2009-07-14 Jason Merrill <jason@redhat.com>
PR c++/40740
* semantics.c (perform_koenig_lookup): Handle empty template args.
2009-07-13 Jason Merrill <jason@redhat.com>
* call.c (build_over_call): Use can_trust_pointer_alignment.

View File

@ -1827,9 +1827,12 @@ perform_koenig_lookup (tree fn, VEC(tree,gc) *args)
tree identifier = NULL_TREE;
tree functions = NULL_TREE;
tree tmpl_args = NULL_TREE;
bool template_id = false;
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
{
/* Use a separate flag to handle null args. */
template_id = true;
tmpl_args = TREE_OPERAND (fn, 1);
fn = TREE_OPERAND (fn, 0);
}
@ -1861,8 +1864,8 @@ perform_koenig_lookup (tree fn, VEC(tree,gc) *args)
fn = unqualified_fn_lookup_error (identifier);
}
if (fn && tmpl_args)
fn = build_nt (TEMPLATE_ID_EXPR, fn, tmpl_args);
if (fn && template_id)
fn = build2 (TEMPLATE_ID_EXPR, unknown_type_node, fn, tmpl_args);
return fn;
}

View File

@ -1,3 +1,8 @@
2009-07-14 Jason Merrill <jason@redhat.com>
PR c++/40740
* g++.dg/template/koenig8.C: New.
2009-07-14 Jack Howarth <howarth@bromo.med.uc.edu>
* testsuite/gcc.c-torture/compile/20000804-1.c: skip for ilp32 on

View File

@ -0,0 +1,20 @@
// PR c++/40740
template<class T>
T addsome(T v) {
return v+1;
}
int addsome(int v) {
return v+2;
}
int main() {
int i = 0;
if (addsome(i) != 2)
return 1;
if (addsome<>(i) != 1)
return 2;
return 0;
}