From: Borja F. <bor...@gm...> - 2012-03-06 19:44:05
|
In my opinion the best thing should be to error out, it doesn't make sense to set this attributes in non void functions. Technically from a codegen perspective it doesn't matter because registers are all saved and restored unless the naked attrib is set so it wouldnt't make a difference except for some useless instructions. Doing this kind of things shows that the programmer doesn't understand what he's doing. I issued the warning to be sort of backwards compat with gcc, although in this case we would be supporting wrong code. In conclusion, error out. 2012/3/6 Weddington, Eric <Eri...@at...> > > Well, we don't have to slavishly follow GCC either. > > What do you think? > > If you were a programmer, would you want the compiler to warn you, then > not apply the attribute and continue compilation? > > Should the compiler assume that you did not want the attribute to be > applied in the case of a non-void function or one with arguments? > > The compiler really doesn't know what the fix should be. I would think, > that in this case, it really is equivalent to a syntax error. These > attributes are only allowed on a non-void, non-argument function. > Otherwise, the user needs to the fix the code to expressly say what > needs to be done. > > This is outside the realm of the C standard, since we're dealing with > function attributes and ISRs. Again, what do you think? > > Eric Weddington > > > -----Original Message----- > > From: Borja Ferrer [mailto:bor...@gm...] > > Sent: Tuesday, March 06, 2012 12:22 PM > > To: Weddington, Eric > > Cc: avr...@li... > > Subject: Re: [avr-llvm-devel] Interrupt handling > > > > It issues a warning, so, it doesn't apply the attribute and it doesn't > abort > > compilation. I checked gcc and it warns aswell. However i can error > out if > > it's better, i leave that up to you. > > > > > > 2012/3/6 Weddington, Eric <Eri...@at...> > > > > > > > > > > > -----Original Message----- > > > From: Borja Ferrer [mailto:bor...@gm...] > > > > > Sent: Tuesday, March 06, 2012 11:57 AM > > > To: Weddington, Eric > > > Cc: avr...@li... > > > Subject: Re: [avr-llvm-devel] Interrupt handling > > > > > > > > I've added some checks to the frontend when setting the > > signal/interrupt > > > attribute that are the following: > > > > > > 1) warn when the attrib is used in things that aren't function > > declarations. > > > 2) warn when the function has arguments > > > 3) warn when the function doesnt return a void > > > > > > If anybody can think of any more checks that are required let > me know. > > > > > > Oh, and here are the warning messages printed for cases 2 and > 3 > > respectively, > > > again, if somebody has a better descriptive string or with > better > > english I'll > > > change it: > > > > > > 2) "'%0' attribute only applies to functions with no > arguments" > > > 3) "'%0' attribute only applies to functions with a void > return type" > > > where %0 is either interrupt or signal > > > > > > > > > Semantics question: Do you mean that it issues just a *warning*? > Or does > > it error out on these? > > > > > > |