osdir.com
mailing list archive

Subject: hack to accept two C99 syntax - msg#00000

List: programming.splint.general

Date: Next Index Thread: Next Index
Hi,

I started to use splint a couple of weeks ago, and
found that it does not recognize the following two
C99 syntax rules.

1. declaration in a block following other statements
2. declaration in a for-loop init-expr

So I hacked the splint src/cgrammar.y file a little
to accept these syntax. So far I haven't found any
problem, but use it at your own risk. If you find any
error or enhancement of this change, please let me know
or post it to the group.

The attached diff file for src/grammar.y
will increase the R/R conflict to 243.

Thanks.

Chih-Hung Hsieh

*** orig/splint-3.1.1/src/cgrammar.y Thu Mar 6 23:16:12 2003
--- splint-3.1.1/src/cgrammar.y Mon Jul 31 13:59:39 2006
***************
*** 218,224 ****
%type <entry> endIter

%type <funcclauselist> functionClauses functionClausesPlain
! %type <funcclause> functionClause functionClause functionClausePlain

%type <globsclause> globalsClause globalsClausePlain
%type <modsclause> modifiesClause modifiesClausePlain nomodsClause
--- 218,224 ----
%type <entry> endIter

%type <funcclauselist> functionClauses functionClausesPlain
! %type <funcclause> functionClause functionClausePlain

%type <globsclause> globalsClause globalsClausePlain
%type <modsclause> modifiesClause modifiesClausePlain nomodsClause
***************
*** 1726,1739 ****
{ $$ = exprNode_doWhile ($2, $5); }
| forPred iterDefStmt
{ $$ = exprNode_for ($1, $2); }
;

forPred
! : CFOR TLPAREN optExpr TSEMI optExpr TSEMI
{ context_setProtectVars (); } optExpr { context_sizeofReleaseVars (); }
TRPAREN
! { $$ = exprNode_forPred ($3, $5, $8);
context_enterForClause ($5); }
;

partialIterStmt
--- 1726,1745 ----
{ $$ = exprNode_doWhile ($2, $5); }
| forPred iterDefStmt
{ $$ = exprNode_for ($1, $2); }
+ DeleteInnerScope
;

forPred
! : CFOR CreateInnerScope TLPAREN instanceDecl optExpr TSEMI
{ context_setProtectVars (); } optExpr { context_sizeofReleaseVars (); }
TRPAREN
! { $$ = exprNode_forPred ($4, $5, $8);
context_enterForClause ($5); }
+ | CFOR CreateInnerScope TLPAREN optExpr TSEMI optExpr TSEMI
+ { context_setProtectVars (); } optExpr { context_sizeofReleaseVars (); }
+ TRPAREN
+ { $$ = exprNode_forPred ($4, $6, $9);
+ context_enterForClause ($6); }
;

partialIterStmt
***************
*** 1861,1866 ****
--- 1867,1873 ----
| stmtList TRBRACE { $$ = exprNode_updateLocation ($1, lltok_getLoc ($2)); }
| stmtList QNOTREACHED TRBRACE
{ $$ = exprNode_notReached (exprNode_updateLocation ($1, lltok_getLoc
($3))); }
+ /*
| initializerList TRBRACE { $$ = exprNode_updateLocation ($1, lltok_getLoc
($2)); }
| initializerList QNOTREACHED TRBRACE
{ $$ = exprNode_notReached (exprNode_updateLocation ($1, lltok_getLoc
($3))); }
***************
*** 1870,1875 ****
--- 1877,1883 ----
{ $$ = exprNode_notReached (exprNode_updateLocation (exprNode_concat ($1,
$2),
lltok_getLoc ($3)));
}
+ */
;

compoundStmtAux
***************
*** 1909,1915 ****
;

stmtList
! : stmt { $$ = $1; }
| stmtList stmt { $$ = exprNode_concat ($1, $2); }
;

--- 1917,1925 ----
;

stmtList
! : initializer { $$ = $1; }
! | stmt { $$ = $1; }
! | stmtList initializer { $$ = exprNode_concat ($1, $2); }
| stmtList stmt { $$ = exprNode_concat ($1, $2); }
;

***************
*** 2138,2143 ****
--- 2148,2154 ----
{ $$ = exprNode_statement (exprNode_doWhile ($2, $5), $7); }
| forPred stmt
{ $$ = exprNode_for ($1, $2); context_exitForClause ($1, $2); }
+ DeleteInnerScope
;

iterationStmtErr
***************
*** 2147,2152 ****
--- 2158,2164 ----
| doHeader stmtErr WHILE TLPAREN expr TRPAREN
{ $$ = exprNode_doWhile ($2, $5); }
| forPred stmtErr { $$ = exprNode_for ($1, $2); context_exitForClause ($1,
$2); }
+ DeleteInnerScope
;

jumpStmt
_______________________________________________
splint-discuss mailing list
splint-discuss-Y5+ky9gHf7K61byRX2g7jjevRRvlBcP1@xxxxxxxxxxxxxxxx
http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss
Was this page helpful?
Yes No
Thread at a glance:

Next Message by Date: click to view message preview

Unrecognized macros like "timerisset" "timercmp"

I'm a new guy on splint, does anyone can help me about the error of "unrecognized ids"! following is my simple c file "test2.c" 1. #include <stdio.h> 2. #include <stdlib.h> 3. #include <sys/types.h> 4. #include <sys/time.h> 5. 6. 7. typedef struct timeval * p_timer; 8. typedef struct timeval obj_timer; 9. obj_timer now; 10. int 11. _timer_expire(p_timer tp) 12. { 13. if (timerisset(tp) && timercmp((&now), (tp), >)) { 14. timerclear(tp); 15. return 1; 16. } 17. return 0; 18. } I use the splint cmd like this: splint +posixlib -skip-posix-headers test2.c it outputs : Splint 3.1.1 --- 06 Jan 2006 test2.c: (in function _timer_expire) test2.c:13:6: Unrecognized identifier: timerisset Identifier used in code has not been declared. (Use -unrecog to inhibit warning) test2.c:13:24: Unrecognized identifier: timercmp test2.c:13:48: Parse Error. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue. It seems splint can not recognize the macro in <sys/time.h> like "timerisset" & "timercmp" Help me!!!! Thanks a lot!!

Next Message by Thread: click to view message preview

Unrecognized macros like "timerisset" "timercmp"

I'm a new guy on splint, does anyone can help me about the error of "unrecognized ids"! following is my simple c file "test2.c" 1. #include <stdio.h> 2. #include <stdlib.h> 3. #include <sys/types.h> 4. #include <sys/time.h> 5. 6. 7. typedef struct timeval * p_timer; 8. typedef struct timeval obj_timer; 9. obj_timer now; 10. int 11. _timer_expire(p_timer tp) 12. { 13. if (timerisset(tp) && timercmp((&now), (tp), >)) { 14. timerclear(tp); 15. return 1; 16. } 17. return 0; 18. } I use the splint cmd like this: splint +posixlib -skip-posix-headers test2.c it outputs : Splint 3.1.1 --- 06 Jan 2006 test2.c: (in function _timer_expire) test2.c:13:6: Unrecognized identifier: timerisset Identifier used in code has not been declared. (Use -unrecog to inhibit warning) test2.c:13:24: Unrecognized identifier: timercmp test2.c:13:48: Parse Error. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue. It seems splint can not recognize the macro in <sys/time.h> like "timerisset" & "timercmp" Help me!!!! Thanks a lot!!
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by