diff options
author | Jason Merrill <jason@redhat.com> | 2009-07-14 18:15:35 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2009-07-14 18:15:35 +0000 |
commit | 3d8fc1f2c3cdda139202b0e89b3022c7d8805cf9 (patch) | |
tree | f913131dcfc39f5179b8168f8020117cb96dc13e | |
parent | 4b6ced858287f5d51621cf6b44bd38e5a8714774 (diff) |
PR c++/40740
* semantics.c (perform_koenig_lookup): Handle empty template args.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@149636 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/koenig8.C | 20 |
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 812349486ca..67bbc740f6c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index aa52a362fb7..61dff51ba75 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ec32f9e31aa..58ce71cf8a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/g++.dg/template/koenig8.C b/gcc/testsuite/g++.dg/template/koenig8.C new file mode 100644 index 00000000000..5a49a7066da --- /dev/null +++ b/gcc/testsuite/g++.dg/template/koenig8.C @@ -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; +} + |