Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Zack Weinberg
Paul Schlie <[EMAIL PROTECTED]> writes: >> From: Mark Mitchell <[EMAIL PROTECTED]> >> static const int i = f(); > > Admittedly didn't think that was legal, as I though all "static const" > initializer values needed to be resolvable at compile time, directly or > indirectly from literal values by th

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Kazu Hirata
Hi Mark, > That's a bug, or, rather, a place where the C++ front-end is failing > to give full information to the optimizer. It should be > TREE_READONLY. There are some tricky bits, in that if we're doing a > dynamic initialization, we presently cannot mark it TREE_READONLY, > but this is a sta

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Paul Schlie
> From: Paul Schlie <[EMAIL PROTECTED]> >> From: Mark Mitchell <[EMAIL PROTECTED]> >>> Paul Schlie wrote: >>> - ??? no such thing, you can't "dynamically" initialize a "static const", >>> as then it's not a "static const", but rather simply a global "const" >>> >>> (as a "static const" object

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Paul Schlie
> From: Mark Mitchell <[EMAIL PROTECTED]> >> Paul Schlie wrote: >> - ??? no such thing, you can't "dynamically" initialize a "static const", >> as then it's not a "static const", but rather simply a global "const" >> >> (as a "static const" object is logically equivalent to a named/addressable

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Mark Mitchell
Paul Schlie wrote: - ??? no such thing, you can't "dynamically" initialize a "static const", as then it's not a "static const", but rather simply a global "const" (as a "static const" object is logically equivalent to a named/addressable literal, yes?) No, it's not. static const int i = f();

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Paul Schlie
> Mark Mitchell writes: >> Kazu Hirata wrote: >> ... >> static const int array[] = { 0, 0, 0, 1, 1, 1, 2, 2, 2 }; >> >> int >> foo (int a) >> { >> return array[7]; >> } >> >> I am trying to fold array[7] into 2. It turns out that if T is an >> ARRAY_REF, >> >> TREE_READONLY (TREE_OPERAND (T,

Re: Questions about a constant array reference in the C++ front end

2005-05-09 Thread Mark Mitchell
Kazu Hirata wrote: Hi, I have two questions about the C++ front end. Consider a C++ program static const int array[] = { 0, 0, 0, 1, 1, 1, 2, 2, 2 }; int foo (int a) { return array[7]; } I am trying to fold array[7] into 2. It turns out that if T is an ARRAY_REF, TREE_READONLY (TREE_OPERAND (T

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Paul Schlie
> Kazu Hirata writes: > >> Nathan writes: >> this is untrue. the elements hold the qualification. > > Then how do I know that an array is declared with const (or static > const)? When I looked at the CONSTRUCTOR stored in the DECL_INITIAL > of an array, I saw it with the TREE_STATIC flag set regar

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Stefan Strasser
Nathan Sidwell schrieb: Stefan Strasser wrote: I don't know anything about fold but in general a c++ array in the frontend is cv-qualified, not its elements. this is untrue. the elements hold the qualification. right I have been processing large source codes including STL, boost and custom code

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Steven Bosscher
On Sunday 08 May 2005 16:47, Nathan Sidwell wrote: > Kazu, > > > Then how do I know that an array is declared with const (or static > > const)? When I looked at the CONSTRUCTOR stored in the DECL_INITIAL > > of an array, I saw it with the TREE_STATIC flag set regardless of > > whether the array is

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Nathan Sidwell
Kazu, > Then how do I know that an array is declared with const (or static > const)? When I looked at the CONSTRUCTOR stored in the DECL_INITIAL > of an array, I saw it with the TREE_STATIC flag set regardless of > whether the array is declared with const, so that's not useful to > determine wheth

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Kazu Hirata
Hi Nathan, > this is untrue. the elements hold the qualification. Then how do I know that an array is declared with const (or static const)? When I looked at the CONSTRUCTOR stored in the DECL_INITIAL of an array, I saw it with the TREE_STATIC flag set regardless of whether the array is declared

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Nathan Sidwell
Stefan Strasser wrote: > I don't know anything about fold but in general a c++ array in the > frontend is cv-qualified, not its elements. this is untrue. the elements hold the qualification. > I have been processing large source codes including STL, boost and > custom code including function bod

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Stefan Strasser
Kazu Hirata schrieb: I am trying to fold array[7] into 2. It turns out that if T is an ARRAY_REF, TREE_READONLY (TREE_OPERAND (T, 0)) is 0. Why? I don't know anything about fold but in general a c++ array in the frontend is cv-qualified, not its elements. Another question. How is a RANGE_E

Re: Questions about a constant array reference in the C++ front end

2005-05-08 Thread Steven Bosscher
On Sunday 08 May 2005 06:11, Kazu Hirata wrote: > I created an array with more than one thousand elements. I still did > not see a RANGE_EXPR in the array's CONSTRUCTOR. How do I get a > RANGE_EXPR in a CONSTRUCTOR? IIRC G++ only builds RANGE_EXPRs for all-zero constructors. Gr. Steven