From patchwork Fri Jun 10 09:58:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 99864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A88C8B6FE1 for ; Fri, 10 Jun 2011 19:58:11 +1000 (EST) Received: (qmail 14608 invoked by alias); 10 Jun 2011 09:58:08 -0000 Received: (qmail 14600 invoked by uid 22791); 10 Jun 2011 09:58:07 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_TM X-Spam-Check-By: sourceware.org Received: from smtp206.alice.it (HELO smtp206.alice.it) (82.57.200.102) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Jun 2011 09:57:52 +0000 Received: from [192.168.1.4] (79.51.26.185) by smtp206.alice.it (8.5.124.08) id 4DE63E3200D711C0; Fri, 10 Jun 2011 11:57:50 +0200 Message-ID: <4DF1EAC9.3010809@oracle.com> Date: Fri, 10 Jun 2011 11:58:33 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Ian Lance Taylor , Jason Merrill Subject: [PATCH] Move error_operand_p one level up X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * cp-tree.h (error_operand_p): Remove. /gcc 2011-06-10 Paolo Carlini * 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 * gofrontend/expressions.cc (Expression::convert_for_assignment, Call_expression::do_get_tree, Struct_construction_expression::do_get_tree): Use error_operand_p. 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;