|
From: Åke R. <ake...@gm...> - 2017-11-05 16:30:00
|
Sorry I have not answered sooner. I have been busy working on trying to
get the new stm8 target for OpenOCD approved.
Anyhow, as I discovered when a new compound statement is found a new
nest level and blockno is created. However when the new block is created
in CreateBlock() some magic is done with the ast block member variable
where it gets its block number from the body. This number is not always
the same as the block number in the variable declaration. For example if
there is no code between the variable declaration in the new block and a
for-statement this blockno becomes the block number of the for-statement.
So this makes the scope of the variable "ni" in my case end up in the
same scope as the function declaration (in the dwarf tables).
On top of that i also noticed when using a function parameter as a
for-variable it gets copied into some temp-variable that I not been able
to figure out how to emit to dwWriteSymbol().
/Ake
On 2017-11-02 14:04, Philipp Klaus Krause wrote:
>
> Looking at function_declarator2 in src/SDCC.y it seems, function
> parameters go into an extra block? However, I do not know why for your
> int dummy(int x)
> {
> int n = 0;
> {
> int ni = 10;
> for (;x>=0;x--)
> ni = ni - 2;
> }
> return n;
> }
>
> x is in some "hidden" block B3 (by number "in between" the two blocks
> B2, B4 for the function body), while for
>
> int dummy2(int j)
> {
> for(int i = 0; i < 3; i++)
> {
> j--;
> }
> return(j);
> }
>
> j is in some "hidden" block B1 (by number "above" the two blocks B2, B3
> for the function body);
>
> Philipp
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> sdcc-devel mailing list
> sdc...@li...
> https://lists.sourceforge.net/lists/listinfo/sdcc-devel
|