]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39070 (ICE with typeof() (... and __decltype))
authorJason Merrill <jason@redhat.com>
Fri, 13 Feb 2009 19:14:07 +0000 (14:14 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Feb 2009 19:14:07 +0000 (14:14 -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: r144161

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 7ead4b21c8285d57d56c92c54c5418f9c418a860..d9d6866e3ad48c62bd05589d77bdd1d423f25f24 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-12  Jason Merrill  <jason@redhat.com>
 
        PR c++/38950
index 5a9b891668fb6b41d692be0bfb8f4a4288620f79..b23a3963d4476a9086b92a3df5acfda25ad6d342 100644 (file)
@@ -4757,7 +4757,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
                                                 tsubst_flags_t);
 extern tree finish_increment_expr              (tree, enum tree_code);
 extern tree finish_this_expr                   (void);
index db8886c0d6cc4e7082219cb31f62b5b58be3fb8f..81eaffef57a3f4e2452c4cdadc7a74b2cf7c835b 100644 (file)
@@ -11404,12 +11404,12 @@ tsubst_copy_and_build (tree t,
                       /*fn_p=*/NULL,
                       complain));
          }
-       /* 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,
                                 complain);
       }
 
index 55b0bae6cbb32643a3e804ad0073edeed7fcfb60..dfff09bb0af92fc51a43cddcafb3ca0a06e53566 100644 (file)
@@ -1839,10 +1839,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,
                  tsubst_flags_t complain)
 {
   tree result;
@@ -1865,7 +1869,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
@@ -1955,7 +1959,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, complain);
+       result = build_new_function_call (fn, args, koenig_p != 0, complain);
     }
   else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR)
     {
index 7908894a7f8c4c995251c9da8492b8b1067fad97..d3f7ed7f84155270fa3f4c5d822e56813b4917ee 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  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/39152
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];