OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

FR: add support for GCC extension values for labels / computed goto

Open GitMensch opened this issue 7 years ago • 1 comments

This is a GCC extension (not high priority to add, but would be nice to be added later) documented at https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

It allows to assign a label address to a void pointer and issue a goto on it:

	int test ()
	{
	void	*test_ptr;
	test_ptr = &&lab;
	
	goto *test_ptr;
	return 1;
	
	lab:
	return 0;

as it is currently not supported occ says:

Warning(137)  conftest.c(4):  'test_ptr' used without prior assignment in function test
Error(147)    conftest.c(4):  Expression syntax error in function test
Error( 18)    conftest.c(4):  Undefined symbol 'lab' in function test
Error(183)    conftest.c(6):  goto statement needs a label specifier in function test
Error( 11)    conftest.c(7):  Syntax error: ; expected in function test
4 Errors

GitMensch avatar Jun 04 '18 09:06 GitMensch

Just wanted to leave a ping on this (still no urgency).

GitMensch avatar Feb 10 '19 21:02 GitMensch

found a program that implements this to test with : https://github.com/marcobambini/gravity

LADSoft avatar Nov 06 '22 20:11 LADSoft

There is a most simple testcase in the start of this issue.

... and:

You can also "create" those very easy: compile with a cobc that was compiled with OrangeC before and add -fcomputed-goto or run its configure script - which tests for that feature (not checked, but very likely with that test program above) and if available makes -fcomputed-goto the default so running make checkall give you some thousand tests of this feature (even if that means likely only 5-10 real different tests).

GitMensch avatar Nov 06 '22 20:11 GitMensch

It seems that this should have been closed with 057df1b, right?

Did you gave that a try with GnuCOBOL (configure should find it working and the GnuCOBOL testsuite will then use it a lot), especially with the NIST testsuite?

GitMensch avatar Feb 23 '23 17:02 GitMensch

yes this should have been closed... don't think I ran it against gnu cobol though...

LADSoft avatar Feb 23 '23 18:02 LADSoft

So... should we just close it or do you plan to run the test before?

GitMensch avatar Feb 23 '23 18:02 GitMensch

if i have time i'll run the tests this weekend, otherwise i might close it...

LADSoft avatar Feb 24 '23 02:02 LADSoft

I'm going to close this. eventually I will get back to gnu cobol and it will get tested as part of other tests...

LADSoft avatar Jun 30 '23 18:06 LADSoft