Patchwork Move error_operand_p one level up

login
register
mail settings
Submitter Paolo Carlini
Date June 10, 2011, 9:58 a.m.
Message ID <4DF1EAC9.3010809@oracle.com>
Download mbox | patch
Permalink /patch/99864/
State New
Headers show

Comments

Paolo Carlini - June 10, 2011, 9:58 a.m.
Hi,

yesterday I noticed that, as I vaguely suspected for quite some time, 
error_operand_p can be useful also outside the c++ front-end. The below, 
which I bootstrapped c, c++, go, on x86_64-linux (and I'm finishing 
testing) tries to do that, moving the macro one level up and using it in 
all the suitable places I spotted.

What do people think?

Thanks,
Paolo.

////////////////////
/gcc/cp
2011-06-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* cp-tree.h (error_operand_p): Remove.

/gcc
2011-06-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* tree.h (error_operand_p): Add.
	* dbxout.c (dbxout_type_fields): Use the latter.
	* c-decl.c (add_stmt): Likewise.
	* gimplify.c (omp_add_variable, omp_notice_variable,
	gimplify_scan_omp_clauses): Likewise.

/gcc/go
2011-06-10  Paolo Carlini  <paolo.carlini@oracle.com>

	* gofrontend/expressions.cc (Expression::convert_for_assignment,
	Call_expression::do_get_tree,
	Struct_construction_expression::do_get_tree): Use error_operand_p.
Richard Guenther - June 10, 2011, 10:14 a.m.
On Fri, Jun 10, 2011 at 11:58 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> Hi,
>
> yesterday I noticed that, as I vaguely suspected for quite some time,
> error_operand_p can be useful also outside the c++ front-end. The below,
> which I bootstrapped c, c++, go, on x86_64-linux (and I'm finishing testing)
> tries to do that, moving the macro one level up and using it in all the
> suitable places I spotted.
>
> What do people think?

Ok if it bootstraps and tests.

Thanks,
Richard.

> Thanks,
> Paolo.
>
> ////////////////////
>
Paolo Carlini - June 10, 2011, 11:11 a.m.
On 06/10/2011 12:14 PM, Richard Guenther wrote:
> On Fri, Jun 10, 2011 at 11:58 AM, Paolo Carlini
> <paolo.carlini@oracle.com>  wrote:
>> Hi,
>>
>> yesterday I noticed that, as I vaguely suspected for quite some time,
>> error_operand_p can be useful also outside the c++ front-end. The below,
>> which I bootstrapped c, c++, go, on x86_64-linux (and I'm finishing testing)
>> tries to do that, moving the macro one level up and using it in all the
>> suitable places I spotted.
>>
>> What do people think?
> Ok if it bootstraps and tests.
Thanks Richard. I committed the gcc and gcc/cp changes, without touching 
for the time being go/gofrontend, because I realized those files are 
really mirrored from somewhere else. I leave those bits to Ian...

Paolo.

Patch

Index: tree.h
===================================================================
--- tree.h	(revision 174893)
+++ tree.h	(working copy)
@@ -4053,6 +4053,12 @@  enum ptrmemfunc_vbit_where_t
 
 #define NULL_TREE (tree) NULL
 
+/* True if NODE is an erroneous expression.  */
+
+#define error_operand_p(NODE)					\
+  ((NODE) == error_mark_node					\
+   || ((NODE) && TREE_TYPE ((NODE)) == error_mark_node))
+
 extern tree decl_assembler_name (tree);
 extern bool decl_assembler_name_equal (tree decl, const_tree asmname);
 extern hashval_t decl_assembler_name_hash (const_tree asmname);
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 174893)
+++ cp/cp-tree.h	(working copy)
@@ -1123,12 +1123,6 @@  struct GTY(()) language_function {
 #define ansi_assopname(CODE) \
   (assignment_operator_name_info[(int) (CODE)].identifier)
 
-/* True if NODE is an erroneous expression.  */
-
-#define error_operand_p(NODE)					\
-  ((NODE) == error_mark_node					\
-   || ((NODE) && TREE_TYPE ((NODE)) == error_mark_node))
-
 /* TRUE if a tree code represents a statement.  */
 extern bool statement_code_p[MAX_TREE_CODES];
 
Index: dbxout.c
===================================================================
--- dbxout.c	(revision 174893)
+++ dbxout.c	(working copy)
@@ -1510,7 +1510,7 @@  dbxout_type_fields (tree type)
     {
       /* If one of the nodes is an error_mark or its type is then
 	 return early.  */
-      if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
+      if (error_operand_p (tem))
 	return;
 
       /* Omit here local type decls until we know how to support them.  */
Index: go/gofrontend/expressions.cc
===================================================================
--- go/gofrontend/expressions.cc	(revision 174893)
+++ go/gofrontend/expressions.cc	(working copy)
@@ -209,7 +209,7 @@  Expression::convert_for_assignment(Translate_conte
   if (lhs_type->is_error() || rhs_type->is_error())
     return error_mark_node;
 
-  if (rhs_tree == error_mark_node || TREE_TYPE(rhs_tree) == error_mark_node)
+  if (error_operand_p (rhs_tree))
     return error_mark_node;
 
   Gogo* gogo = context->gogo();
@@ -8967,7 +8967,7 @@  Call_expression::do_get_tree(Translate_context* co
   else
     go_unreachable();
 
-  if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node)
+  if (error_operand_p (fn))
     {
       delete[] args;
       return error_mark_node;
@@ -11004,7 +11004,7 @@  Struct_construction_expression::do_get_tree(Transl
 	  ++pv;
 	}
 
-      if (val == error_mark_node || TREE_TYPE(val) == error_mark_node)
+      if (error_operand_p (val))
 	return error_mark_node;
 
       constructor_elt* elt = VEC_quick_push(constructor_elt, elts, NULL);
Index: c-decl.c
===================================================================
--- c-decl.c	(revision 174893)
+++ c-decl.c	(working copy)
@@ -565,7 +565,7 @@  add_stmt (tree t)
 static bool
 decl_jump_unsafe (tree decl)
 {
-  if (decl == error_mark_node || TREE_TYPE (decl) == error_mark_node)
+  if (error_operand_p (decl))
     return false;
 
   /* Always warn about crossing variably modified types.  */
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 174893)
+++ gimplify.c	(working copy)
@@ -5448,7 +5448,7 @@  omp_add_variable (struct gimplify_omp_ctx *ctx, tr
   unsigned int nflags;
   tree t;
 
-  if (decl == error_mark_node || TREE_TYPE (decl) == error_mark_node)
+  if (error_operand_p (decl))
     return;
 
   /* Never elide decls whose type has TREE_ADDRESSABLE set.  This means
@@ -5573,7 +5573,7 @@  omp_notice_variable (struct gimplify_omp_ctx *ctx,
   unsigned flags = in_code ? GOVD_SEEN : 0;
   bool ret = false, shared;
 
-  if (decl == error_mark_node || TREE_TYPE (decl) == error_mark_node)
+  if (error_operand_p (decl))
     return false;
 
   /* Threadprivate variables are predetermined.  */
@@ -5830,7 +5830,7 @@  gimplify_scan_omp_clauses (tree *list_p, gimple_se
 
 	do_add:
 	  decl = OMP_CLAUSE_DECL (c);
-	  if (decl == error_mark_node || TREE_TYPE (decl) == error_mark_node)
+	  if (error_operand_p (decl))
 	    {
 	      remove = true;
 	      break;
@@ -5889,7 +5889,7 @@  gimplify_scan_omp_clauses (tree *list_p, gimple_se
 	case OMP_CLAUSE_COPYIN:
 	case OMP_CLAUSE_COPYPRIVATE:
 	  decl = OMP_CLAUSE_DECL (c);
-	  if (decl == error_mark_node || TREE_TYPE (decl) == error_mark_node)
+	  if (error_operand_p (decl))
 	    {
 	      remove = true;
 	      break;