public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ice-on-invalid calling get_unwidened (error_mark_node, ) (PR c++/32567)
@ 2007-08-21 18:53 Jakub Jelinek
  2007-08-24  1:14 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-08-21 18:53 UTC (permalink / raw)
  To: gcc-patches

Hi!

On the following testcase the FE is calling get_unwidened on
error_mark_node.  As that is not a FE routine, but used by the tree
optimizers as well, I think it is better to avoid calling it with
error_mark_node instead of changing get_unwidened to pass through
error_mark_node.

Ok for trunk?

2007-08-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/32567
	* typeck.c (build_unary_op) <case PREINCREMENT_EXPR>: Return
	error_mark_node right away if build_expr_type_conversion
	returned it.

--- gcc/cp/typeck.c.jj	2007-08-21 08:13:43.000000000 +0200
+++ gcc/cp/typeck.c	2007-08-21 19:31:44.000000000 +0200
@@ -4259,6 +4259,8 @@ build_unary_op (enum tree_code code, tre
 	    errstring ="no post-decrement operator for type";
 	  break;
 	}
+      else if (arg == error_mark_node)
+	return error_mark_node;
 
       /* Report something read-only.  */
 
--- gcc/testsuite/g++.dg/parse/crash36.C.jj	2007-08-21 19:33:27.000000000 +0200
+++ gcc/testsuite/g++.dg/parse/crash36.C	2007-08-21 19:38:31.000000000 +0200
@@ -0,0 +1,11 @@
+// PR c++/32567
+// { dg-do compile }
+// { dg-options "-std=c++98" }
+
+template <typename... T> struct A	// { dg-error "does not include variadic templates" }
+{
+  static T &t;				// { dg-error "not expanded with|T" }
+  static const int i = sizeof (++t);	// { dg-error "invalid use of template type parameter" }
+};
+
+int x[A <int>::i];	// { dg-error "is not an integral constant-expression" }

	Jakub

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

* Re: [C++ PATCH] Fix ice-on-invalid calling get_unwidened (error_mark_node,  ) (PR c++/32567)
  2007-08-21 18:53 [C++ PATCH] Fix ice-on-invalid calling get_unwidened (error_mark_node, ) (PR c++/32567) Jakub Jelinek
@ 2007-08-24  1:14 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2007-08-24  1:14 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

Jakub Jelinek wrote:

> 2007-08-21  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/32567
> 	* typeck.c (build_unary_op) <case PREINCREMENT_EXPR>: Return
> 	error_mark_node right away if build_expr_type_conversion
> 	returned it.

This is OK.

FWIW, I'd actually do it the opposite way of what you suggested.  For
routines that are part of the middle-end API designed to be used by the
front end, accepting error_mark_nodes as inputs means that we don't have
to remember to check as many places in the front ends.  By being
generous in what we accept in the middle end, we'd make the compiler
more robust, at the expense of doing a bit of extra checking.

But, I'm happy to have the bug fixed, and it's not worth arguing about.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

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

end of thread, other threads:[~2007-08-24  1:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-21 18:53 [C++ PATCH] Fix ice-on-invalid calling get_unwidened (error_mark_node, ) (PR c++/32567) Jakub Jelinek
2007-08-24  1:14 ` Mark Mitchell

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).