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

[WIP] Warnings #480

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -806,24 +806,14 @@ DEBUGTOOL_LIBS=
# -------------------------------------
AC_DEFUN([AX_HANDLE_EXTRA_WARNING],
[if test "x$enable_extra_warning" != xyes; then
# Too many misleading indentation in the FORM source code.
AX_CHECK_COMPILE_FLAG([-Wno-misleading-indentation],
[$1="$$1 -Wno-misleading-indentation"],
[],
[-Werror])
# Too many false positives.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow],
[$1="$$1 -Wno-stringop-overflow"],
[],
[-Werror])
# Currently no warnings are disabled without --enable-extra-warning
$1
fi[]dnl
])

my_test_COMPILEFLAGS=${COMPILEFLAGS+set}
if test "$my_test_COMPILEFLAGS" != set; then
if test "x$vendor" = xgnu; then
# We don't use -pedantic option because of horrible warnings.
COMPILEFLAGS="-Wall -Wextra"
AX_HANDLE_EXTRA_WARNING([COMPILEFLAGS])
# Enable optimizations.
Expand Down
2 changes: 1 addition & 1 deletion sources/comexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ IllLeft:MesPrint("&Illegal LHS");
AN.RepPoint = AT.RepCount + 1;
ow = (WORD *)(((UBYTE *)(AT.WorkPointer)) + AM.MaxTer);
mm = s; ww = ow; i = *mm;
while ( --i >= 0 ) *ww++ = *mm++; AT.WorkPointer = ww;
while ( --i >= 0 ) {*ww++ = *mm++;} AT.WorkPointer = ww;
AC.lhdollarflag = 0; oldEside = AR.Eside; AR.Eside = LHSIDE;
AR.Cnumlhs = C->numlhs;
AR.PolyFun = 0;
Expand Down
47 changes: 24 additions & 23 deletions sources/declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,47 +67,48 @@
#define ParseSignedNumber(x,s) { int sgn; ParseSign(sgn,s)\
ParseNumber(x,s) if ( sgn ) x = -x; }

#define NCOPY(s,t,n) while ( --n >= 0 ) *s++ = *t++;
/* (n) is necessary here, since the macro is sometimes passed dereferenced pointers for n */
#define NCOPY(s,t,n) { while ( (n)-- > 0 ) { *s++ = *t++; } }

/*#define NCOPY(s,t,n) { memcpy(s,t,n*sizeof(WORD)); s+=n; t+=n; n = -1; }*/
#define NCOPYI(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define NCOPYB(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define NCOPYI32(s,t,n) while ( --n >= 0 ) *s++ = *t++;
#define WCOPY(s,t,n) { int nn=n; WORD *ss=(WORD *)s, *tt=(WORD *)t; while ( --nn >= 0 ) *ss++=*tt++; }
#define NeedNumber(x,s,err) { int sgn = 1; \
while ( *s == ' ' || *s == '\t' || *s == '-' || *s == '+' ) { \
if ( *s == '-' ) sgn = -sgn; s++; } \
if ( chartype[*s] != 1 ) goto err; \
ParseNumber(x,s) \
if ( sgn < 0 ) (x) = -(x); while ( *s == ' ' || *s == '\t' ) s++;\
while ( *s == ' ' || *s == '\t' || *s == '-' || *s == '+' ) { \
if ( *s == '-' ) {sgn = -sgn;} s++; } \
if ( chartype[*s] != 1 ) goto err; \
ParseNumber(x,s) \
if ( sgn < 0 ) {(x) = -(x);} while ( *s == ' ' || *s == '\t' ) s++;\
}
#define SKIPBLANKS(s) { while ( *(s) == ' ' || *(s) == '\t' ) (s)++; }
#define FLUSHCONSOLE if ( AP.InOutBuf > 0 ) CharOut(LINEFEED)

#define SKIPBRA1(s) { int lev1=0; s++; while(*s) { if(*s=='[')lev1++; \
else if(*s==']'&&--lev1<0)break; s++;} }
#define SKIPBRA2(s) { int lev2=0; s++; while(*s) { if(*s=='{')lev2++; \
else if(*s=='}'&&--lev2<0)break; \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA3(s) { int lev3=0; s++; while(*s) { if(*s=='(')lev3++; \
else if(*s==')'&&--lev3<0)break; \
else if(*s=='{')SKIPBRA2(s) \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA4(s) { int lev4=0; s++; while(*s) { if(*s=='(')lev4++; \
else if(*s==')'&&--lev4<0)break; \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA5(s) { int lev5=0; s++; while(*s) { if(*s=='{')lev5++; \
else if(*s=='}'&&--lev5<0)break; \
else if(*s=='(')SKIPBRA4(s) \
else if(*s=='[')SKIPBRA1(s) s++;} }
#define SKIPBRA1(s) { int lev1=0; s++; while(*s) { if(*s=='['){lev1++;} \
else {if(*s==']'&&--lev1<0){break;}} s++;} }
#define SKIPBRA2(s) { int lev2=0; s++; while(*s) { if(*s=='{'){lev2++;} \
else {if(*s=='}'&&--lev2<0){break;} \
else {if(*s=='['){SKIPBRA1(s)}}} s++;} }
#define SKIPBRA3(s) { int lev3=0; s++; while(*s) { if(*s=='('){lev3++;} \
else {if(*s==')'&&--lev3<0){break;} \
else {if(*s=='{'){SKIPBRA2(s)} \
else {if(*s=='['){SKIPBRA1(s)}}}} s++;} }
#define SKIPBRA4(s) { int lev4=0; s++; while(*s) { if(*s=='('){lev4++;} \
else {if(*s==')'&&--lev4<0){break;} \
else {if(*s=='['){SKIPBRA1(s)}}} s++;} }
#define SKIPBRA5(s) { int lev5=0; s++; while(*s) { if(*s=='{'){lev5++;} \
else {if(*s=='}'&&--lev5<0){break;} \
else {if(*s=='('){SKIPBRA4(s)} \
else {if(*s=='['){SKIPBRA1(s)}}}} s++;} }

/*
#define CYCLE1(a,i) {WORD iX,jX; iX=*a; for(jX=1;jX<i;jX++)a[jX-1]=a[jX]; a[i-1]=iX;}
*/
#define CYCLE1(t,a,i) {t iX=*a; WORD jX; for(jX=1;jX<i;jX++)a[jX-1]=a[jX]; a[i-1]=iX;}

#define AddToCB(c,wx) if(c->Pointer>=c->Top) \
DoubleCbuffer(c-cbuf,c->Pointer,21); \
{DoubleCbuffer(c-cbuf,c->Pointer,21);} \
*(c->Pointer)++ = wx;

#define EXCHINOUT { FILEHANDLE *ffFi = AR.outfile; \
Expand Down
2 changes: 1 addition & 1 deletion sources/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ IllLeft:MesPrint("&Illegal LHS in dictionary");
AN.RepPoint = AT.RepCount + 1;
ow = (WORD *)(((UBYTE *)(AT.WorkPointer)) + AM.MaxTer);
mm = s; ww = ow; i = *mm;
while ( --i >= 0 ) *ww++ = *mm++; AT.WorkPointer = ww;
while ( --i >= 0 ) {*ww++ = *mm++;} AT.WorkPointer = ww;
AC.lhdollarflag = 0; oldEside = AR.Eside; AR.Eside = LHSIDE;
AR.Cnumlhs = C->numlhs;
if ( Generator(BHEAD ow,C->numlhs) ) {
Expand Down
23 changes: 7 additions & 16 deletions sources/form3.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@

/* Workaround for MSVC. */
#if defined(_MSC_VER)
/*
* Recent versions of MSVC++ (>= 2012) don't like reserved keywords being
* macroized even when they are not available. This is problematic for
* `alignof`, which is used in legacy `PADXXX` macros. We disable tests in
* xkeycheck.h.
*/
#if _MSC_VER >= 1700
#define _ALLOW_KEYWORD_MACROS
#endif
/*
* Old versions of MSVC didn't support C99 function `snprintf`, which is used
* in poly.cc. On the other hand, macroizing `snprintf` gives a fatal error
Expand Down Expand Up @@ -330,20 +321,20 @@ typedef char BOOL;
#define MAXPOSITIVE4 (MAXPOSITIVE / 4) /* 0x00001FFFL */

/*
* alignof(type) returns the number of bytes used in the alignment of
* form_alignof(type) returns the number of bytes used in the alignment of
* the type.
*/
#if !defined(alignof)
#if !defined(form_alignof)
#if defined(__GNUC__)
/* GNU C compiler has "__alignof__". */
#define alignof(type) __alignof__(type)
#define form_alignof(type) __alignof__(type)
#elif defined(_MSC_VER)
/* Microsoft C compiler has "__alignof". */
#define alignof(type) __alignof(type)
#define form_alignof(type) __alignof(type)
#elif !defined(__cplusplus)
/* Generic case in C. */
#include <stddef.h>
#define alignof(type) offsetof(struct { char c_; type x_; }, x_)
#define form_alignof(type) offsetof(struct { char c_; type x_; }, x_)
#else
/* Generic case in C++, at least works with a POD struct. */
#include <cstddef>
Expand All @@ -353,7 +344,7 @@ template<typename T> struct calc {
enum { value = offsetof(X, x_) };
};
}
#define alignof(type) alignof_impl_::calc<type>::value
#define form_alignof(type) alignof_impl_::calc<type>::value
#endif
#endif

Expand Down Expand Up @@ -399,7 +390,7 @@ template<typename T> struct calc {
* compile C99 and C++98+TR1 sources anyway).
*/
#define PADDUMMY(type, size) \
UBYTE d_u_m_m_y[alignof(type) - ((size) & (alignof(type) - 1))]
UBYTE d_u_m_m_y[form_alignof(type) - ((size) & (form_alignof(type) - 1))]
#define PADPOSITION(ptr_,long_,int_,word_,byte_) \
PADDUMMY(off_t, \
+ sizeof(int *) * (ptr_) \
Expand Down
2 changes: 1 addition & 1 deletion sources/minos.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static INDEXBLOCK scratchblock;
static NAMESBLOCK scratchnamesblock;

#define CFD(y,s,type,x,j) for(x=0,j=0;j<((int)sizeof(type));j++) \
x=(x<<8)+((*s++)&0x00FF); y=x;
{x=(x<<8)+((*s++)&0x00FF);} y=x;
#define CTD(y,s,type,x,j) x=y;for(j=sizeof(type)-1;j>=0;j--){s[j]=x&0xFF; \
x>>=8;} s += sizeof(type);

Expand Down
18 changes: 18 additions & 0 deletions sources/optimize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ class tree_node {

tree_node (int _var=0):
sum_results(0), num_visits(0), var(_var), finished(false) {}

tree_node(const tree_node& other):
childs(other.childs),
sum_results(other.sum_results),
num_visits(other.num_visits),
var(other.var),
finished(other.finished) {}

tree_node& operator=(const tree_node& other) {
if (this != &other) {
childs = other.childs;
sum_results = other.sum_results;
num_visits = other.num_visits;
var = other.var;
finished = other.finished;
}
return *this;
}
};

// global variables for multithreading
Expand Down
2 changes: 2 additions & 0 deletions sources/parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@
* (TU 7 Jun 2011)
*/
}
# define OMPI_SKIP_MPICXX 1
# include <mpi.h>
extern "C" {
# else
# define OMPI_SKIP_MPICXX 1
# include <mpi.h>
# endif

Expand Down
2 changes: 1 addition & 1 deletion sources/polygcd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ const map<vector<int>,int> polygcd::bracket_count(const poly &a, const vector<in

struct BracketInfo {
std::vector<int> pattern;
int num_terms, dummy;
int num_terms, dummy = 0;
const poly* p;

BracketInfo(const std::vector<int>& pattern, int num_terms, const poly* p) : pattern(pattern), num_terms(num_terms), p(p) {}
Expand Down
5 changes: 3 additions & 2 deletions sources/pre.c
Original file line number Diff line number Diff line change
Expand Up @@ -5679,14 +5679,15 @@ int DoSetExternalAttr(UBYTE *s)
}
}else if(strINCmp((UBYTE *)KILL,nam,lnam)==0){
int i,n=0;
for(i=0;i<lval;i++)
for(i=0;i<lval;i++) {
if( *val>='0' && *val<= '9' )
n = 10*n + *val++ - '0';
else{
MesPrint("@External channel: number expected for %s",KILL);
return(-1);
}
AX.killSignal=n;
}
AX.killSignal=n;
}else if(strINCmp((UBYTE *)STDERR,nam,lnam)==0){
if( AX.stderrname != NULL ) {
M_free(AX.stderrname,"external channel stderrname");
Expand Down
12 changes: 7 additions & 5 deletions sources/proces.c
Original file line number Diff line number Diff line change
Expand Up @@ -3315,12 +3315,14 @@ SkipCount: level++;
if ( level > AR.Cnumlhs ) {
if ( AR.DeferFlag && AR.sLevel <= 0 ) {
#ifdef WITHMPI
if ( PF.me != MASTER && AC.mparallelflag == PARALLELFLAG && PF.exprtodo < 0 ) {
if ( PF_Deferred(term,level) ) goto GenCall;
}
else
if ( PF.me != MASTER && AC.mparallelflag == PARALLELFLAG && PF.exprtodo < 0 ) {
if ( PF_Deferred(term,level) ) goto GenCall;
}
else
#endif
if ( Deferred(BHEAD term,level) ) goto GenCall;
{
if ( Deferred(BHEAD term,level) ) goto GenCall;
}
goto Return0;
}
if ( AN.ncmod != 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion sources/reken.c
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,7 @@ int MakeLongRational(PHEAD UWORD *a, WORD na, UWORD *m, WORD nm, UWORD *b, WORD
UWORD *x4 = NumberMalloc("MakeRational");
UWORD *y1 = NumberMalloc("MakeRational");
UWORD *y2 = NumberMalloc("MakeRational");
WORD nroot,nx1,nx2,nx3,nx4,ny1,ny2,retval = 0;
WORD nroot,nx1,nx2,nx3,nx4,ny1,ny2 = 0,retval = 0;
WORD sign = 1;
/*
Step 1: Take the square root of m
Expand Down
2 changes: 1 addition & 1 deletion sources/sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ WORD WriteAll(VOID)
*/
for ( n = 0; n < NumExpressions; n++ ) {
e = &Expressions[n];
if ( !e->printflag & PRINTON ) continue;
if ( (!e->printflag) & PRINTON ) continue;
switch ( e->status ) {
case LOCALEXPRESSION:
case GLOBALEXPRESSION:
Expand Down
1 change: 1 addition & 0 deletions sources/setfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ VOID WriteSetup(VOID)
SORTING *AllocSort(LONG inLargeSize, LONG inSmallSize, LONG inSmallEsize, LONG inTermsInSmall,
int inMaxPatches, int inMaxFpatches, LONG inIOsize, int level)
{
DUMMYUSE(level); /* This is only used in DEBUGGING mode */
LONG LargeSize = inLargeSize;
LONG SmallSize = inSmallSize;
LONG SmallEsize = inSmallEsize;
Expand Down
7 changes: 4 additions & 3 deletions sources/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,14 @@ dovariable: c = *in; *in = 0;
}
/*[06nov2003 mt]:*/
#ifdef WITHMPI
else/*RHSide*/
else { /*RHSide*/
/* NOTE: We always set AC.RhsExprInModuleFlag regardless of
* AP.PreAssignFlag or AP.PreInsideLevel because we have to detect
* RHS expressions even in those cases. */
AC.RhsExprInModuleFlag = 1;
if ( !AP.PreAssignFlag && !AP.PreInsideLevel )
Expressions[number].vflags |= ISINRHS;
}
if ( !AP.PreAssignFlag && !AP.PreInsideLevel )
Expressions[number].vflags |= ISINRHS;
#endif
/*:[06nov2003 mt]*/
if ( AC.exprfillwarning == 0 ) {
Expand Down
4 changes: 2 additions & 2 deletions sources/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@ if ( filelist ) MesPrint(" oldsize: %l, objectsize: %d, fullsize: %l"
#define DODOUBLE(x) { x *s, *t, *u; if ( *start ) { \
oldsize = *(x **)stop - *(x **)start; newsize = 2*oldsize; \
t = u = (x *)Malloc1(newsize*sizeof(x),text); s = *(x **)start; \
for ( i = 0; i < oldsize; i++ ) *t++ = *s++; M_free(*start,"double"); } \
for ( i = 0; i < oldsize; i++ ) {*t++ = *s++;} M_free(*start,"double"); } \
else { newsize = 100; u = (x *)Malloc1(newsize*sizeof(x),text); } \
*start = (void *)u; *stop = (void *)(u+newsize); }

Expand All @@ -2995,7 +2995,7 @@ void DoubleBuffer(void **start, void **stop, int size, char *text)
#define DOEXPAND(x) { x *newbuffer, *t, *m; \
t = newbuffer = (x *)Malloc1((newsize+2)*type,"ExpandBuffer"); \
if ( *buffer ) { m = (x *)*buffer; i = *oldsize; \
while ( --i >= 0 ) *t++ = *m++; M_free(*buffer,"ExpandBuffer"); \
while ( --i >= 0 ) {*t++ = *m++;} M_free(*buffer,"ExpandBuffer"); \
} *buffer = newbuffer; *oldsize = newsize; }

void ExpandBuffer(void **buffer, LONG *oldsize, int type)
Expand Down
Loading