# include "lclintMacros.nf"
# include "basic.h"
# include "cscanner.h"
-# include "mtincludes.h"
# include "cgrammar.h"
# include "exprChecks.h"
/*@only@*/ uentry oentry;
/*@only@*/ exprNode expr;
/*@only@*/ enumNameList enumnamelist;
- /*@only@*/ exprNodeList alist;
+ /*@only@*/ exprNodeList exprlist;
/*@only@*/ sRefSet srset;
/*@only@*/ cstringList cstringlist;
%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
%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
| externalDefs
externalDefs
- : externalDef
- | externalDefs externalDef
+ : externalDef { context_checkGlobalScope (); }
+ | externalDefs externalDef { context_checkGlobalScope (); }
externalDef
: fcnDef optSemi { uentry_clearDecl (); }
| 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); }
$$ = idDecl_replaceCtype ($1, ct);
idDecl_addClauses ($$, $6);
- context_popLoc ();
+ context_popLoc ();
+ /*drl 7/25/01 added*/
+ setImplictfcnConstraints();
}
| namedDeclBase PushType TLPAREN genericParamList TRPAREN
{ setCurrentParams ($4); }
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); }
$$ = 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
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); }
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 ();
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 */ }
: { 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 (); }
| QNOTNULL { $$ = qual_createNotNull (); }
| QEXPOSED { $$ = qual_createExposed (); }
| QOBSERVER { $$ = qual_createObserver (); }
+ | QNULLTERMINATED { $$ = qual_createNullTerminated (); }
| CANNOTATION { $$ = qual_createMetaState ($1); }
+
paramQualifier
: QRETURNED { $$ = qual_createReturned (); }
| QSEF { $$ = qual_createSef (); }
lltok_getLoc ($3)));
}
-
compoundStmtAux
: TLBRACE compoundStmtRest
{ $$ = exprNode_makeBlock ($2); }
llerror (FLG_SYNTAX, message ("Macro syntax not parseable: %s",
context_inFunctionName ()));
- if (context_inMacroUnknown ())
+ if (context_inUnknownMacro ())
{
if (!givehint)
{