]> andersk Git - splint.git/blobdiff - src/cgrammar.y
EXtensive code clean up. Almost passes LCLint.
[splint.git] / src / cgrammar.y
index 1f4527b21519c1e5dce6db4ed66f4eb7b63dc5c6..0857a900f84158bbc459d555f53446dc803dcbc5 100644 (file)
@@ -69,7 +69,7 @@ void yyerror (char *s);
 # undef realloc
 # endif
 
-void checkandsetBufState(idDecl id, exprNode is);
+
 %}
 
 %union
@@ -94,6 +94,13 @@ void checkandsetBufState(idDecl id, exprNode is);
  /*@only@*/ exprNodeList alist;
  /*@only@*/ sRefSet srset; 
  /*@only@*/ cstringList cstringlist;
+  /*drl
+    added 1/19/2001
+  */
+  constraint con;
+  constraintList conL;
+  constraintExpr conE;
+  /* drl */
 }
 
 /* standard C tokens */
@@ -209,16 +216,17 @@ void checkandsetBufState(idDecl id, exprNode is);
 %type <sr>    mExpr modListExpr specClauseListExpr
 
 /*drl*/
-%type <sr>    BufConstraint
+%type <con>    BufConstraint
 %type <tok> relationalOp
 %type <tok> BufBinaryOp
 %type <tok> bufferModifier
 
-%type <sr> BufConstraintExpr
+%type <conE> BufConstraintExpr
 
-%type <sr> BufConstraintTerm
+%type <conE> BufConstraintTerm
+%type <sr> BufConstraintSrefExpr
 
-%type <sr>    BufConstraintList
+%type <conL>    BufConstraintList
 
 %type <tok>  BufUnaryOp
 
@@ -251,7 +259,7 @@ void checkandsetBufState(idDecl id, exprNode is);
 %type <tquallist> optGlobQuals
 %type <qtyp> completeType completeTypeSpecifier optCompleteType
 %type <qtyp> completeTypeSpecifierAux altType typeExpression 
-%type <expr> lclintassertion
+/*%type <expr> lclintassertion*/
 
 %start file
 
@@ -322,10 +330,12 @@ namedDeclBase
      context_popLoc (); 
    }
  | namedDeclBase PushType TLPAREN genericParamList TRPAREN 
-   { setCurrentParams ($4); 
+   { setCurrentParams ($4);
+    
         } 
  optGlobMods  optGlobBufConstraints
-   { clearCurrentParams ();
+   { setImplictfcnConstraints ();
+     clearCurrentParams ();
      $$ = idDecl_replaceCtype ($1, ctype_makeFunction (idDecl_getCtype ($1), $4));
      context_popLoc ();
 
@@ -438,7 +448,7 @@ context_setProtectVars (); enterParamsTemp ();
 
 BufConstraintList
 : BufConstraint BufConstraintList{ $$ = constraintList_add ($2, $1); }
-| BufConstraint {constraintList c; c = constraintList_new(); c = constraintList_add (c, $1); $$ = c}
+| BufConstraint {constraintList c; c = constraintList_makeNew(); c = constraintList_add (c, $1); $$ = c}
 
 BufConstraint
 :  BufConstraintExpr relationalOp BufConstraintExpr TSEMI  {
@@ -462,15 +472,41 @@ BufConstraintExpr
    $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
 
 BufConstraintTerm
-: id                              { /* $$ = constraintExpr_makeTermsRef (checkSpecClausesId ($1)); */
- $$ = constraintExpr_makeTermsRef (checkbufferConstraintClausesId ($1));}
- | NEW_IDENTIFIER                  { $$ = constraintExpr_makeTermsRef(fixSpecClausesId ($1) ); }
+: BufConstraintSrefExpr { $$ =  constraintExpr_makeTermsRef($1);} 
  | CCONSTANT {  char *t; int c;
   t =  cstring_toCharsSafe (exprNode_unparse($1));
   c = atoi( t );
   $$ = constraintExpr_makeIntLiteral (c);
 }
 
+
+BufConstraintSrefExpr
+: id                              {
+   $$ =
+     checkbufferConstraintClausesId ($1);}
+ | NEW_IDENTIFIER                  { $$ = fixSpecClausesId ($1); }
+
+ | BufConstraintSrefExpr TLSQBR TRSQBR       { $$ = sRef_makeAnyArrayFetch ($1); }
+ |  BufConstraintSrefExpr  TLSQBR CCONSTANT TRSQBR {
+     char *t; int c;
+  t =  cstring_toCharsSafe (exprNode_unparse($3));
+  c = atoi( t );
+   $$ = sRef_makeArrayFetchKnown($1, c); }
+ | TMULT  BufConstraintSrefExpr               { $$ = sRef_constructPointer ($2); }
+ | TLPAREN BufConstraintSrefExpr TRPAREN     { $$ = $2; }  
+ |  BufConstraintSrefExpr TDOT newId          { cstring_markOwned ($3);
+                                           $$ = sRef_buildField ($1, $3); }
+ |  BufConstraintSrefExpr ARROW_OP newId      { cstring_markOwned ($3);
+                                            $$ = sRef_makeArrow ($1, $3); }
+
+/*
+| BufConstraintTerm TLSQBR TRSQBR       { $$ = sRef_makeAnyArrayFetch ($1); }
+ | specClauseListExpr TLSQBR mExpr TRSQBR { $$ = sRef_makeAnyArrayFetch ($1); }
+ | TLPAREN specClauseListExpr TRPAREN     { $$ = $2; }  
+ | specClauseListExpr TDOT newId          { cstring_markOwned ($3);
+                                           $$ = sRef_buildField ($1, $3); }
+*/
+
 /*BufConstraintExpr
 : BufConstraintTerm 
 */
@@ -1288,10 +1324,9 @@ stmt
  | iterationStmt 
  | iterStmt
  | jumpStmt 
-/*  | tst1 */
- | lclintassertion {$$ = $1; printf ("Doing stmt lclintassertion\n"); }
-
+/* | lclintassertion {$$ = $1; printf ("Doing stmt lclintassertion\n"); }*/
 
+/*
 lclintassertion
  : QSETBUFFERSIZE id CCONSTANT QENDMACRO { printf(" QSETBUFFERSIZE id CCONSTANT HEllo World\n");  uentry_setBufferSize($2, $3); $$ = exprNode_createTok ($4);
   }
This page took 0.050159 seconds and 4 git commands to generate.