Re: [RFC v1 0/5] Returning (adjusted) arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Joseph,

On Sun, May 18, 2025 at 11:57:39PM +0200, Alejandro Colomar wrote:
> Hi Martin, Joseph,
> 
> I'm still working on implementing this, returning adjusted arrays.  I'm
> having some issues and would like to ask for help.
> 
> I've moved the push_scope()/pop_scope() calls to supposedly extend the
> scope of the variables.  However, I'm not seeing the results I expected
> from it.  Here's what I'm seeing with these patches:
> 
> 	$ echo 'int f(int n)[n];' \
> 	| /opt/local/gnu/gcc/retarr/bin/gcc -x c /dev/stdin -Wsign-conversion
> 	/dev/stdin:1:6: warning: ALX: J [-Wsign-conversion]
> 	/dev/stdin:1:12: warning: ALX: J [-Wsign-conversion]
> 	/dev/stdin:1:13: warning: ALX: I [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: H [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: G [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: F [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: E [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: D [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: C [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: B [-Wsign-conversion]
> 	/dev/stdin:1:14: warning: ALX: A [-Wsign-conversion]
> 	/dev/stdin:1:14: error: ‘n’ undeclared here (not in a function)
> 
> The ALX warnings are there to kind-of print the stack.  Supposedly, I've
> extended (in patch 4/5) the scope by moving the pop_scope() call from
> where it was (somewhere between debug messages (2nd) J and I to after A
> (and the actual error).  I was expecting that to remove the error, but
> it didn't.  Do you know why that is not enough?

I've investigaged a bit more, and it seems that within
build_external_ref(), lookup_name() is returning NULL_TREE without
entering the conditional, which means I_SYMBOL_BINDING() is probably
returning NULL.

I've checked that the pop_scope() call indeed doesn't happen before the
error, so I don't know why the variable is not in scope.  Do you have
any idea of what may be happening?

	$ echo 'int f(int n)[n];' | /opt/local/gnu/gcc/ra/bin/gcc -x c /dev/stdin -Wsign-conversion
	<built-in>: warning: ALX: qe [-Wsign-conversion]
	<built-in>: warning: ALX: ww [-Wsign-conversion]
	/dev/stdin:1:6: warning: ALX: J [-Wsign-conversion]
	/dev/stdin:1:1: warning: ALX: ww [-Wsign-conversion]
	/dev/stdin:1:12: warning: ALX: J [-Wsign-conversion]
	/dev/stdin:1:13: warning: ALX: I [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: H [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: G [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: F [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: E [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: D [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: C [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: eq [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: ey [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: eu [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: B [-Wsign-conversion]
	/dev/stdin:1:14: warning: ALX: A [-Wsign-conversion]
	/dev/stdin:1:14: error: ‘n’ undeclared here (not in a function)
	/dev/stdin:1:14: warning: ALX: eS [-Wsign-conversion]
	/dev/stdin:1:1: warning: ALX: we [-Wsign-conversion]
	/dev/stdin:1:1: warning: ALX: we [-Wsign-conversion]
	/dev/stdin:1:1: warning: ALX: we [-Wsign-conversion]

Here's something with more debug printed lines ('we' is pop_scope()).


Have a lovely day!
Alex

> 
> Alejandro Colomar (5):
>   gcc/c/c-decl.cc: Return arrays
>   gcc/c/c-decl.cc: Allow VMTs at file scope
>   gcc/c/c-parser.cc: Refactor code
>   gcc/c/c-parser.cc: Extend the scope a little bit
>   dbg
> 
>  gcc/c/c-decl.cc   | 52 +++++++++++++++++++++++++++++++++++------------
>  gcc/c/c-parser.cc | 42 ++++++++++++++++++++++++++++++++------
>  gcc/c/c-typeck.cc |  3 +++
>  3 files changed, 78 insertions(+), 19 deletions(-)
> 
> Range-diff against v0:
> -:  ----------- > 1:  ef2d9f64dde gcc/c/c-decl.cc: Return arrays
> -:  ----------- > 2:  991aa4dd2ea gcc/c/c-decl.cc: Allow VMTs at file scope
> -:  ----------- > 3:  54bb6934166 gcc/c/c-parser.cc: Refactor code
> -:  ----------- > 4:  4d77c9e4f74 gcc/c/c-parser.cc: Extend the scope a little bit
> -:  ----------- > 5:  a3f8a6e438a dbg
> -- 
> 2.49.0
> 

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux