|
| <prev next> |
hack to accept two C99 syntax: msg#00000programming.splint.general
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 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Next by Date: | Unrecognized macros like "timerisset" "timercmp": 00000, raymond |
|---|---|
| Next by Thread: | Unrecognized macros like "timerisset" "timercmp": 00000, raymond |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | Mail Home | sitemap | FAQ | advertise |