From patchwork Sun Aug 12 20:17:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 176802 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 C4CCE2C0091 for ; Mon, 13 Aug 2012 06:18:04 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345407485; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Date:From:To:Cc:Subject: Message-ID:MIME-Version:Content-Type:Content-Disposition: User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=S/AumXY etdCnO0GE2EasecKGmmk=; b=Kaazcl76pL1d8lqnnJvjrTMBIHq7vRoQP0oN4N7 +gNDEVVMRiDEe2idzqG9kpHp3VxY6f+amQgrmV1MJ/8D1vHxGqGcXmqyfpO0THWO vsqFwE+iK+xlrO3z160yI3r/unO+hGMBrCtWAL5UoFKfm7C8NyxTcmwuZBhZrq5M MS5I= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=saBrUOqcy2bITqyGDe3Nkru9eb3HC/goUg3IxGomyvmnbXDtg/9ixsBQLzWXYJ 7QsNv8vAuWQTZtHEOsL3pVZ/grqRly3qWH6WujgYFxAI2uRO/PcQg5IfX51fFJuy KqabzWybyT0Dg5VSIQf7OIMpqO4tRNSbdl8r59KzP/XZI=; Received: (qmail 29167 invoked by alias); 12 Aug 2012 20:17:58 -0000 Received: (qmail 29157 invoked by uid 22791); 12 Aug 2012 20:17:54 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL, BAYES_40, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f201.google.com (HELO mail-ob0-f201.google.com) (209.85.214.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Aug 2012 20:17:34 +0000 Received: by obbun3 with SMTP id un3so2203671obb.2 for ; Sun, 12 Aug 2012 13:17:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:organization:user-agent:x-gm-message-state; bh=GB7yJGD1YvQoMeXgl+fvrkkIOzl3zlJG3LotdmSstOM=; b=gzje6jOliA0O5CbnumV86KFPGFnz93cGjrCYW18YHHAOCaCq1Yltr9TLrAlhQPd/3s i9/4WlvVjOQuBN2aSIsRIxUA0vi0/Jej92tnIQWqW/Sdia/fVO5erGkHhh0IrNmiUK00 PVFeHg6iPqTH+pvTU+xxHRo+YyD/MrqAyU79T1dqGJbUVbRNkJbM50VySa5/xiJFZYLl xDNr4wOlX4VO7bZSGk/waVTfuRnjodHKSzAW6jffk5FD8NACiy01XkoAPxrf8k4roRXu godZOhwky3JdVgiyp6x1OEe21HHeZKGVXSBFDSNT1LGrQPj22U89+gGTPW2FWX+ybzz3 bBWA== Received: by 10.43.53.144 with SMTP id vq16mr3932231icb.26.1344802653677; Sun, 12 Aug 2012 13:17:33 -0700 (PDT) Received: by 10.43.53.144 with SMTP id vq16mr3932223icb.26.1344802653609; Sun, 12 Aug 2012 13:17:33 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id mb9si1093520igc.1.2012.08.12.13.17.33 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sun, 12 Aug 2012 13:17:33 -0700 (PDT) Received: from torture.tor.corp.google.com (torture.tor.corp.google.com [172.29.41.4]) by wpzn3.hot.corp.google.com (Postfix) with ESMTP id 1E8C0100047; Sun, 12 Aug 2012 13:17:33 -0700 (PDT) Received: by torture.tor.corp.google.com (Postfix, from userid 54752) id A7809C0890; Sun, 12 Aug 2012 16:17:32 -0400 (EDT) Date: Sun, 12 Aug 2012 16:17:32 -0400 From: Diego Novillo To: gcc-patches@gcc.gnu.org, Lawrence Crowl Cc: Richard Guenther , Richard Henderson Subject: Merge C++ conversion into trunk (6/6 - gdb tree macro support) Message-ID: <20120812201732.GA15153@google.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkiqglBlnEVrfqjR+uSlPaGDizi0AYZf03/f1YL0wZ0OMCsibxomua0ih5Ry6tX3XWx9trr6rFDzt1Id1wgif/I7WqLA6bMSZUUCOt8PXpo1t1k2eyTMfzxq+oC7AheMySXhSZkHsM9AR02mtn5fs/AJFoh+XU/TGp+nKevMN1BpubQF6WcvJdmz0q2ChbVWPbbXKuHYPfzlkdPIYBimDc0gl2nnBRXYxPmc806J900ByNoe2o= 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 This implements support for calling tree macros from gdb. See http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00711.html for details. Diego. 2012-08-12 Lawrence Crowl * tree.h (tree_check): New. (TREE_CHECK): Use inline function above instead of __extension__. (tree_not_check): New. (TREE_NOT_CHECK): Use inline function above instead of __extension__. (tree_check2): New. (TREE_CHECK2): Use inline function above instead of __extension__. (tree_not_check2): New. (TREE_NOT_CHECK2): Use inline function above instead of __extension__. (tree_check3): New. (TREE_CHECK3): Use inline function above instead of __extension__. (tree_not_check3): New. (TREE_NOT_CHECK3): Use inline function above instead of __extension__. (tree_check4): New. (TREE_CHECK4): Use inline function above instead of __extension__. (tree_not_check4): New. (TREE_NOT_CHECK4): Use inline function above instead of __extension__. (tree_check5): New. (TREE_CHECK5): Use inline function above instead of __extension__. (tree_not_check5): New. (TREE_NOT_CHECK5): Use inline function above instead of __extension__. (contains_struct_check): New. (CONTAINS_STRUCT_CHECK): Use inline function above instead of __extension__. (tree_class_check): New. (TREE_CLASS_CHECK): Use inline function above instead of __extension__. (tree_range_check): New. (TREE_RANGE_CHECK): Use inline function above instead of __extension__. (omp_clause_subcode_check): New. (OMP_CLAUSE_SUBCODE_CHECK): Use inline function above instead of __extension__. (omp_clause_range_check): New. (OMP_CLAUSE_RANGE_CHECK): Use inline function above instead of __extension__. (expr_check): New. (EXPR_CHECK): Use inline function above instead of __extension__. (non_type_check): New. (NON_TYPE_CHECK): Use inline function above instead of __extension__. (tree_vec_elt_check): New. (TREE_VEC_ELT_CHECK): Use inline function above instead of __extension__. (omp_clause_elt_check): New. (OMP_CLAUSE_ELT_CHECK): Use inline function above instead of __extension__. (tree_operand_check): New. (TREE_OPERAND_CHECK): Use inline function above instead of __extension__. (tree_operand_check_code): New. (TREE_OPERAND_CHECK_CODE): Use inline function above instead of __extension__. (TREE_CHAIN): Simplify implementation. (TREE_TYPE): Simplify implementation. (tree_operand_length): Move for compilation dependences. * gdbinit.in: (macro define __FILE__): New. (macro define __LINE__): New. (skip "tree.h"): New. * tree.h (tree_check): Change from template to const overload. (tree_not_check): Likewise. (tree_check2): Likewise. (tree_not_check2): Likewise. (tree_check3): Likewise. (tree_not_check3): Likewise. (tree_check4): Likewise. (tree_not_check4): Likewise. (tree_check5): Likewise. (tree_not_check5): Likewise. (contains_struct_check): Likewise. (tree_class_check): Likewise. (tree_range_check): Likewise. (omp_clause_subcode_check): Likewise. (omp_clause_range_check): Likewise. (expr_check): Likewise. (non_type_check): Likewise. (tree_vec_elt_check): Likewise. (omp_clause_elt_check): Likewise. (tree_operand_check): Likewise. (tree_operand_check_code): Likewise. (tree_operand_length): Move to avoid a duplicate copy. * gdbinit.in (set unwindonsignal on): New. diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in index d1ae46d..858e490 100644 --- a/gcc/gdbinit.in +++ b/gcc/gdbinit.in @@ -182,6 +182,17 @@ document pbm Dump the bitmap that is in $ as a comma-separated list of numbers. end +# Define some macros helpful to gdb when it is expanding macros. +macro define __FILE__ "gdb" +macro define __LINE__ 1 + +# Skip all inline functions in tree.h. +# These are used in accessor macros. +skip "tree.h" + +# Gracefully handle aborts in functions used from gdb. +set unwindonsignal on + # Put breakpoints at exit and fancy_abort in case abort is mapped # to either fprintf/exit or fancy_abort. b fancy_abort diff --git a/gcc/tree.h b/gcc/tree.h index cc49629..ba4a021 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -719,195 +719,80 @@ enum tree_node_structure_enum { is accessed incorrectly. The macros die with a fatal error. */ #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) -#define TREE_CHECK(T, CODE) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != (CODE)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE), 0); \ - __t; }) - -#define TREE_NOT_CHECK(T, CODE) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) == (CODE)) \ - tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE), 0); \ - __t; }) - -#define TREE_CHECK2(T, CODE1, CODE2) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != (CODE1) \ - && TREE_CODE (__t) != (CODE2)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), 0); \ - __t; }) - -#define TREE_NOT_CHECK2(T, CODE1, CODE2) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) == (CODE1) \ - || TREE_CODE (__t) == (CODE2)) \ - tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), 0); \ - __t; }) - -#define TREE_CHECK3(T, CODE1, CODE2, CODE3) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != (CODE1) \ - && TREE_CODE (__t) != (CODE2) \ - && TREE_CODE (__t) != (CODE3)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), 0); \ - __t; }) - -#define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) == (CODE1) \ - || TREE_CODE (__t) == (CODE2) \ - || TREE_CODE (__t) == (CODE3)) \ - tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), 0); \ - __t; }) - -#define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != (CODE1) \ - && TREE_CODE (__t) != (CODE2) \ - && TREE_CODE (__t) != (CODE3) \ - && TREE_CODE (__t) != (CODE4)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), (CODE4), 0); \ - __t; }) - -#define TREE_NOT_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) == (CODE1) \ - || TREE_CODE (__t) == (CODE2) \ - || TREE_CODE (__t) == (CODE3) \ - || TREE_CODE (__t) == (CODE4)) \ - tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), (CODE4), 0); \ - __t; }) - -#define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != (CODE1) \ - && TREE_CODE (__t) != (CODE2) \ - && TREE_CODE (__t) != (CODE3) \ - && TREE_CODE (__t) != (CODE4) \ - && TREE_CODE (__t) != (CODE5)) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), (CODE4), (CODE5), 0);\ - __t; }) - -#define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) == (CODE1) \ - || TREE_CODE (__t) == (CODE2) \ - || TREE_CODE (__t) == (CODE3) \ - || TREE_CODE (__t) == (CODE4) \ - || TREE_CODE (__t) == (CODE5)) \ - tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2), (CODE3), (CODE4), (CODE5), 0);\ - __t; }) - -#define CONTAINS_STRUCT_CHECK(T, STRUCT) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (tree_contains_struct[TREE_CODE(__t)][(STRUCT)] != 1) \ - tree_contains_struct_check_failed (__t, (STRUCT), __FILE__, __LINE__, \ - __FUNCTION__); \ - __t; }) - -#define TREE_CLASS_CHECK(T, CLASS) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE_CLASS (TREE_CODE(__t)) != (CLASS)) \ - tree_class_check_failed (__t, (CLASS), __FILE__, __LINE__, \ - __FUNCTION__); \ - __t; }) - -#define TREE_RANGE_CHECK(T, CODE1, CODE2) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) < (CODE1) || TREE_CODE (__t) > (CODE2)) \ - tree_range_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE1), (CODE2)); \ - __t; }) - -#define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != OMP_CLAUSE) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - OMP_CLAUSE, 0); \ - if (__t->omp_clause.code != (CODE)) \ - omp_clause_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - (CODE)); \ - __t; }) - -#define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TREE_CODE (__t) != OMP_CLAUSE) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - OMP_CLAUSE, 0); \ - if ((int) __t->omp_clause.code < (int) (CODE1) \ - || (int) __t->omp_clause.code > (int) (CODE2)) \ - omp_clause_range_check_failed (__t, __FILE__, __LINE__, \ - __FUNCTION__, (CODE1), (CODE2)); \ - __t; }) +#define TREE_CHECK(T, CODE) \ +(tree_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE))) + +#define TREE_NOT_CHECK(T, CODE) \ +(tree_not_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE))) + +#define TREE_CHECK2(T, CODE1, CODE2) \ +(tree_check2 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2))) + +#define TREE_NOT_CHECK2(T, CODE1, CODE2) \ +(tree_not_check2 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2))) + +#define TREE_CHECK3(T, CODE1, CODE2, CODE3) \ +(tree_check3 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2), (CODE3))) + +#define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) \ +(tree_not_check3 ((T), __FILE__, __LINE__, __FUNCTION__, \ + (CODE1), (CODE2), (CODE3))) + +#define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) \ +(tree_check4 ((T), __FILE__, __LINE__, __FUNCTION__, \ + (CODE1), (CODE2), (CODE3), (CODE4))) + +#define TREE_NOT_CHECK4(T, CODE1, CODE2, CODE3, CODE4) \ +(tree_not_check4 ((T), __FILE__, __LINE__, __FUNCTION__, \ + (CODE1), (CODE2), (CODE3), (CODE4))) + +#define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) \ +(tree_check5 ((T), __FILE__, __LINE__, __FUNCTION__, \ + (CODE1), (CODE2), (CODE3), (CODE4), (CODE5))) + +#define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) \ +(tree_not_check5 ((T), __FILE__, __LINE__, __FUNCTION__, \ + (CODE1), (CODE2), (CODE3), (CODE4), (CODE5))) + +#define CONTAINS_STRUCT_CHECK(T, STRUCT) \ +(contains_struct_check ((T), (STRUCT), __FILE__, __LINE__, __FUNCTION__)) + +#define TREE_CLASS_CHECK(T, CLASS) \ +(tree_class_check ((T), (CLASS), __FILE__, __LINE__, __FUNCTION__)) + +#define TREE_RANGE_CHECK(T, CODE1, CODE2) \ +(tree_range_check ((T), (CODE1), (CODE2), __FILE__, __LINE__, __FUNCTION__)) + +#define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) \ +(omp_clause_subcode_check ((T), (CODE), __FILE__, __LINE__, __FUNCTION__)) + +#define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) \ +(omp_clause_range_check ((T), (CODE1), (CODE2), \ + __FILE__, __LINE__, __FUNCTION__)) /* These checks have to be special cased. */ -#define EXPR_CHECK(T) __extension__ \ -({ __typeof (T) const __t = (T); \ - char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \ - if (!IS_EXPR_CODE_CLASS (__c)) \ - tree_class_check_failed (__t, tcc_expression, __FILE__, __LINE__, \ - __FUNCTION__); \ - __t; }) +#define EXPR_CHECK(T) \ +(expr_check ((T), __FILE__, __LINE__, __FUNCTION__)) /* These checks have to be special cased. */ -#define NON_TYPE_CHECK(T) __extension__ \ -({ __typeof (T) const __t = (T); \ - if (TYPE_P (__t)) \ - tree_not_class_check_failed (__t, tcc_type, __FILE__, __LINE__, \ - __FUNCTION__); \ - __t; }) - -#define TREE_VEC_ELT_CHECK(T, I) __extension__ \ -(*({__typeof (T) const __t = (T); \ - const int __i = (I); \ - if (TREE_CODE (__t) != TREE_VEC) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - TREE_VEC, 0); \ - if (__i < 0 || __i >= __t->vec.length) \ - tree_vec_elt_check_failed (__i, __t->vec.length, \ - __FILE__, __LINE__, __FUNCTION__); \ - &__t->vec.a[__i]; })) - -#define OMP_CLAUSE_ELT_CHECK(T, I) __extension__ \ -(*({__typeof (T) const __t = (T); \ - const int __i = (I); \ - if (TREE_CODE (__t) != OMP_CLAUSE) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, \ - OMP_CLAUSE, 0); \ - if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code]) \ - omp_clause_operand_check_failed (__i, __t, __FILE__, __LINE__, \ - __FUNCTION__); \ - &__t->omp_clause.ops[__i]; })) +#define NON_TYPE_CHECK(T) \ +(non_type_check ((T), __FILE__, __LINE__, __FUNCTION__)) + +#define TREE_VEC_ELT_CHECK(T, I) \ +(*(CONST_CAST2 (tree *, typeof (T)*, \ + tree_vec_elt_check ((T), (I), __FILE__, __LINE__, __FUNCTION__)))) + +#define OMP_CLAUSE_ELT_CHECK(T, I) \ +(*(omp_clause_elt_check ((T), (I), __FILE__, __LINE__, __FUNCTION__))) /* Special checks for TREE_OPERANDs. */ -#define TREE_OPERAND_CHECK(T, I) __extension__ \ -(*({__typeof (T) const __t = EXPR_CHECK (T); \ - const int __i = (I); \ - if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t)) \ - tree_operand_check_failed (__i, __t, \ - __FILE__, __LINE__, __FUNCTION__); \ - &__t->exp.operands[__i]; })) - -#define TREE_OPERAND_CHECK_CODE(T, CODE, I) __extension__ \ -(*({__typeof (T) const __t = (T); \ - const int __i = (I); \ - if (TREE_CODE (__t) != CODE) \ - tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, (CODE), 0);\ - if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t)) \ - tree_operand_check_failed (__i, __t, \ - __FILE__, __LINE__, __FUNCTION__); \ - &__t->exp.operands[__i]; })) +#define TREE_OPERAND_CHECK(T, I) \ +(*(CONST_CAST2 (tree*, typeof (T)*, \ + tree_operand_check ((T), (I), __FILE__, __LINE__, __FUNCTION__)))) + +#define TREE_OPERAND_CHECK_CODE(T, CODE, I) \ +(*(tree_operand_check_code ((T), (CODE), (I), \ + __FILE__, __LINE__, __FUNCTION__))) /* Nodes are chained together for many purposes. Types are chained together to record them for being output to the debugger @@ -918,17 +803,15 @@ enum tree_node_structure_enum { Often lists of things are represented by TREE_LIST nodes that are chained together. */ -#define TREE_CHAIN(NODE) __extension__ \ -(*({__typeof (NODE) const __t = CONTAINS_STRUCT_CHECK (NODE, TS_COMMON);\ - &__t->common.chain; })) +#define TREE_CHAIN(NODE) \ +(CONTAINS_STRUCT_CHECK (NODE, TS_COMMON)->common.chain) /* In all nodes that are expressions, this is the data type of the expression. In POINTER_TYPE nodes, this is the type that the pointer points to. In ARRAY_TYPE nodes, this is the type of the elements. In VECTOR_TYPE nodes, this is the type of the elements. */ -#define TREE_TYPE(NODE) __extension__ \ -(*({__typeof (NODE) const __t = CONTAINS_STRUCT_CHECK (NODE, TS_TYPED); \ - &__t->typed.type; })) +#define TREE_TYPE(NODE) \ +(CONTAINS_STRUCT_CHECK (NODE, TS_TYPED)->typed.type) extern void tree_contains_struct_check_failed (const_tree, const enum tree_node_structure_enum, @@ -1608,7 +1491,7 @@ struct GTY(()) tree_vec { /* In a CONSTRUCTOR node. */ #define CONSTRUCTOR_ELTS(NODE) (CONSTRUCTOR_CHECK (NODE)->constructor.elts) #define CONSTRUCTOR_ELT(NODE,IDX) \ - (VEC_index (constructor_elt, CONSTRUCTOR_ELTS (NODE), IDX)) + (&VEC_index (constructor_elt, CONSTRUCTOR_ELTS (NODE), IDX)) #define CONSTRUCTOR_NELTS(NODE) \ (VEC_length (constructor_elt, CONSTRUCTOR_ELTS (NODE))) @@ -1618,7 +1501,7 @@ struct GTY(()) tree_vec { #define FOR_EACH_CONSTRUCTOR_VALUE(V, IX, VAL) \ for (IX = 0; (IX >= VEC_length (constructor_elt, V)) \ ? false \ - : ((VAL = VEC_index (constructor_elt, V, IX)->value), \ + : ((VAL = VEC_index (constructor_elt, V, IX).value), \ true); \ (IX)++) @@ -1628,8 +1511,8 @@ struct GTY(()) tree_vec { #define FOR_EACH_CONSTRUCTOR_ELT(V, IX, INDEX, VAL) \ for (IX = 0; (IX >= VEC_length (constructor_elt, V)) \ ? false \ - : (((void) (VAL = VEC_index (constructor_elt, V, IX)->value)), \ - (INDEX = VEC_index (constructor_elt, V, IX)->index), \ + : (((void) (VAL = VEC_index (constructor_elt, V, IX).value)), \ + (INDEX = VEC_index (constructor_elt, V, IX).index), \ true); \ (IX)++) @@ -3743,6 +3626,486 @@ union GTY ((ptr_alias (union lang_tree_node), struct tree_optimization_option GTY ((tag ("TS_OPTIMIZATION"))) optimization; struct tree_target_option GTY ((tag ("TS_TARGET_OPTION"))) target_option; }; + +#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) + +inline tree +tree_check (tree __t, const char *__f, int __l, const char *__g, tree_code __c) +{ + if (TREE_CODE (__t) != __c) + tree_check_failed (__t, __f, __l, __g, __c, 0); + return __t; +} + +inline tree +tree_not_check (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c) +{ + if (TREE_CODE (__t) == __c) + tree_not_check_failed (__t, __f, __l, __g, __c, 0); + return __t; +} + +inline tree +tree_check2 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, 0); + return __t; +} + +inline tree +tree_not_check2 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, 0); + return __t; +} + +inline tree +tree_check3 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0); + return __t; +} + +inline tree +tree_not_check3 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0); + return __t; +} + +inline tree +tree_check4 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3 + && TREE_CODE (__t) != __c4) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0); + return __t; +} + +inline tree +tree_not_check4 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3 + || TREE_CODE (__t) == __c4) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0); + return __t; +} + +inline tree +tree_check5 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4, enum tree_code __c5) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3 + && TREE_CODE (__t) != __c4 + && TREE_CODE (__t) != __c5) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0); + return __t; +} + +inline tree +tree_not_check5 (tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4, enum tree_code __c5) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3 + || TREE_CODE (__t) == __c4 + || TREE_CODE (__t) == __c5) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0); + return __t; +} + +inline tree +contains_struct_check (tree __t, const enum tree_node_structure_enum __s, + const char *__f, int __l, const char *__g) +{ + if (tree_contains_struct[TREE_CODE(__t)][__s] != 1) + tree_contains_struct_check_failed (__t, __s, __f, __l, __g); + return __t; +} + +inline tree +tree_class_check (tree __t, const enum tree_code_class __class, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE_CLASS (TREE_CODE(__t)) != __class) + tree_class_check_failed (__t, __class, __f, __l, __g); + return __t; +} + +inline tree +tree_range_check (tree __t, + enum tree_code __code1, enum tree_code __code2, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) < __code1 || TREE_CODE (__t) > __code2) + tree_range_check_failed (__t, __f, __l, __g, __code1, __code2); + return __t; +} + +inline tree +omp_clause_subcode_check (tree __t, enum omp_clause_code __code, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if (__t->omp_clause.code != __code) + omp_clause_check_failed (__t, __f, __l, __g, __code); + return __t; +} + +inline tree +omp_clause_range_check (tree __t, + enum omp_clause_code __code1, + enum omp_clause_code __code2, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if ((int) __t->omp_clause.code < (int) __code1 + || (int) __t->omp_clause.code > (int) __code2) + omp_clause_range_check_failed (__t, __f, __l, __g, __code1, __code2); + return __t; +} + +/* These checks have to be special cased. */ + +inline tree +expr_check (tree __t, const char *__f, int __l, const char *__g) +{ + char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); + if (!IS_EXPR_CODE_CLASS (__c)) + tree_class_check_failed (__t, tcc_expression, __f, __l, __g); + return __t; +} + +/* These checks have to be special cased. */ + +inline tree +non_type_check (tree __t, const char *__f, int __l, const char *__g) +{ + if (TYPE_P (__t)) + tree_not_class_check_failed (__t, tcc_type, __f, __l, __g); + return __t; +} + +inline tree * +tree_vec_elt_check (tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != TREE_VEC) + tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0); + if (__i < 0 || __i >= __t->vec.length) + tree_vec_elt_check_failed (__i, __t->vec.length, __f, __l, __g); + return &CONST_CAST_TREE (__t)->vec.a[__i]; +} + +inline tree * +omp_clause_elt_check (tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code]) + omp_clause_operand_check_failed (__i, __t, __f, __l, __g); + return &__t->omp_clause.ops[__i]; +} + +inline const_tree +tree_check (const_tree __t, const char *__f, int __l, const char *__g, + tree_code __c) +{ + if (TREE_CODE (__t) != __c) + tree_check_failed (__t, __f, __l, __g, __c, 0); + return __t; +} + +inline const_tree +tree_not_check (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c) +{ + if (TREE_CODE (__t) == __c) + tree_not_check_failed (__t, __f, __l, __g, __c, 0); + return __t; +} + +inline const_tree +tree_check2 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, 0); + return __t; +} + +inline const_tree +tree_not_check2 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, 0); + return __t; +} + +inline const_tree +tree_check3 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0); + return __t; +} + +inline const_tree +tree_not_check3 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0); + return __t; +} + +inline const_tree +tree_check4 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3 + && TREE_CODE (__t) != __c4) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0); + return __t; +} + +inline const_tree +tree_not_check4 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3 + || TREE_CODE (__t) == __c4) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0); + return __t; +} + +inline const_tree +tree_check5 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4, enum tree_code __c5) +{ + if (TREE_CODE (__t) != __c1 + && TREE_CODE (__t) != __c2 + && TREE_CODE (__t) != __c3 + && TREE_CODE (__t) != __c4 + && TREE_CODE (__t) != __c5) + tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0); + return __t; +} + +inline const_tree +tree_not_check5 (const_tree __t, const char *__f, int __l, const char *__g, + enum tree_code __c1, enum tree_code __c2, enum tree_code __c3, + enum tree_code __c4, enum tree_code __c5) +{ + if (TREE_CODE (__t) == __c1 + || TREE_CODE (__t) == __c2 + || TREE_CODE (__t) == __c3 + || TREE_CODE (__t) == __c4 + || TREE_CODE (__t) == __c5) + tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0); + return __t; +} + +inline const_tree +contains_struct_check (const_tree __t, const enum tree_node_structure_enum __s, + const char *__f, int __l, const char *__g) +{ + if (tree_contains_struct[TREE_CODE(__t)][__s] != 1) + tree_contains_struct_check_failed (__t, __s, __f, __l, __g); + return __t; +} + +inline const_tree +tree_class_check (const_tree __t, const enum tree_code_class __class, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE_CLASS (TREE_CODE(__t)) != __class) + tree_class_check_failed (__t, __class, __f, __l, __g); + return __t; +} + +inline const_tree +tree_range_check (const_tree __t, + enum tree_code __code1, enum tree_code __code2, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) < __code1 || TREE_CODE (__t) > __code2) + tree_range_check_failed (__t, __f, __l, __g, __code1, __code2); + return __t; +} + +inline const_tree +omp_clause_subcode_check (const_tree __t, enum omp_clause_code __code, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if (__t->omp_clause.code != __code) + omp_clause_check_failed (__t, __f, __l, __g, __code); + return __t; +} + +inline const_tree +omp_clause_range_check (const_tree __t, + enum omp_clause_code __code1, + enum omp_clause_code __code2, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if ((int) __t->omp_clause.code < (int) __code1 + || (int) __t->omp_clause.code > (int) __code2) + omp_clause_range_check_failed (__t, __f, __l, __g, __code1, __code2); + return __t; +} + +inline const_tree +expr_check (const_tree __t, const char *__f, int __l, const char *__g) +{ + char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); + if (!IS_EXPR_CODE_CLASS (__c)) + tree_class_check_failed (__t, tcc_expression, __f, __l, __g); + return __t; +} + +inline const_tree +non_type_check (const_tree __t, const char *__f, int __l, const char *__g) +{ + if (TYPE_P (__t)) + tree_not_class_check_failed (__t, tcc_type, __f, __l, __g); + return __t; +} + +inline const_tree * +tree_vec_elt_check (const_tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != TREE_VEC) + tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0); + if (__i < 0 || __i >= __t->vec.length) + tree_vec_elt_check_failed (__i, __t->vec.length, __f, __l, __g); + return CONST_CAST (const_tree *, &__t->vec.a[__i]); + //return &__t->vec.a[__i]; +} + +inline const_tree * +omp_clause_elt_check (const_tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != OMP_CLAUSE) + tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0); + if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code]) + omp_clause_operand_check_failed (__i, __t, __f, __l, __g); + return CONST_CAST (const_tree *, &__t->omp_clause.ops[__i]); +} + +#endif + +/* Compute the number of operands in an expression node NODE. For + tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself, + otherwise it is looked up from the node's code. */ +static inline int +tree_operand_length (const_tree node) +{ + if (VL_EXP_CLASS_P (node)) + return VL_EXP_OPERAND_LENGTH (node); + else + return TREE_CODE_LENGTH (TREE_CODE (node)); +} + +#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) + +/* Special checks for TREE_OPERANDs. */ +inline tree * +tree_operand_check (tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + const_tree __u = EXPR_CHECK (__t); + if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u)) + tree_operand_check_failed (__i, __u, __f, __l, __g); + return &CONST_CAST_TREE (__u)->exp.operands[__i]; +} + +inline tree * +tree_operand_check_code (tree __t, enum tree_code __code, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != __code) + tree_check_failed (__t, __f, __l, __g, __code, 0); + if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t)) + tree_operand_check_failed (__i, __t, __f, __l, __g); + return &__t->exp.operands[__i]; +} + +inline const_tree * +tree_operand_check (const_tree __t, int __i, + const char *__f, int __l, const char *__g) +{ + const_tree __u = EXPR_CHECK (__t); + if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u)) + tree_operand_check_failed (__i, __u, __f, __l, __g); + return CONST_CAST (const_tree *, &__u->exp.operands[__i]); +} + +inline const_tree * +tree_operand_check_code (const_tree __t, enum tree_code __code, int __i, + const char *__f, int __l, const char *__g) +{ + if (TREE_CODE (__t) != __code) + tree_check_failed (__t, __f, __l, __g, __code, 0); + if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t)) + tree_operand_check_failed (__i, __t, __f, __l, __g); + return CONST_CAST (const_tree *, &__t->exp.operands[__i]); +} + +#endif + /* Standard named or nameless data types of the C compiler. */ @@ -5917,18 +6280,6 @@ is_tm_safe_or_pure (const_tree x) void init_inline_once (void); -/* Compute the number of operands in an expression node NODE. For - tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself, - otherwise it is looked up from the node's code. */ -static inline int -tree_operand_length (const_tree node) -{ - if (VL_EXP_CLASS_P (node)) - return VL_EXP_OPERAND_LENGTH (node); - else - return TREE_CODE_LENGTH (TREE_CODE (node)); -} - /* Abstract iterators for CALL_EXPRs. These static inline definitions have to go towards the end of tree.h so that union tree_node is fully defined by this point. */