[splint-discuss] Parse error with @ from the IAR compiler

Keith.Richeson at us.elster.com Keith.Richeson at us.elster.com
Fri Jan 19 10:37:13 PST 2007


Mr. Wojcik,

Thank you for your recommendations.  I had not thought about using sed to
accomplish basically the same thing I am trying to do with the -D option.
I will cetainly look into that.  Thanks!!!

Keith Richeson
(919) 250-5511
keith.richeson at us.elster.com

"A problem well stated is a problem half solved"



                                                                           
             "Michael Wojcik"                                              
             <Michael.Wojcik at M                                             
             icroFocus.com>                                             To 
             Sent by:                  "Discussions about the Splint       
             splint-discuss-bo         annotation-assisted static          
             unces at cs.virginia         analysisproject"                    
             .edu                      <splint-discuss at cs.virginia.edu>    
                                                                        cc 
                                                                           
             01/19/2007 11:51                                      Subject 
             AM                        RE: [splint-discuss] Parse error    
                                       with @ from the IAR compiler        
                                                                           
             Please respond to                                             
             Discussions about                                             
                the Splint                                                 
             annotation-assist                                             
                 ed static                                                 
                 analysis                                                  
                  project                                                  
             <splint-discuss at c                                             
              s.virginia.edu>                                              
                                                                           
                                                                           




> From: splint-discuss-bounces at cs.virginia.edu
> [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of
> Keith.Richeson at us.elster.com
> Sent: Friday, 19 January, 2007 09:12
> Subject: [splint-discuss] Parse error with @ from the IAR compiler
>
>
>
> I'm working on an embedded project and we are using the IAR C compiler
for
> the 8051.  One of the extensions to the compiler is that it allows a
user
> to "locate" a variable using the @ symbol.  That is to say, if I want
to
> make sure that a variable gets allocated at location 0xFFE0 in RAM, I
can
> use the following declaration:
>
> int myVar @ 0xFFE0;
>
> and the compiler will understand the statement.
>
> Of course since this is not standard C splint is not happy with the
above
> statement, and in fact a parse error is generated...

As it should be.  "@" isn't even part of the basic source character set
defined by ISO 9899; no C implementation is required to translate a
source file containing it.

>  My first idea of how to deal with this is to define @ = ";
> //" so that the line effectively ends at the @ symbol and everything
else
> is a comment.

I'll note in passing that prior to C99, "//" wasn't a part of standard C
either.

The real problem, though, is that "@", not being part of the source
character set, can't be used in an identifier, either, and macro names
are identifiers.

> Does anyone have any other suggestions for getting around this
> issue?

I'd wrap the compiler's special syntax in a macro, then
conditionally-compile it for Splint:

             #if defined S_SPLINT_S
                         #define VAR_AT(addr)
             #else
                         #define VAR_AT(addr) @ addr
             #endif

and then in your code, replace all

             int myVar @ 0xFFE0;

with

             int myVar VAR_AT(0xFFE0);

Of course, that may be more work than what you want to do.  Another
alternative would be to stick a filter into your toolchain in front of
Splint that removes all the @-expressions; that's pretty trivial if
they're all consistently formatted with the address on the same line as
the operator.  With sed, for example:

             sed "s/@[^,;]*//g" source.c > source-tmp.c
             splint source-tmp.c

Details depend on what tools you have available, but this this is easy
to do on Unix, and pretty easy on Windows with the addition of some free
software.

--
Michael Wojcik                517 676-0892
Software Systems Developer    Micro Focus     http://www.microfocus.com/

_______________________________________________
splint-discuss mailing list
splint-discuss at ares.cs.Virginia.EDU
http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss

______________________________________________________________________
This email has been spam and virus checked by Elster IT Services.




More information about the splint-discuss mailing list