]> andersk Git - splint.git/blobdiff - src/cgrammar.y
Tried to fix some problems with the configuration system.
[splint.git] / src / cgrammar.y
index c71d42083d9af9791e607929878928baeb4719fc..701ccce4261bed8d4cb8e057d4df5ac6514846d1 100644 (file)
@@ -110,7 +110,7 @@ extern void yyerror (char *);
   /*@only@*/ uentry oentry;
   /*@only@*/ exprNode expr;
   /*@only@*/ enumNameList enumnamelist;
-  /*@only@*/ exprNodeList alist;
+  /*@only@*/ exprNodeList exprlist;
   /*@only@*/ sRefSet srset; 
   /*@only@*/ cstringList cstringlist;
 
@@ -217,7 +217,7 @@ extern void yyerror (char *);
 
 %type <globsclause> globalsClause globalsClausePlain
 %type <modsclause> modifiesClause modifiesClausePlain nomodsClause
-%type <warnclause> warnClause warnClausePlain
+%type <warnclause> warnClause warnClausePlain optWarnClause
 %type <funcclause> conditionClause conditionClausePlain
 %type <stateclause> stateClause stateClausePlain
 %type <msconstraint> metaStateConstraint 
@@ -254,8 +254,8 @@ extern void yyerror (char *);
 %type <ntyplist> structNamedDeclList
 
 %type <entrylist> genericParamList paramTypeList paramList idList paramIdList
-%type <alist> argumentExprList iterArgList
-%type <alist> initList
+%type <exprlist> argumentExprList iterArgList
+%type <exprlist> initList namedInitializerList namedInitializerListAux
 %type <flist> structDeclList structDecl
 %type <srset> locModifies modList specClauseList optSpecClauseList
 %type <sr>    mExpr modListExpr specClauseListExpr
@@ -314,8 +314,8 @@ file
  | externalDefs
 
 externalDefs
- : externalDef
- | externalDefs externalDef 
+ : externalDef { context_checkGlobalScope (); }
+ | externalDefs externalDef { context_checkGlobalScope (); }
 
 externalDef
  : fcnDef optSemi { uentry_clearDecl (); } 
@@ -361,8 +361,16 @@ namedDeclBase
  | namedDeclBase TLSQBR TRSQBR 
    { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
  | namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
-   { 
-     $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
+   {
+     exprNode_findValue($4);
+     if (exprNode_hasValue ($4)) 
+       {
+        $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), exprNode_getLongValue ($4)));
+       } 
+     else
+       {
+        $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); 
+       }
    }
  | namedDeclBase PushType TLPAREN TRPAREN 
    { setCurrentParams (uentryList_missingParams); }
@@ -373,7 +381,9 @@ namedDeclBase
      
      $$ = idDecl_replaceCtype ($1, ct);
      idDecl_addClauses ($$, $6);
-     context_popLoc (); 
+     context_popLoc ();
+     /*drl 7/25/01 added*/
+     setImplictfcnConstraints();
    }
  | namedDeclBase PushType TLPAREN genericParamList TRPAREN 
    { setCurrentParams ($4); } 
@@ -449,8 +459,11 @@ metaStateConstraint
 
 metaStateSpecifier
   : BufConstraintSrefExpr { cscanner_expectingMetaStateName (); } TCOLON metaStateName
-   { cscanner_clearExpectingMetaStateName ();
-     $$ = metaStateSpecifier_create ($1, $4); }
+    { cscanner_clearExpectingMetaStateName ();
+      $$ = metaStateSpecifier_create ($1, $4); }
+  | CTOK_ELIPSIS { cscanner_expectingMetaStateName (); } TCOLON metaStateName
+    { cscanner_clearExpectingMetaStateName ();
+      $$ = metaStateSpecifier_createElipsis ($4); }
 
 metaStateExpression
 : metaStateSpecifier { $$ = metaStateExpression_create ($1); }
@@ -487,16 +500,8 @@ BufConstraintExpr
    $$ = constraintExpr_parseMakeBinaryOp ($2, $3, $4); }
 
 BufConstraintTerm
- : BufConstraintSrefExpr { $$ =  constraintExpr_makeTermsRef($1);} 
- | CCONSTANT 
-   {  
-     /* char *t; int c;
-       t =  cstring_toCharsSafe (exprNode_unparse($1));
-       c = atoi( t );
-     */
-     
-     $$ = constraintExpr_makeIntLiteral (exprNode_getLongValue ($1));
-   }
+ : BufConstraintSrefExpr { $$ =  constraintExpr_makeTermsRef ($1);} 
+ | CCONSTANT { $$ = constraintExpr_makeIntLiteral (exprNode_getLongValue ($1)); }
 
 BufConstraintSrefExpr
 : id            
@@ -618,14 +623,22 @@ flagSpec
 flagId
  : NEW_IDENTIFIER
 
+optWarnClause
+ : warnClause
+ | /* empty */ { $$ = warnClause_undefined; }
+
 warnClause
  : warnClausePlain QENDMACRO { $$ = $1; }
 
 warnClausePlain
  : QWARN flagSpec cconstantExpr
-   { $$ = warnClause_create ($1, $2, $3); }
+   {      
+     llassert (exprNode_knownStringValue ($3));
+     $$ = warnClause_create ($1, $2, cstring_copy (multiVal_forceString (exprNode_getValue ($3)))); 
+     exprNode_free ($3);
+   }
  | QWARN flagSpec
-   { $$ = warnClause_create ($1, $2, exprNode_undefined); }
+   { $$ = warnClause_create ($1, $2, cstring_undefined); }
 
 globIdList
  : globIdListExpr                     { $$ = globSet_single ($1); }
@@ -678,20 +691,20 @@ fcnBody
      exprNode_checkFunctionBody ($3); $$ = $3; 
      context_exitInner ($3); 
    }
- | initializerList 
-   { doneParams (); context_enterInnerContext (); }
+ | { context_enterOldStyleScope (); } initializerList 
+   { oldStyleDoneParams (); context_enterInnerContext (); } 
    compoundStmt 
    {
-     context_exitInner ($3);
-     exprNode_checkFunctionBody ($3); 
-     $$ = $3; /* old style */ 
+     exprNode_checkFunctionBody ($4); 
+     $$ = $4; /* oldstyle */ 
+     context_exitInner ($4);
    } 
  
 fcnDef
  : fcnDefHdr fcnBody 
    { 
      context_setFunctionDefined (exprNode_loc ($2)); 
-     exprNode_checkFunction (context_getHeader (), $2); 
+     exprNode_checkFunction (context_getHeader (),  $2); 
      /* DRL 8 8 2000 */
      
      context_exitFunction ();
@@ -962,7 +975,8 @@ namedInitializer
 
 typeDecl
  : CTYPEDEF completeTypeSpecifier { setProcessingTypedef ($2); } 
-   NotType namedInitializerList IsType TSEMI { unsetProcessingTypedef (); } 
+   NotType namedInitializerList IsType optWarnClause TSEMI 
+   { clabstract_declareType ($5, $7); }
  | CTYPEDEF completeTypeSpecifier IsType TSEMI { /* in the ANSI grammar, semantics unclear */ }
  | CTYPEDEF namedInitializerList IsType TSEMI { /* in the ANSI grammar, semantics unclear */ } 
 
@@ -973,11 +987,11 @@ PushType
  : { g_expectingTypeName = TRUE; context_pushLoc (); }
 
 namedInitializerList
- :  namedInitializerListAux IsType { ; }
+ :  namedInitializerListAux IsType { $$ = $1; }
 
 namedInitializerListAux
- : namedInitializer { ; }
- | namedInitializerList TCOMMA NotType namedInitializer { ; }
+ : namedInitializer { $$ = exprNodeList_singleton ($1); }
+ | namedInitializerList TCOMMA NotType namedInitializer { $$ = exprNodeList_push ($1, $4); }
 
 optDeclarators
  : /* empty */      { $$ = exprNode_makeError (); }
@@ -1569,7 +1583,6 @@ compoundStmtRest
                                                        lltok_getLoc ($3))); 
    }
 
-
 compoundStmtAux
  : TLBRACE compoundStmtRest 
    { $$ = exprNode_makeBlock ($2); }
@@ -1856,7 +1869,7 @@ void yyerror (/*@unused@*/ char *s)
       llerror (FLG_SYNTAX, message ("Macro syntax not parseable: %s", 
                                    context_inFunctionName ()));
       
-      if (context_inMacroUnknown ())
+      if (context_inUnknownMacro ())
        {
          if (!givehint)
            {
This page took 0.681541 seconds and 4 git commands to generate.