public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Don't ICE if __decltype is called on CALL_EXPR with  type dependent CALL_EXPR_FN (PR c++/37540)
@ 2008-10-21 17:56 Jakub Jelinek
  2008-10-21 17:57 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2008-10-21 17:56 UTC (permalink / raw)
  To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches, Doug Gregor

Hi!

The recently added code to finish_decltype_type looks at CALL_EXPR_FN's
type, but as can be seen on the testcase below, if expr (the CALL_EXPR)
isn't type dependent (result type is known), CALL_EXPR_FN can still
be type dependent, can have NULL result type etc.

This patch handles that case the same as if the whole expr is type
dependent.  Alternatively patch could do:
-   if (type_dependent_expression_p (expr))
+   if (type_dependent_expression_p (expr)
+       || (TREE_CODE (expr) == CALL_EXPR
+	    && type_dependent_expression_p (CALL_EXPR_FN (expr))))

Ok for trunk if bootstrap/regtest passes?

2008-10-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/37540
	* semantics.c (finish_decltype_type): If CALL_EXPR_FN is
	type dependent, do the same as if expr is type dependent.

	* g++.dg/cpp0x/decltype13.C: New test.

--- gcc/cp/semantics.c.jj	2008-10-14 10:17:49.000000000 +0200
+++ gcc/cp/semantics.c	2008-10-21 17:58:54.000000000 +0200
@@ -4496,6 +4496,7 @@ finish_decltype_type (tree expr, bool id
 
   if (type_dependent_expression_p (expr))
     {
+    is_dependent_expr:
       type = cxx_make_type (DECLTYPE_TYPE);
       DECLTYPE_TYPE_EXPR (type) = expr;
       DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (type)
@@ -4609,7 +4610,9 @@ finish_decltype_type (tree expr, bool id
           tree fndecl = get_callee_fndecl (expr);
           if (fndecl && fndecl != error_mark_node)
             type = TREE_TYPE (TREE_TYPE (fndecl));
-          else 
+	  else if (type_dependent_expression_p (CALL_EXPR_FN (expr)))
+	    goto is_dependent_expr;
+	  else
             {
               tree target_type = TREE_TYPE (CALL_EXPR_FN (expr));
               if ((TREE_CODE (target_type) == REFERENCE_TYPE
--- gcc/testsuite/g++.dg/cpp0x/decltype13.C.jj	2008-10-21 18:01:40.000000000 +0200
+++ gcc/testsuite/g++.dg/cpp0x/decltype13.C	2008-10-21 18:00:58.000000000 +0200
@@ -0,0 +1,13 @@
+// PR c++/37540
+// { dg-do compile }
+
+struct A
+{
+  int g () { return 0; }
+};
+
+template <typename T> void
+f (A a)
+{
+  __decltype (a.g ()) i;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Don't ICE if __decltype is called on CALL_EXPR with  type dependent CALL_EXPR_FN (PR c++/37540)
  2008-10-21 17:56 [C++ PATCH] Don't ICE if __decltype is called on CALL_EXPR with type dependent CALL_EXPR_FN (PR c++/37540) Jakub Jelinek
@ 2008-10-21 17:57 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2008-10-21 17:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Mark Mitchell, gcc-patches, Doug Gregor

I don't see why CALL_EXPR_FN should be dependent in that testcase.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-21 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-21 17:56 [C++ PATCH] Don't ICE if __decltype is called on CALL_EXPR with type dependent CALL_EXPR_FN (PR c++/37540) Jakub Jelinek
2008-10-21 17:57 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).