** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
** For more information: http://www.splint.org
*/
%{
%token <tok> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN
%token <tok> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
%token <tok> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
-%token <tok> CSIZEOF CALIGNOF ARROW_OP CTYPEDEF COFFSETOF
+%token <tok> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
%token <tok> INC_OP DEC_OP LEFT_OP RIGHT_OP
%token <tok> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
%token <tok> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
%token <tok> QSETS
%token <tok> QRELEASES
%token <tok> QPRECLAUSE
-%token <tok> QPOSTCLAUSE
+%token <tok> QPOSTCLAUSE
+%token <tok> QINVARIANT
%token <tok> QALT
%token <tok> QUNDEF QKILLED
%token <tok> QENDMACRO
%token <ctyp> CGCHAR CBOOL CINT CGFLOAT CDOUBLE CVOID
%token <tok> QANYTYPE QINTEGRALTYPE QUNSIGNEDINTEGRALTYPE QSIGNEDINTEGRALTYPE
-%type <typequal> nullterminatedQualifier
%token <tok> QNULLTERMINATED
%token <tok> QSETBUFFERSIZE
%token <tok> QSETSTRINGLENGTH
%type <conL> BufConstraintList
+%type <conL> optStructInvariant
+
%type <tok> BufUnaryOp
+/*drl 1/6/2002 either /\ or && */
+%type <tok> constraintSeperator
+
%type <enumnamelist> enumeratorList
%type <cstringlist> fieldDesignator
%type <expr> compoundStmt compoundStmtAux compoundStmtRest compoundStmtAuxErr
%type <expr> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt
%type <expr> stmtErr stmtListErr compoundStmtErr expressionStmtErr
-%type <expr> iterationStmtErr initializerList initializer ifPred whilePred forPred iterWhilePred
+%type <expr> iterationStmtErr initializerList typeInitializerList initializer
+%type <expr> ifPred whilePred forPred iterWhilePred typeInitializer
+
+%type <expr> designator designatorList designation
%type <typequal> storageSpecifier typeQualifier typeModifier globQual
%type <tquallist> optGlobQuals
| iterDecl { uentry_clearDecl (); }
| macroDef { uentry_clearDecl (); }
| initializer { uentry_checkDecl (); exprNode_free ($1); }
+ | TSEMI { uentry_clearDecl (); /* evans 2002-02-08: okay to have a null statement */ }
| error { uentry_clearDecl (); }
constantDecl
| IsType TLPAREN NotType namedDecl IsType TRPAREN
{ $$ = idDecl_expectFunction ($4); }
| namedDeclBase TLSQBR TRSQBR
- { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); }
| namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
- exprNode_findValue($4);
+ exprNode_findValue ($4);
+ idDecl_notExpectingFunction ($1);
+
if (exprNode_hasValue ($4))
{
- $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
+ $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1),
+ exprNode_getLongValue ($4)));
}
else
{
- $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1)));
+ $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
}
}
| namedDeclBase PushType TLPAREN TRPAREN
| IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
{ $$ = idDecl_expectFunction ($4); }
| plainNamedDeclBase TLSQBR TRSQBR
- { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); }
| plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
int value;
value = 0;
}
- $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), value));
+ $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), value));
}
| plainNamedDeclBase PushType TLPAREN TRPAREN
{ setCurrentParams (uentryList_missingParams); }
/*drl*/
+constraintSeperator
+: TCAND
+| AND_OP
+
BufConstraintList
-: BufConstraint TCAND BufConstraintList { $$ = constraintList_add ($3, $1); }
+: BufConstraint constraintSeperator BufConstraintList { $$ = constraintList_add ($3, $1); }
| BufConstraint { $$ = constraintList_single ($1); }
BufConstraint
| TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
| TYPE_NAME_OR_ID { $$ = exprNode_fromIdentifier (coerceId ($1)); }
| QEXTENSION { $$ = exprNode_makeError (); }
+ | TLPAREN { exprChecks_inCompoundStatementExpression (); }
+ compoundStmt TRPAREN
+ { exprChecks_leaveCompoundStatementExpression (); $$ = exprNode_compoundStatementExpression ($1, $3); }
postfixExpr
: primaryExpr
| postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
| postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
| postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
-
+ | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE
+ { /* added for C99 */ $$ = exprNode_undefined; /*@i87 no checking */ }
+
argumentExprList
: assignExpr { $$ = exprNodeList_singleton ($1); }
| argumentExprList TCOMMA assignExpr { $$ = exprNodeList_push ($1, $3); }
: assignExpr
| TLBRACE initList TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); }
| TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); }
+ | designation init { $$ = exprNode_undefined; }
+
+/*
+** Splint parses these (added in ISO C99), but no checking yet...
+*/
+
+designation
+ : designatorList TASSIGN { $$ = $1; }
+ | newId TCOLON { $$ = exprNode_undefined;
+ /* gcc extension, obsolete since 2.5 */ }
+designatorList
+ : designator { $$ = exprNode_undefined; }
+ | designatorList designator { $$ = exprNode_undefined; }
+
+designator
+ : TLSQBR constantExpr TRSQBR { $$ = exprNode_undefined; }
+ | TDOT newId { $$ = exprNode_undefined; }
initList
: init
| QAUTO { $$ = qual_createAuto (); }
| QREGISTER { $$ = qual_createRegister (); }
-nullterminatedQualifier:
- QNULLTERMINATED IsType { $$ = qual_createNullTerminated (); }
-
stateClause
: stateClausePlain QENDMACRO { $$ = $1; }
: /* empty */ { $$ = qtype_unknown (); }
| completeTypeSpecifier { $$ = $1; }
+
+optStructInvariant
+: /* empty */ { $$ = constraintList_undefined; }
+/* don't want to have support for structure invariant until we're
+ sure it's stable
+ | QINVARIANT BufConstraintList QENDMACRO { $$ = $2 }
+*/
+
suSpc
: NotType CSTRUCT newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
CreateStructInnerScope
- structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
+ structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
TRBRACE
- { $$ = declareStruct ($3, $8); }
+ optStructInvariant { {ctype ct; ct = declareStruct ($3, $8); /* setGlobalStructInfo(ct, $12);*/ $$ = ct;} }
| NotType CUNION newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
CreateStructInnerScope
structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
| TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
| TLSQBR constantExpr TRSQBR
{ $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
- | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeArray ($1); }
+ | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeInnerArray ($1); }
| abstractDeclBase TLSQBR constantExpr TRSQBR
- { $$ = ctype_makeFixedArray ($1, exprNode_getLongValue ($3)); }
+ { $$ = ctype_makeInnerFixedArray ($1, exprNode_getLongValue ($3)); }
| IsType TLPAREN TRPAREN
{ $$ = ctype_makeFunction (ctype_unknown, uentryList_makeMissingParams ()); }
| IsType TLPAREN paramTypeList TRPAREN
| iterStmt
| jumpStmt
+
iterBody
: iterDefStmtList { $$ = $1; }
: initializer { $$ = $1; }
| initializerList initializer { $$ = exprNode_concat ($1, $2); }
+typeInitializerList
+ : typeInitializer { $$ = $1; }
+ | typeInitializerList TCOMMA typeInitializer { $$ = exprNode_concat ($1, $3); }
+
+typeInitializer
+ : assignExpr { $$ = $1; }
+ | TLBRACE typeInitializerList optComma TRBRACE { $$ = $2; }
+
stmtList
: stmt { $$ = $1; }
| stmtList stmt { $$ = exprNode_concat ($1, $2); }
:
| TSEMI { ; }
+optComma
+ :
+ | TCOMMA { ; }
+
id
: IDENTIFIER
typeName
: TYPE_NAME
| TYPE_NAME_OR_ID { $$ = ctype_unknown; }
+ | CTYPEOF TLPAREN expr TRPAREN { $$ = exprNode_getType ($3); exprNode_free ($3); }
+ | CTYPEOF TLPAREN typeExpression TRPAREN { $$ = qtype_getType ($3); }
%%