Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some possible bugs after eliminating several warnings #2

Open
mingodad opened this issue Jul 8, 2021 · 3 comments
Open

Some possible bugs after eliminating several warnings #2

mingodad opened this issue Jul 8, 2021 · 3 comments

Comments

@mingodad
Copy link

mingodad commented Jul 8, 2021

Adding "-Wall -Wextra" compiler flags I fixed several warnings and some possible bugs showed up too see bellow:

Possible bugs:

-------------------------- src/Fog/FogLexerInput.cpp --------------------------
index a40dfd6..dcb19d3 100644
@@ -204,7 +204,7 @@ const char *FogLexerInput::get(FogTokenContext& tokenContext)
  }
  for ( ; !p->is_empty(); p->pop())
  {
-  const char *stateName = stateName = p->get(tokenContext);
+  const char *stateName = p->get(tokenContext);
   if (stateName)
   {
    if (tokenContext.token().is_line() && _token.is_null())
@@ -772,7 +772,7 @@ const char *FogLexerInput_Stream::peek(FogTokenRef& tokenValue, size_t nextIndex
  while (nextIndex < _contents.tally())       //   If replaying.
  {
   tokenValue = _contents[nextIndex++];
-  if (!tokenValue->is_skip(skipWhite));   ////!!! here the semicolon probably is a mistake
+  if (!tokenValue->is_skip(skipWhite))
    return "<INPUT_REPEEK>";
  }
  return _lexer.peek(tokenValue, skipWhite);

------------------------- src/Fog/FogMakeSemantics.cpp -------------------------
index 04aea39..8cd0fb0 100644
@@ -217,7 +217,7 @@ bool FogMakeSemantics::make_specifier(FogBaseMakeSpecifierContext& aContext, Fog
             if (scopeSpecifier)
                 return aContext.adopt_specifier(new FogTypeParameterSpecifier(aContext, *scopeSpecifier));
             ERRMSG("BUG -- should have made template-type-parameter from an elaborated-type-specifier");
-            false;   /////!!!!! here it seems that the "return" was forgotten
+            return false;
         }
 //        case MAKE_USING: return new FogUsingSpecifier(aContext, *aName);
         case MAKE_VALUE_PARAMETER:

------------------------- src/Fog/FogUsageManager.cpp -------------------------
index 8961380..6eb97a3 100644
@@ -113,7 +113,7 @@ void FogUsageManager::compile() {
 				while (true) {
 					FogUsage *nextUsage = endUsage->pick_cyclic_use_of(*this);
 					if (nextUsage == endUsage) {
-						int i = 0; /////!!!!! here it seems that the intention is to reset "i" not creating a new one
+						i = 0;
 					}
 					
 					if (!nextUsage)        //   Only occurs if a bug has left endUsage acyclic

---------------------------- src/Fog/FogParser.cpp ----------------------------
index 06ae30c..4a2d2b9 100644
@@ -7413,7 +7413,7 @@ case 768:
 { yyval.declaration = YACC_DERIVED_CLAUSE(yyvsp[-4].expression, yyvsp[-1].subspace); ;
     break;}
 case 769:
-{ yyval.declaration = yyval.declaration = YACC_DERIVED_CLAUSE(yyvsp[-8].expression, yyvsp[-5].subspace); YACC_UNBANG(yyvsp[-2].bang, "Bad object-statement."); ;
+{ yyval.declaration  = YACC_DERIVED_CLAUSE(yyvsp[-8].expression, yyvsp[-5].subspace); YACC_UNBANG(yyvsp[-2].bang, "Bad object-statement."); ;
     break;}
 case 772:
 { yyval.function_body = YACC_CTOR_FUNCTION_BLOCK(0, yyvsp[-1].mem_initializers); ;

----------------------------- src/Fog/FogParser.y -----------------------------
index 5d4d4ae..7a04d82 100644
@@ -1673,7 +1673,7 @@ object_statement:                   ';'
     |                               derived_clause object_statement                             { $$ = YACC_DERIVED_CLAUSE($1, $2); }
     |                               derived_clause ':' '{' object_statement_seq.opt '}'         { $$ = YACC_DERIVED_CLAUSE($1, $4); }
     |                               derived_clause ':' '{' object_statement_seq.opt looping_object_statement '#' bang error '#'
-                                                { $$ = $$ = YACC_DERIVED_CLAUSE($1, $4); YACC_UNBANG($7, "Bad object-statement."); }
+                                                { $$ = YACC_DERIVED_CLAUSE($1, $4); YACC_UNBANG($7, "Bad object-statement."); }
 function_used_block:                function_block
     |                               function_try_block
     |                               ctor_initializer ';'                                        { $$ = YACC_CTOR_FUNCTION_BLOCK(0, $1); }


Full list of fixes:

--------------------------- src/Fog/FogCharacter.cpp ---------------------------
index 823f9fe..1468ed0 100644
@@ -30,9 +30,9 @@ FogCharacter::FogCharacter()
 FogCharacter::FogCharacter(const PrimId& rawId, const PrimId& binId, unsigned long aValue, CharacterType characterType)
 		:
 		_raw_id(rawId),
-		_bin_id(binId),
 		_character_type(characterType),
-		_value(aValue) {}
+		_value(aValue),
+		_bin_id(binId) {}
 		
 FogCharacter::~FogCharacter() {}
 

-------------------------- src/Fog/FogCodeTokens.cpp --------------------------
index 7f712c9..8547f3f 100644
@@ -15,8 +15,8 @@ TMPL_HACK_FIX_DO(FogCodeTokens)
 
 FogCodeTokens::FogCodeTokens()
 :
-    _executable_tokens(0),
-    _source_lines(0)
+    _source_lines(0),
+    _executable_tokens(0)
 {}
 
 
@@ -24,8 +24,8 @@ FogCodeTokens::FogCodeTokens(const This& tokenList)
 :
     Super(tokenList),
     _tokens(tokenList._tokens),
-    _executable_tokens(tokenList._executable_tokens),
-    _source_lines(tokenList._source_lines)
+    _source_lines(tokenList._source_lines),
+    _executable_tokens(tokenList._executable_tokens)
 {}
 
 FogCodeTokens::~FogCodeTokens() {}

-------------------------- src/Fog/FogEmitContext.cpp --------------------------
index ee4083d..bd9d6db 100644
@@ -367,8 +367,8 @@ FogStaticEmitContext::FogStaticEmitContext(FogStream& s, FogToken& aToken, ForUs
 		:
 		_static_token(aToken),
 		_in_scope(IN_ANY_SCOPE),
-		_for_use_as(forUseAs),
 		_s(s),
+		_for_use_as(forUseAs),
 		_separator(0),
 		_terminator(0) {}
 		

--------------------------- src/Fog/FogFunction.cpp ---------------------------
index aca7d72..41347ea 100644
@@ -437,7 +437,7 @@ FogFunction *FogFunction::deduce_specialisation(FogMakeSpecifierContext& makeSpe
             //    Initialise map of parameters to be deduced.
             //  
             FogExprSetOfRef deducedValues;
-            for (int i1 = firstNumber+1; i1 <= lastNumber; i1++)
+            for (size_t i1 = firstNumber+1; i1 <= lastNumber; i1++)
             {
                 const FogTemplateParameterSpecifier& tP = templateParameters.template_parameter_number(i1);
                 const FogName& tPN = tP.name();
@@ -492,7 +492,7 @@ FogFunction *FogFunction::deduce_specialisation(FogMakeSpecifierContext& makeSpe
             if (failedDeductions)
                 return 0;
             FogListOfExprRef exprList(new FogListOfExpr, FogListOfExprRef::ADOPT);
-            for (int i2 = firstNumber+1; i2 <= lastNumber; i2++)
+            for (size_t i2 = firstNumber+1; i2 <= lastNumber; i2++)
             {
                 const FogTemplateParameterSpecifier& tP = templateParameters.template_parameter_number(i2);
                 const FogName& tPN = tP.name();

---------------------------- src/Fog/FogInline.cpp ----------------------------
index 4a7a950..c04960d 100644
@@ -38,7 +38,7 @@ bool FogInline_Flyweights::initialise()
         _flyweights[p->_inline_enum] = flyWeights[p->_inline_enum].pointer();
     }
     _flyweights[FogInline::EXPLICIT_IF_SHORT] = &FogTokenType::get_inline(FogTokenType::INLINE);
-    for (int i = 0; i < (sizeof(_flyweights)/sizeof(_flyweights[0])); i++)
+    for (size_t i = 0; i < (sizeof(_flyweights)/sizeof(_flyweights[0])); i++)
     {
         if (!_flyweights[i])
         {

------------------------ src/Fog/FogIterationDomain.cpp ------------------------
index fa881b3..79ac29a 100644
@@ -16,15 +16,15 @@ TMPL_HACK_FIX_DO(FogIterationDomain)
 FogIterationDomain::FogIterationDomain()
 :
     _meta_type(FogMetaType::void_type()),
-    _executable_tokens(0),
-    _source_lines(0)
+    _source_lines(0),
+    _executable_tokens(0)
 {}
 
 FogIterationDomain::FogIterationDomain(const FogMetaType& metaType)
 :
     _meta_type(metaType),
-    _executable_tokens(0),
-    _source_lines(0)
+    _source_lines(0),
+    _executable_tokens(0)
 {}
 
 FogIterationDomain::FogIterationDomain(const This& tokenList)
@@ -32,8 +32,8 @@ FogIterationDomain::FogIterationDomain(const This& tokenList)
     Super(tokenList),
     _meta_type(tokenList._meta_type),
     _tokens(tokenList._tokens),
-    _executable_tokens(tokenList._executable_tokens),
-    _source_lines(tokenList._source_lines)
+    _source_lines(tokenList._source_lines),
+    _executable_tokens(tokenList._executable_tokens)
 {}
 
 FogIterationDomain::~FogIterationDomain() {}

-------------------------- src/Fog/FogLexerInput.cpp --------------------------
index a40dfd6..dcb19d3 100644
@@ -204,7 +204,7 @@ const char *FogLexerInput::get(FogTokenContext& tokenContext)
  }
  for ( ; !p->is_empty(); p->pop())
  {
-  const char *stateName = stateName = p->get(tokenContext);
+  const char *stateName = p->get(tokenContext);
   if (stateName)
   {
    if (tokenContext.token().is_line() && _token.is_null())
@@ -772,7 +772,7 @@ const char *FogLexerInput_Stream::peek(FogTokenRef& tokenValue, size_t nextIndex
  while (nextIndex < _contents.tally())       //   If replaying.
  {
   tokenValue = _contents[nextIndex++];
-  if (!tokenValue->is_skip(skipWhite));
+  if (!tokenValue->is_skip(skipWhite))
    return "<INPUT_REPEEK>";
  }
  return _lexer.peek(tokenValue, skipWhite);

------------------------- src/Fog/FogMakeSemantics.cpp -------------------------
index 04aea39..8cd0fb0 100644
@@ -217,7 +217,7 @@ bool FogMakeSemantics::make_specifier(FogBaseMakeSpecifierContext& aContext, Fog
             if (scopeSpecifier)
                 return aContext.adopt_specifier(new FogTypeParameterSpecifier(aContext, *scopeSpecifier));
             ERRMSG("BUG -- should have made template-type-parameter from an elaborated-type-specifier");
-            false;
+            return false;
         }
 //        case MAKE_USING: return new FogUsingSpecifier(aContext, *aName);
         case MAKE_VALUE_PARAMETER:

----------------------- src/Fog/FogMetaVariableSlot.cpp -----------------------
index ecdf79e..3c4cb6a 100644
@@ -78,21 +78,21 @@ FogMetaEntity *FogMetaVariableSlot::get_meta_entity(FogScopeContext& inScope) co
     FogMetaEntity *metaEntity = NULL;//found_meta_entities[this];
     
     if (!metaEntity) {
-	    inToken = get_scope_in(inScope);
+	inToken = get_scope_in(inScope);
 		
-		VERBOSE(printf("DEBUG   inToken %x\n", &inToken);)
+	VERBOSE(printf("DEBUG   inToken %x\n", &inToken);)
 	    
-	    if (!inToken)
-	        return 0;
+	if (!inToken)
+	    return 0;
 	    
-		VERBOSE(printf("DEBUG   find entity %s\n", id().str());)
+	VERBOSE(printf("DEBUG   find entity %s\n", id().str());)
 		
-		metaEntity = inToken->find_meta_entity(id());
+	metaEntity = inToken->find_meta_entity(id());
 		
-		VERBOSE(if (metaEntity) {std::strstream str;metaEntity->print_viz(str);printf("DEBUG   found %x %s\n", metaEntity, str.str());})
+	VERBOSE(if (metaEntity) {std::strstream str;metaEntity->print_viz(str);printf("DEBUG   found %x %s\n", metaEntity, str.str());})
     }
     else {
-		VERBOSE(printf("DEBUG   old entity %x\n", metaEntity);)
+	VERBOSE(printf("DEBUG   old entity %x\n", metaEntity);)
     }
     
     

-------------------------- src/Fog/FogMultipleId.cpp --------------------------
index 76dca62..4dd924f 100644
@@ -29,8 +29,8 @@ FogMultipleId::FogMultipleId(const FogElementType& elementType)
 FogMultipleId::FogMultipleId(const This& thatName)
 :
     Super(thatName),
-    _element_type(thatName._element_type),
     _tokens(thatName._tokens),
+    _element_type(thatName._element_type),
     _resolved_id(thatName._resolved_id),
     _resolved(thatName._resolved),
     _resolved_in(thatName._resolved_in),

------------------------- src/Fog/FogParseContext.cpp -------------------------
index 39f8ac4..ee50d23 100644
@@ -102,8 +102,8 @@ FogDeclarationParseContext::FogDeclarationParseContext(FogToken& aToken)
 
 FogDeclarationParseContext::FogDeclarationParseContext(FogToken& aToken, FogScopeContext& _scope_context)
 :
-    _static_token(aToken),
-    FogParseContext(_scope_context)
+    FogParseContext(_scope_context),
+    _static_token(aToken)
 //    _target_file(0)
 {}
 

-------------------------- src/Fog/FogParseContext.h --------------------------
index 2b87fad..005538b 100644
@@ -180,7 +180,7 @@ class FogDecoratedParseContext : public FogParseContext
 private:
     FogParseContext& _parse_context;
 protected:
-    FogDecoratedParseContext(FogParseContext& parseContext) : _parse_context(parseContext), FogParseContext(parseContext) {}
+    FogDecoratedParseContext(FogParseContext& parseContext) : FogParseContext(parseContext), _parse_context(parseContext) {}
     FogParseContext& parse_context() { return _parse_context; }
 public:
     virtual const FogAccess& access() const;

---------------------------- src/Fog/FogParser.cpp ----------------------------
index 06ae30c..4a2d2b9 100644
@@ -7413,7 +7413,7 @@ case 768:
 { yyval.declaration = YACC_DERIVED_CLAUSE(yyvsp[-4].expression, yyvsp[-1].subspace); ;
     break;}
 case 769:
-{ yyval.declaration = yyval.declaration = YACC_DERIVED_CLAUSE(yyvsp[-8].expression, yyvsp[-5].subspace); YACC_UNBANG(yyvsp[-2].bang, "Bad object-statement."); ;
+{ yyval.declaration  = YACC_DERIVED_CLAUSE(yyvsp[-8].expression, yyvsp[-5].subspace); YACC_UNBANG(yyvsp[-2].bang, "Bad object-statement."); ;
     break;}
 case 772:
 { yyval.function_body = YACC_CTOR_FUNCTION_BLOCK(0, yyvsp[-1].mem_initializers); ;

----------------------------- src/Fog/FogParser.y -----------------------------
index 5d4d4ae..7a04d82 100644
@@ -1673,7 +1673,7 @@ object_statement:                   ';'
     |                               derived_clause object_statement                             { $$ = YACC_DERIVED_CLAUSE($1, $2); }
     |                               derived_clause ':' '{' object_statement_seq.opt '}'         { $$ = YACC_DERIVED_CLAUSE($1, $4); }
     |                               derived_clause ':' '{' object_statement_seq.opt looping_object_statement '#' bang error '#'
-                                                { $$ = $$ = YACC_DERIVED_CLAUSE($1, $4); YACC_UNBANG($7, "Bad object-statement."); }
+                                                { $$ = YACC_DERIVED_CLAUSE($1, $4); YACC_UNBANG($7, "Bad object-statement."); }
 function_used_block:                function_block
     |                               function_try_block
     |                               ctor_initializer ';'                                        { $$ = YACC_CTOR_FUNCTION_BLOCK(0, $1); }

----------------------------- src/Fog/FogRoot.cpp -----------------------------
index d7de844..9704960 100644
@@ -26,15 +26,15 @@ TMPL_HACK_FIX_DO(FogRoot)
 FogRoot::FogRoot()
 		:
 		Super(FogTag::namespace_tag(), *this, *PrimIdHandle("$null$")),
-		_reader(*this),
 		_program("?"),
+		_reader(*this),
 		_root_context(*this) {}
 		
 FogRoot::FogRoot(const PrimId& anId)
 		:
 		Super(FogTag::namespace_tag(), *this, *PrimIdHandle(anId ? anId.str() : "<unnamed>")),
-		_reader(*this),
 		_program("?"),
+		_reader(*this),
 		_meta_base(new FogAuto(*this), FogScopeRef::ADOPT),
 		_std(new FogStd(*this), FogScopeRef::ADOPT),
 		_root_context(*this) {

----------------------------- src/Fog/FogScope.cpp -----------------------------
index 47fc871..f47d6da 100644
@@ -68,13 +68,13 @@ FogScope::FogScope(const FogTag& aTag, FogScope& parentScope, const PrimId& anId
 :
     Super(parentScope, anId, anId),
     _nested(&parentScope == this ? 0 : parentScope.nesting_depth()+1),  //   Avoid recursion for global scope.
-    _templates(*this),
     _tag(aTag),
     _braced(false),
     _is_leaf(FogLazyBool::make_undecided()),
     _is_frozen(false),
     _done_meta_construct(false),
-    _inline_usage(0)
+    _inline_usage(0),
+    _templates(*this)
 {}
 
 FogScope::~FogScope() {}

-------------------------- src/Fog/FogScopeContext.h --------------------------
index 6ec447d..704e88c 100644
@@ -142,8 +142,8 @@ private:
 private:
     This& operator=(const This& scopeContext);
 protected:
-    FogDecoratedScopeContext(FogScopeContext& scopeContext) : _context(scopeContext), Super(scopeContext, 123) {}
-    FogDecoratedScopeContext(This& scopeContext) : _context(scopeContext), Super(scopeContext, 123) {}
+    FogDecoratedScopeContext(FogScopeContext& scopeContext) : Super(scopeContext, 123), _context(scopeContext) {}
+    FogDecoratedScopeContext(This& scopeContext) : Super(scopeContext, 123), _context(scopeContext) {}
 public:
     FogScopeContext& scope_context() { return _context; }
     const FogScopeContext& scope_context() const { return _context; }

-------------------------- src/Fog/FogSourceFile.cpp --------------------------
index 5c17b79..ccdf2c1 100644
@@ -14,8 +14,8 @@ TMPL_HACK_FIX_DO(FogSourceFile)
 
 FogSourceFile::FogSourceFile()
 :
- _has_been_read(false),
- _source_type(FogSourceFileType::invalid())
+ _source_type(FogSourceFileType::invalid()),
+ _has_been_read(false)
 {}
 
 FogSourceFile::FogSourceFile(const PrimId& pathedId, const PrimId& fileIdent,
@@ -23,8 +23,8 @@ FogSourceFile::FogSourceFile(const PrimId& pathedId, const PrimId& fileIdent,
 :
  _pathed_id(pathedId),
  _short_id(fileIdent),
- _has_been_read(false),
- _source_type(sourceType)
+ _source_type(sourceType),
+ _has_been_read(false)
 {}
 
 //  const FogMetaType *FogSourceFile::meta_type() const { return &FogMetaType::source_file_type(); }

---------------------------- src/Fog/FogString.cpp ----------------------------
index d786882..aeeccf1 100644
@@ -30,8 +30,8 @@ FogString::FogString()
 FogString::FogString(const PrimId& rawId, const PrimId& binId, StringType stringType)
 :
  _raw_id(rawId),
- _bin_id(binId),
- _string_type(stringType)
+ _string_type(stringType),
+ _bin_id(binId)
 {}
 
 FogString::~FogString() {}

----------------------- src/Fog/FogSubstituteParser.cpp -----------------------
index 26934b8..df84383 100644
@@ -2043,7 +2043,7 @@ void FogSubstituteParser::substitute_hash_id(FogKeyword *anId)
 	const FogTokenListOfRef& theTokens = replacementMacro.tokens();
 	bool gotWhite = false;				// Flag compressing multi-white, stripping trailing white.
 	bool gotNonWhite = false;			// Flag stripping leading white.
-	for (int i = 0; i < theTokens.tally(); ++i)
+	for (size_t i = 0; i < theTokens.tally(); ++i)
 	{
 		const FogToken& theToken = *theTokens[i];
 		if (theToken.is_white())

-------------------------- src/Fog/FogTargetFile.cpp --------------------------
index 488b989..5f56c60 100644
@@ -32,9 +32,9 @@ TMPL_HACK_FIX_DO(FogTargetFile)
 FogTargetFile::FogTargetFile()
 		:
 		_source_file(0),
-		_is_input(false),
 		_explicit_guard(false),
 		_is_interface(false),
+		_is_input(false),
 		_file_number(0),
 		_min_usage_number(0),
 		_max_usage_number(0),
@@ -45,10 +45,10 @@ FogTargetFile::FogTargetFile(const FogSourceFile& sourceFile)
 		_pathed_id(sourceFile.unique_id()),
 		_short_id(sourceFile.short_id()),
 		_source_file(&sourceFile),
-		_is_input(false),
 		_utility(FogUtility::pool_utility()),
 		_explicit_guard(false),
 		_is_interface(false),
+		_is_input(false),
 		_file_number(0),
 		_min_usage_number(0),
 		_max_usage_number(0),
@@ -62,10 +62,10 @@ FogTargetFile::FogTargetFile(const PrimId& pathedId, const PrimId& fileIdent)
 		_pathed_id(pathedId),
 		_short_id(fileIdent),
 		_source_file(0),
-		_is_input(false),
 		_utility(FogUtility::pool_utility()),
 		_explicit_guard(false),
 		_is_interface(false),
+		_is_input(false),
 		_file_number(0),
 		_min_usage_number(0),
 		_max_usage_number(0),

------------------------ src/Fog/FogTemplateManager.cpp ------------------------
index 296e41c..c9eebe0 100644
@@ -18,14 +18,14 @@ TYPEINFO_SINGLE(FogTemplateManager, Super)
 
 FogTemplateManager::FogTemplateManager(FogEntity& primaryEntity)
 :
-    _classification(NON_TEMPLATE),
-    _primary(primaryEntity)
+    _primary(primaryEntity),
+    _classification(NON_TEMPLATE)
 {}
 
 FogTemplateManager::FogTemplateManager(FogEntity& primaryEntity, FogMakerContext& makerContext)
 :
-    _classification(classify_primary(makerContext)),
     _primary(primaryEntity),
+    _classification(classify_primary(makerContext)),
     _parameter_specifiers(is_templated() ? makerContext.template_parameters() : 0)
 {
 //    install_parameters(makerContext); -- must be in caller to ensure that parent has become at least a FogScope
@@ -34,8 +34,8 @@ FogTemplateManager::FogTemplateManager(FogEntity& primaryEntity, FogMakerContext
 
 FogTemplateManager::FogTemplateManager(FogMakeTemplateContext& makeTemplateContext)
 :
-    _classification(classify_secondary(makeTemplateContext)),
     _primary(makeTemplateContext.primary()),
+    _classification(classify_secondary(makeTemplateContext)),
     _arguments(makeTemplateContext.template_args()),
     _parameter_specifiers(makeTemplateContext.template_parameters())
 {

----------------------------- src/Fog/FogUsage.cpp -----------------------------
index 6517fe6..0f36367 100644
@@ -249,9 +249,9 @@ TMPL_HACK_FIX_DO(FogUsage)
 FogUsage::FogUsage()
 :
 //	_entity(FogEntity::mutable_null()),
-	_entity(0),
 //	_type(NAME),
 	_type(INVALID),
+	_entity(0),
 	_file(0),
 	_usage_number(0)
 {}

------------------------- src/Fog/FogUsageManager.cpp -------------------------
index 8961380..6eb97a3 100644
@@ -113,7 +113,7 @@ void FogUsageManager::compile() {
 				while (true) {
 					FogUsage *nextUsage = endUsage->pick_cyclic_use_of(*this);
 					if (nextUsage == endUsage) {
-						int i = 0;
+						i = 0;
 					}
 					
 					if (!nextUsage)        //   Only occurs if a bug has left endUsage acyclic

------------------------------- src/Prim/Prim.h -------------------------------
index f9a1d08..33324f3 100644
@@ -320,12 +320,14 @@ PRIM_AND_SHARED_MAP(T)
 
 #define PRIM_THAT_AND_LIST(T) PRIM_AND_LIST(T)
 #define PRIM_THAT_AND_1LIST(T) PRIM_AND_1LIST(T)
+/*
 // typedef PrimSinglyLinkedListOfRefToConst<name2(T,That)> name2(T,1ListOfRefToConst); \
 // typedef PrimSinglyLinkedListOfRef<name2(T,That)> name2(T,1ListOfRef); \
 // typedef PrimSinglyLinkedListOfRefToConstIterator<name2(T,That)> name2(T,1ListOfRefToConstIterator); \
 // typedef PrimSinglyLinkedListOfRefIterator<name2(T,That)> name2(T,1ListOfRefIterator); \
 // typedef PrimConstSinglyLinkedListOfRefToConstIterator<name2(T,That)> name2(T,Const1ListOfRefToConstIterator); \
 // typedef PrimConstSinglyLinkedListOfRefIterator<name2(T,That)> name2(T,1LinkedListOfRefIterator);
+*/
 #define PRIM_THAT_AND_MAP(T) PRIM_AND_MAP(T)
 #define PRIM_THAT_AND_REF(T) PRIM_AND_REF(T)
 #define PRIM_THAT_WITH_REF(T) PRIM_WITH_REF(T)

----------------------------- src/Prim/PrimBits.h -----------------------------
index c87e3ca..00e4d44 100644
@@ -4,7 +4,7 @@
 
 
 
-
+/*
 //  
 //  \		PrimBit_TN defines bit N in an unsigned T.
 //  \		PrimSignedBits_MTN defines a M bit field with least significant bit N in a signed T.
@@ -52,7 +52,8 @@
 //  		All standard one bit fields are predeclared. Multiple bit fields must be explicitly declared.
 //  
 //  		When templates are available the () can be replaced by <>, and the declarations removed.
-//  
+//
+*/
 #define PrimBit(T,aBit) name3(PrimBit_,T,aBit)
 #define PrimBitdeclare(T,N)                  \
 class PrimBit(T,N)                    \

---------------------------- src/Prim/PrimBufRep.h ----------------------------
index f1e7deb..2fcdf97 100644
@@ -55,7 +55,7 @@ public:
 //  
 //  	Create a default string representation which is the null buffer representation.
 //  
- PrimBufRep() : _bytes(_null_buf), _share_count(0), _size(0) {}
+ PrimBufRep() : _bytes(_null_buf), _size(0), _share_count(0) {}
  ~PrimBufRep(); 
 };
 #endif

--------------------------- src/Prim/PrimComToken.h ---------------------------
index d05e877..741ea82 100644
@@ -102,9 +102,11 @@ public:
 /*   Inclusion of PrimComToken used to include everything, so if this include file
  * is the first of the family to be included, the old policy is presumably assumed
  * so include the lot. Just to make the tests harder PrimComToken_Enum was separate. */
+/*
 //  #if !defined(PRIMCOMPARSE_HXX) && (!defined(PRIMCOMTOKENSTR_HXX) || defined(PRIMCOMTOKEN_ENUM_HXX)) \
 //  	&& !defined(PRIMCOMTOKENSTRS_HXX) && !defined(PRIMCOMTOKEN_BOOL_HXX) && !defined(PRIMCOMTOKEN_DOUBLE_HXX) \
 //  	&& !defined(PRIMCOMTOKEN_INT_HXX) && !defined(PRIMCOMTOKEN_LONG_HXX)
 //  #include <PrimComs.h>
+*/
 #endif
  

-------------------------- src/Prim/PrimComTokenStr.h --------------------------
index 357b4e1..5fc30c9 100644
@@ -31,7 +31,7 @@ protected:
 //  
  PrimComTokenStr(PrimComParse& aParser, const char *aName, const char *aUsage,
   const TokenOptions& someOptions, PrimStringHandle& theValue, const PrimString& defaultValue)
-  : Super(aParser, aName, aUsage, someOptions), _value(theValue), _default_value(defaultValue) {}
+  : Super(aParser, aName, aUsage, someOptions), _default_value(defaultValue), _value(theValue) {}
  virtual ~PrimComTokenStr();
  virtual void initialise_parse(PrimComParse& aParser);
  virtual const char *parse_text(PrimComParse& aParser, const char *someText);

------------------------ src/Prim/PrimComToken_Bool.cpp ------------------------
index 5a7f072..3c91986 100644
@@ -16,8 +16,8 @@ PrimComToken_Bool::PrimComToken_Bool(PrimComParse& aParser, bool &theValue, cons
  const char *aUsage, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
- _default_value(false)
+ _default_value(false),
+ _value(theValue)
 {}
 
 //  
@@ -28,8 +28,8 @@ PrimComToken_Bool::PrimComToken_Bool(PrimComParse& aParser, bool &theValue, cons
  const char *aUsage, const bool& defaultValue, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
- _default_value(defaultValue)
+ _default_value(defaultValue),
+ _value(theValue)
 {}
 
 //  

----------------------- src/Prim/PrimComToken_Double.cpp -----------------------
index 683bb80..c0a7a9e 100644
@@ -16,8 +16,8 @@ PrimComToken_Double::PrimComToken_Double(PrimComParse& aParser, double &theValue
  const char *aUsage, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
- _default_value(0.0)
+ _default_value(0.0),
+ _value(theValue)
 {}
 
 //  
@@ -28,8 +28,8 @@ PrimComToken_Double::PrimComToken_Double(PrimComParse& aParser, double &theValue
  const char *aUsage, double defaultValue, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
- _default_value(defaultValue)
+ _default_value(defaultValue),
+ _value(theValue)
 {}
 
 //  

------------------------ src/Prim/PrimComToken_Int.cpp ------------------------
index efd3134..6733b81 100644
@@ -17,8 +17,8 @@ PrimComToken_Int::PrimComToken_Int(PrimComParse& aParser, int &theValue, const c
  const char *aUsage, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
  _default_value(0),
+ _value(theValue),
  _number_base(default_number_base())
 {}
 
@@ -32,8 +32,8 @@ PrimComToken_Int::PrimComToken_Int(PrimComParse& aParser, int &theValue, const c
  const char *aUsage, int defaultValue, const int& numberBase, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
  _default_value(defaultValue),
+ _value(theValue),
  _number_base(numberBase)
 {}
 

------------------------ src/Prim/PrimComToken_Long.cpp ------------------------
index 60c14fb..dabe40e 100644
@@ -17,8 +17,8 @@ PrimComToken_Long::PrimComToken_Long(PrimComParse& aParser, long &theValue, cons
  const char *aUsage, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
  _default_value(0),
+ _value(theValue),
  _number_base(default_number_base())
 {}
 
@@ -32,8 +32,8 @@ PrimComToken_Long::PrimComToken_Long(PrimComParse& aParser, long &theValue, cons
  const char *aUsage, long defaultValue, const int& numberBase, const TokenOptions& someOptions)
 :
  Super(aParser, aName, aUsage, someOptions),
- _value(theValue),
  _default_value(defaultValue),
+ _value(theValue),
  _number_base(numberBase)
 {}
 

-------------------------- src/Prim/PrimListOfRef.cpp --------------------------
index 315f2b4..7c77b2c 100644
@@ -153,9 +153,9 @@ void PrimListOfRefImp::clone(const PrimRefFuncs& supportFunctions, const PrimLis
 //  
 //  	Return a non-null pointer if anElement is non-null and matches one of the list pointers.
 //  
-const PrimRefValue *PrimListOfRefImp::find(const PrimRefFuncs& supportFunctions, const PrimRefValue& anElement) const
+const PrimRefValue *PrimListOfRefImp::find(const PrimRefFuncs& /*supportFunctions*/, const PrimRefValue& anElement) const
 {
- UNUSED(&supportFunctions);
+ /*UNUSED(&supportFunctions);*/
  const PrimRefBase *p = contents();
  for (size_t i = tally(); i-- > 0; p++)
   if (*p == anElement)
@@ -252,9 +252,9 @@ std::ostream& PrimListOfRefImp::print_on(const PrimRefFuncs& supportFunctions, s
 //  
 //  	Display the list dimensions as part of an inline diagnostic.
 //  
-std::ostream& PrimListOfRefImp::print_this(const PrimRefFuncs& supportFunctions, std::ostream& s) const
+std::ostream& PrimListOfRefImp::print_this(const PrimRefFuncs& /*supportFunctions*/, std::ostream& s) const
 {
- UNUSED(&supportFunctions);
+ /*UNUSED(&supportFunctions);*/
  return (s << tally() << '/' << capacity());
 }
 

-------------------------- src/Prim/PrimMapOfRef.cpp --------------------------
index 31698eb..4769277 100644
@@ -540,9 +540,9 @@ std::ostream& PrimMapOfRefImp::print_on(const PrimMapOfRefFuncs& supportFunction
 //  
 //  	Provide the dimensions as part of a brief diagnostic.
 //  
-std::ostream& PrimMapOfRefImp::print_this(const PrimMapOfRefFuncs& supportFunctions, std::ostream& s) const
+std::ostream& PrimMapOfRefImp::print_this(const PrimMapOfRefFuncs& /*supportFunctions*/, std::ostream& s) const
 {
- UNUSED(&supportFunctions);
+ /*UNUSED(&supportFunctions);*/
  s << _tally << '/' << _capacity;
  return s;
 }

--------------------------- src/Prim/PrimNotice.cpp ---------------------------
index 6e26fe1..2d9fa9c 100644
@@ -29,9 +29,9 @@ bool PrimNotice::not_posted() const
 //  	can respond to the message using the run-time type information mechanism and then use a message
 //  	specific method to post the notice.
 //  
-bool PrimNotice::posted_on(PrimNotifier& aNoticeBoard) const
+bool PrimNotice::posted_on(PrimNotifier& /*aNoticeBoard*/) const
 {
- UNUSED(&aNoticeBoard);
+ /*UNUSED(&aNoticeBoard);*/
  return not_posted();
 }
 

---------------------------- src/Prim/PrimNotice.h ----------------------------
index ea4133d..c00482f 100644
@@ -39,7 +39,7 @@ public:
 //  		augmenting with their own field comparisons. However this proved to be stupid for the test
 //  		suite which multiply inherited the notice and so had an inconsistent type for it.
 //  
- bool compare(const PrimNotice& aNotice) const { UNUSED(&aNotice); return (true); }
+ bool compare(const PrimNotice& /*aNotice*/) const { /*UNUSED(&aNotice);*/ return (true); }
  virtual bool not_posted() const;
 //  
 //  		Report the notifier that posted this notice. The return may be 0 if unknown.

-------------------- src/Prim/PrimSinglyLinkedListOfRef.cpp --------------------
index 28848f5..bc6e566 100644
@@ -179,10 +179,10 @@ PrimSinglyLinkedListOfRefElement **PrimSinglyLinkedListOfRefImp::find(const Prim
 //  
 //  	Return a non-null pointer if anElement is non-null and matches one of the list pointers.
 //  
-const PrimRefValue *PrimSinglyLinkedListOfRefImp::find(const PrimRefFuncs& supportFunctions,
+const PrimRefValue *PrimSinglyLinkedListOfRefImp::find(const PrimRefFuncs& /*supportFunctions*/,
   const PrimRefValue& anElement) const
 {
- UNUSED(&supportFunctions);
+ /*UNUSED(&supportFunctions);*/
  return find(anElement) ? &anElement : 0;
 }
 
@@ -298,10 +298,10 @@ std::ostream& PrimSinglyLinkedListOfRefImp::print_on(const PrimRefFuncs& support
 //  
 //  	Display the list dimensions as part of an inline diagnostic.
 //  
-std::ostream& PrimSinglyLinkedListOfRefImp::print_this(const PrimRefFuncs& supportFunctions,
+std::ostream& PrimSinglyLinkedListOfRefImp::print_this(const PrimRefFuncs& /*supportFunctions*/,
   std::ostream& s) const
 {
- UNUSED(&supportFunctions);
+ /*UNUSED(&supportFunctions);*/
  return s << tally();
 }
@mingodad
Copy link
Author

mingodad commented Jul 8, 2021

Using the test script from the original distribution I'm getting:

FAILED 23 out of 35 tests.
PASSED 12 out of 35 tests.

test.pl

#
#	Test script for FOG
#
#	Prerequisite:	TestFog	is executable to test
#		so on Unix do something like
#				ln -s sun4o_g/fog TestFog
#		and on NT create TestFog.bat containing
#				Debug/Fog $*
#
#	Invoke as:
#
#	perl test.pl <test-directory>*
#		requiring the TestFog prerequisite or as e.g.
#	perl test.pl executable="\"Debug/fog.exe\"" <test-directory>*
#		to use a specific executable for the tests
#
#	where each test directory comprises
#		'test-directory'/'test-directory'.fog
#		optional include files
#		'test-directory'/references/'reference result files'
#
#	running test creates
#		'test-directory'/results/'actual result files'
#
#	Thus to run the full set (wildcard only works on Unix)
#		perl test.pl tests/*
#	Thus to run some tests (NT or Unix)
#		perl test.pl tests/ansi_c tests/lexical
#
#	Warning: The stream synchronisation on NT is abysmal so diagnostics resulting
#	from invocation of FOG may appear extraordinarily early wrt other activities.
#
#print "executable = $executable\n";
eval "\$$1=\$2" while $ARGV[0] =~ /^(\w+)=(.*)/ && shift;		# Nutshell perl p256
#print "executable = $executable\n";
$executable = "\"./TestFog\"" unless $executable ne "";
#print "executable = $executable\n";
$ENV{'TESTNAME'} = "willink";									# Used by getenv.fog
$failures = 0;
$passes = 0;
$tests = 0;
for (@ARGV)
{
#	print "$_\n";
	next if $_ eq '.';
	next if $_ eq '..';
	next unless -d 'tests/'.$_;
	$error_count = 0;
	$tests++;
	local($tst) = $_;
	local($dir) = 'tests/'.$tst;
	mkdir($dir .'/references', ~umask) unless -e $dir .'/references';
	if (-e $dir .'/results')
	{
		opendir(DIR,$dir .'/results') || die "Can't open $dir/results";
		local($unlinks) = "$dir/results/" . join(" $dir/results/", grep(!/^\.\.?$/, readdir(DIR)));
		local(@unlinks) = split(/ /,$unlinks);
#		print "unlink @unlinks\n";
		unlink @unlinks;
		closedir(DIR);
	}
	else
	{
		mkdir($dir .'/results', ~umask) unless -e $dir .'/results';
	}
	opendir(DIR, $dir) || die "Can't open $dir";
	local(@commandline) = "$executable -q -zd -t4 -cd $dir/results -hd $dir/results $dir/" .
							join(' $dir/',grep(/\.fog$/, readdir(DIR))) .
					" -nc -nobanner -i$dir -global global -DMACRO=aMacro -log $dir/results/log.log";
	closedir(DIR);
	print "@commandline\n";
	system "@commandline\n";
	if (-e $dir . '/results/log.log')
	{
		opendir(DIR,$dir .'/results') || die "Can't open $dir/results";
		local(@resultnames) = grep(!/^\.\.?$/, readdir(DIR));
		closedir(DIR);
		for (@resultnames)
		{
#			print "result $_\n";
			if (!-e $dir .'/references/' . 	$_)
			{
				print "ERROR missing result need to cp $dir/results/$_ $dir/references/$_.\n";
				$error_count++;
			}
			else
			{
				local(@commandline) = "diff -b $dir/references/$_ $dir/results/$_ > $dir/results/$_.diff";
#				print "@commandline\n";
				$diff_status = (system "@commandline\n") / 256;
#				print "$diff_status\n";
				if ($diff_status)
				{
					print "ERROR need to verify and then cp $dir/results/$_ $dir/references/$_.\n";
					open(DIFFS, $dir . '/results/' . $_ . '.diff') || warn "Can't open $dir/results/$_.diff\n";
					while (<DIFFS>)
					{
						print;
					}
					$error_count++;
				}
#				print "diff $dir/results/$_ $dir/references/$_.\n";
#				open(RESULT, $dir . '/results/' . $_) || warn "Can't open $dir/results/$_.\n";
#				open(REFERENCE, $dir . '/references/' . $_) || warn "Can't open $dir/references/$_.\n";
#				$break = 0;
#				while (!eof(RESULT) && !eof(REFERENCE) && !$break)
#				{
#					@reswords = split(/\W*\s+\W*/, <RESULT>);
#					@refwords = split(/\W*\s+\W*/, <REFERENCE>);
#					if (join(" ", @refwords) ne join(" ", @reswords))
#					{
#						print "Files differ.\n";
#						print "    Reference: " , join(" ", @refwords), "\n";
#						print "    Result:    " , join(" ", @reswords), "\n";
#						$break++;
#					}
#				}
#				if (!eof(RESULT) || !eof(REFERENCE) || $break)
#				{
#					print "ERROR need to verify and then cp $dir/results/$_ $dir/references/$_.\n";
#					$error_count++;
#				}
#				close RESULT;
#				close REFERENCE;
			}
		}
	}
	else
	{
		print "ERROR fog failed to execute.\n";
		$error_count++;
	}
	if (-e $dir . '/references/log.log')
	{
		opendir(DIR,$dir .'/references') || die "Can't open $dir/references";
		local(@referencenames) = readdir(DIR);
		closedir(DIR);
		for (@referencenames)
		{
			next if $_ eq '.';
			next if $_ eq '..';
			next if $_ eq "Debug";						# Ignore bogus Debug directory
			next if $_ eq "Release";					# Ignore bogus Release directory
			next if $_ eq "vssver.scc";					# Ignore Visual SourceSafe control files
			if (!-e $dir .'/results/' . 	$_)
			{
				print "ERROR $dir/results/$_ not generated to correspond to $dir/references/$_.\n";
				$error_count++;
			}
		}
	}
	if ($error_count > 0)
	{
		print "FAILED $dir with $error_count errors ---------------------------------------------------.\n";
		$failures++;
	}
	else
	{
		print "PASSED $dir ---------------------------------------------------.\n";
		$passes++;
	}
}
if ($failures > 0)
{
	print "FAILED $failures out of $tests tests.\n";
}
if ($passes > 0)
{
	print "PASSED $passes out of $tests tests.\n";
}

Executing tests from the root folder:

perl test.pl executable="$PWD/fog-nb/dist/Debug/GNU-Linux/fog-nb" \
    13_5 \
    auto_statements \
    cxx \
    FactoryMethod \
    iterator \
    monitor \
    SynchronisedEnum \
    ambig \
    bugs \
    defined \
    getenv \
    lexical \
    multi_dollar \
    templates \
    anons \
    burg \
    derived \
    if \
    marshal \
    multiples \
    template_type \
    ansi_c \
    conversions \
    dollars \
    if_math \
    meta_position \
    Observer \
    utility \
    arithmetic \
    cpp \
    error \
    includes \
    misparse \
    strings \
    Visitor
...
FAILED 23 out of 35 tests.
PASSED 12 out of 35 tests.

@SeppoPakonen
Copy link
Collaborator

"-Wall -Wextra" certainly gives a lot of warnings, because the original code is written for the c++98 standard, if even for it. These changes are welcome.

The changes that appear in the diffs look good. However, I was not able to patch them automatically with any command. Could you submit your changes with a pull request or submit a new patch that works with the patch or git apply command?

That test script needs to be re-enabled in this project. Those failed tests are a serious problem. I will look at this once these changes have been added.

@mingodad
Copy link
Author

Here is the output of git diff.
dad-changes.diff.zip

SeppoPakonen added a commit that referenced this issue Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants