Bug 31331 - [avr] ICE on function attribute syntax for main()
Summary: [avr] ICE on function attribute syntax for main()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.1
: P3 minor
Target Milestone: 4.2.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 32517 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-23 21:16 UTC by Eric Weddington
Modified: 2014-02-16 13:12 UTC (History)
4 users (show)

See Also:
Host: mingw
Target: avr
Build: mingw
Known to work:
Known to fail:
Last reconfirmed: 2007-06-18 22:01:43


Attachments
Patch to fix bug, written by Anatoly Sokolov (715 bytes, patch)
2007-06-18 22:00 UTC, Eric Weddington
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Weddington 2007-03-23 21:16:22 UTC
Program:
__attribute__ ((naked)) int main(void)
{
    return 0;
}

Compiled with 4.1.1 for the AVR target:

Compiling C: test.c
avr-gcc -c -mmcu=atmega128 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./test.lst  -std=gnu99 -Wundef -MMD -MP -MF .dep/test.o.d test.c -o test.o 
test.c:2: internal compiler error: in start_function, at c-decl.c:6014
Please submit a full bug report,


A program with the proper syntax, compiles without error:

int main(void) __attribute__ ((naked));

int main(void)
{
    return 0;
}
Comment 1 Joerg Wunsch 2007-04-12 16:32:19 UTC
I disagree the "invalid syntax".  According to the formal attribute syntax
description:

``Any list of specifiers and qualifiers at the start of a declaration may
contain attribute specifiers, whether or not such a list may in that
context contain storage class specifiers.''

it is a perfectly valid use.  Syntactically, the ``int main(void)'' part of
that function definition is a declarator, so it essentially combines a
declaration with a definition.
Comment 2 Eric Weddington 2007-06-18 22:00:08 UTC
Created attachment 13733 [details]
Patch to fix bug, written by Anatoly Sokolov
Comment 3 Eric Weddington 2007-06-18 22:01:43 UTC
The attached patch, written by Anatoly Sokolov, fixes the bug.
Comment 4 Andrew Pinski 2007-06-26 19:32:37 UTC
*** Bug 32517 has been marked as a duplicate of this bug. ***
Comment 5 aesok 2007-07-04 21:10:37 UTC
Subject: Bug 31331

Author: aesok
Date: Wed Jul  4 21:10:28 2007
New Revision: 126337

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126337
Log:
	PR target/31331
	* config/avr/avr.c (avr_naked_function_p): Handle receiving a type
	rather than a decl. 
	(avr_attribute_table): Make "naked" attribute apply to function types
	rather than to decls.
	(avr_handle_fntype_attribute): New function.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c

Comment 6 aesok 2007-07-07 19:30:48 UTC
Subject: Bug 31331

Author: aesok
Date: Sat Jul  7 19:30:37 2007
New Revision: 126446

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126446
Log:
	PR target/31331
	* config/avr/avr.c (avr_naked_function_p): Handle receiving a type
	rather than a decl. 
	(avr_attribute_table): Make "naked" attribute apply to function types
	rather than to decls.
	(avr_handle_fntype_attribute): New function.


Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/config/avr/avr.c

Comment 7 aesok 2007-07-07 19:37:02 UTC
Fixed.
Comment 8 aesok 2007-07-07 19:39:45 UTC
Subject: Bug 31331

Author: aesok
Date: Sat Jul  7 19:39:36 2007
New Revision: 126447

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126447
Log:
	PR target/31331
	* config/avr/avr.c (avr_naked_function_p): Handle receiving a type
	rather than a decl. 
	(avr_attribute_table): Make "naked" attribute apply to function types
	rather than to decls.
	(avr_handle_fntype_attribute): New function.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/avr/avr.c

Comment 9 Jackie Rosen 2014-02-16 13:12:53 UTC Comment hidden (spam)