]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39070 (ICE with typeof() (... and __decltype))
authorJason Merrill <jason@gcc.gnu.org>
Fri, 13 Feb 2009 21:53:38 +0000 (16:53 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Feb 2009 21:53:38 +0000 (16:53 -0500)
        PR c++/39070
        * semantics.c (finish_call_expr): Change koenig_p parm to int.
        If -1, don't set KOENIG_LOOKUP_P but do keep hidden candidates.
        * cp-tree.h: Adjust prototype.
        * pt.c (tsubst_copy_and_build) [CALL_EXPR]: Pass -1.

From-SVN: r144166

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype16.C [new file with mode: 0644]

index f19a0fde93d74fd9dcfb92ca92b07d502e9721fc..d509ced7ff9a1c9e29a2295815e59b9041342736 100644 (file)
@@ -1,3 +1,11 @@
+2009-02-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39070
+       * semantics.c (finish_call_expr): Change koenig_p parm to int.
+       If -1, don't set KOENIG_LOOKUP_P but do keep hidden candidates.
+       * cp-tree.h: Adjust prototype.
+       * pt.c (tsubst_copy_and_build) [CALL_EXPR]: Pass -1.
+
 2009-02-03  Paolo Bonzini  <bonzini@gnu.org>
 
        PR c++/36897
index 8bb4bc86a351620bc4a3d849f6713d8f7e0d1291..0872280a39b6980813d61014687eb76ecdeee8f3 100644 (file)
@@ -4623,7 +4623,7 @@ extern tree finish_stmt_expr_expr         (tree, tree);
 extern tree finish_stmt_expr                   (tree, bool);
 extern tree stmt_expr_value_expr               (tree);
 extern tree perform_koenig_lookup              (tree, tree);
-extern tree finish_call_expr                   (tree, tree, bool, bool);
+extern tree finish_call_expr                   (tree, tree, bool, int);
 extern tree finish_increment_expr              (tree, enum tree_code);
 extern tree finish_this_expr                   (void);
 extern tree finish_pseudo_destructor_expr       (tree, tree, tree);
index 7f4a5a2cfdc80ff16416f4a689ccdf69cb0296c4..737a9a69af6278dbfb9a2f161e3fed7d5a4a4be3 100644 (file)
@@ -11061,12 +11061,12 @@ tsubst_copy_and_build (tree t,
                       qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL,
                       /*fn_p=*/NULL));
          }
-       /* Pass true for koenig_p so that build_new_function_call will
+       /* Pass -1 for koenig_p so that build_new_function_call will
           allow hidden friends found by arg-dependent lookup at template
           parsing time.  */
        return finish_call_expr (function, call_args,
                                 /*disallow_virtual=*/qualified_p,
-                                /*koenig_p*/true);
+                                /*koenig_p*/-1);
       }
 
     case COND_EXPR:
index dbd5e0fb2c110492312ddef7e4c22527b5e1da1a..6df17c6bf7156271ac9ac6466a1ec106218b2455 100644 (file)
@@ -1832,10 +1832,14 @@ perform_koenig_lookup (tree fn, tree args)
    qualified.  For example a call to `X::f' never generates a virtual
    call.)
 
+   KOENIG_P is 1 if we want to perform argument-dependent lookup,
+   -1 if we don't, but we want to accept functions found by previous
+   argument-dependent lookup, and 0 if we want nothing to do with it.
+
    Returns code for the call.  */
 
 tree
-finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
+finish_call_expr (tree fn, tree args, bool disallow_virtual, int koenig_p)
 {
   tree result;
   tree orig_fn;
@@ -1857,7 +1861,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
          || any_type_dependent_arguments_p (args))
        {
          result = build_nt_call_list (fn, args);
-         KOENIG_LOOKUP_P (result) = koenig_p;
+         KOENIG_LOOKUP_P (result) = koenig_p > 0;
          if (cfun)
            {
              do
@@ -1946,7 +1950,7 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
 
       if (!result)
        /* A call to a namespace-scope function.  */
-       result = build_new_function_call (fn, args, koenig_p);
+       result = build_new_function_call (fn, args, koenig_p != 0);
     }
   else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR)
     {
index 288e79e9951a43f520cb789c6ae9a38b663b1305..c62385b4d7700a0109544473154718046981348c 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39070
+       * g++.dg/cpp0x/decltype16.C: New.
+
 2009-02-13  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/35444
@@ -7,7 +12,7 @@
 2009-02-10  Steve Ellcey  <sje@cup.hp.com>
 
        PR c/39084
-       gcc.dg/pr39084.c: New test.
+       gcc.dg/pr39084.c: New test.
 
 2009-02-09  Janis Johnson  <janis187@us.ibm.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype16.C b/gcc/testsuite/g++.dg/cpp0x/decltype16.C
new file mode 100644 (file)
index 0000000..2002458
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/39070
+// { dg-options "-std=c++0x" }
+
+template<typename X> struct junk {
+   template<typename Z> static Z y();
+   template<typename Y> static int  test(...);
+   template<typename Y> static char test(decltype(y<Y>())*);
+   static int const value=sizeof(test<X>(0));
+};
+typedef char type[junk<int>::value==sizeof(char) ? 1 : -1];