- To: Amittai Aviram <amittai.Aviram@xxxxxxxx>
- Subject: Re: What exactly does is_variable_sized test for?
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Wed, 22 Feb 2012 08:41:56 -0800
- Authentication-results: mr.google.com; spf=pass (google.com: domain of iant@xxxxxxxxxx designates 10.236.46.232 as permitted sender) smtp.mail=iant@xxxxxxxxxx; dkim=pass header.i=iant@xxxxxxxxxx
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1330533766; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Received-SPF:Received:Received:Received:Received:From:To:Cc: Subject:References:Date:In-Reply-To:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=BR0aEsyEqcDm2VeR4ezt1ACSS/g=; b=AMAlkCp4RZ9K9P+ 67CFezR5g9ZsUlGFNUsL0MT1fsxO01C/Zb2W8EBOQ09NiCyhopv+dYGMfOPvyZbU 50TEr2vWTGRqaA/7wDgCzdGFbPx6EA4YLjpSWjRsuvUnSofGxD7dnAS7lfAJqqye zDrirpzpWcIc4agQTtYN51mahph0=
- In-reply-to: <CC76EA10-861B-46E2-8B54-E3266EFB47B2@yale.edu> (Amittai Aviram's message of "Tue, 21 Feb 2012 23:50:46 -0500")
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Amittai Aviram <amittai.Aviram@xxxxxxxx> writes:
> I am trying to understand some code in gcc/omp-low.c that calls the predicate is_variable_sized:
>
> omp-low.c:is_variable_sized (const_tree expr)
>
> where const_tree is a pointer to a constant tree_node, which is a union of a bunch of structures, but, in this case, it must be (I think) a tree_var_decl structure. It is defined as follows:
>
> static inline bool
> is_variable_sized (const_tree expr)
> {
> return !TREE_CONSTANT (TYPE_SIZE_UNIT (TREE_TYPE (expr)));
> }
>
> Unpacking the macros, I get
> return !expr->common.type->type.size_unit->base.constant_flag;
>
> But what exactly does this mean? What kind of C variable counts as "variable sized"? Does that mean an array or struct type? Thanks!
In
void foo(int i) { int a[i]; }
the local variable a is variably sized. Or, for that matter, in this
void foo(int i) { struct s { int a[i]; } v; }
the local variable v is variably sized. So both structs and arrays can
be variably sized, although it is not the common case for either.
By the way, don't try to unpack the macros. Instead, look for the
definitions in tree.h and read the comments there. Unpacking the macros
is complicated and is far more confusing than helpful.
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]