OSDN Git Service

PR c++/40740
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jul 2009 18:15:35 +0000 (18:15 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jul 2009 18:15:35 +0000 (18:15 +0000)
* semantics.c (perform_koenig_lookup): Handle empty template args.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149636 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/koenig8.C [new file with mode: 0644]

index 8123494..67bbc74 100644 (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.
index aa52a36..61dff51 100644 (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;
 }
index ec32f9e..58ce71c 100644 (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
diff --git a/gcc/testsuite/g++.dg/template/koenig8.C b/gcc/testsuite/g++.dg/template/koenig8.C
new file mode 100644 (file)
index 0000000..5a49a70
--- /dev/null
@@ -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;
+}
+