Enable and mollify -Wunused-variable.

In my (whitequark's) experience this warning tends to expose
copy-paste errors with a high SNR, so making a few fragments
slightly less symmetric is worth it.

Also mollify -Wlogical-op-parentheses while we're at it.
This commit is contained in:
whitequark 2016-02-14 00:36:54 +00:00
parent d43bd93060
commit 29ad1acdfe
14 changed files with 11 additions and 23 deletions

View File

@ -42,6 +42,13 @@ if(WIN32)
-D_UNICODE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(WARNING_FLAGS
-Wunused-variable)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
endif()
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")

View File

@ -604,7 +604,6 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
}
ExprVector au = a->NormalExprsU(),
av = a->NormalExprsV(),
an = a->NormalExprsN();
ExprVector bu = b->NormalExprsU(),
bv = b->NormalExprsV(),

View File

@ -130,7 +130,6 @@ void GraphicsWindow::MakeUnselected(Selection *stog, bool coincidentPointTrick){
Selection *s;
// If an item was selected, then we just un-select it.
bool wasSelected = false;
selection.ClearTags();
for(s = selection.First(); s; s = selection.NextAfter(s)) {
if(s->Equals(stog)) {

View File

@ -244,7 +244,6 @@ int Constraint::DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b) {
void Constraint::DoLineWithArrows(Vector ref, Vector a, Vector b,
bool onlyOneExt)
{
Vector gn = (SS.GW.projRight.Cross(SS.GW.projUp)).WithMagnitude(1);
double pixels = 1.0 / SS.GW.scale;
Vector ab = a.Minus(b);

View File

@ -465,8 +465,6 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) {
void Entity::DrawOrGetDistance(void) {
if(!IsVisible()) return;
Group *g = SK.GetGroup(group);
switch(type) {
case POINT_N_COPY:
case POINT_N_TRANS:

View File

@ -46,7 +46,6 @@ double ssglStrWidth(const std::string &str, double h)
iter = ReadUTF8(iter, &chr);
const VectorGlyph &glyph = GetVectorGlyph(chr);
int glyphWidth = glyph.width;
if(glyph.baseCharacter != 0) {
const VectorGlyph &baseGlyph = GetVectorGlyph(glyph.baseCharacter);
width += max(glyph.width, baseGlyph.width);

View File

@ -514,7 +514,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
bool Group::IsSolvedOkay() {
return this->solved.how == System::SOLVED_OKAY ||
this->allowRedundant && this->solved.how == System::REDUNDANT_OKAY;
(this->allowRedundant && this->solved.how == System::REDUNDANT_OKAY);
}
void Group::AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index) {
@ -525,7 +525,6 @@ void Group::AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index) {
}
void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
Equation eq = {};
if(type == IMPORTED) {
// Normalize the quaternion
ExprQuaternion q = {

View File

@ -403,7 +403,6 @@ SKdNode *SKdNode::From(STriangleLl *tll) {
int tcnt = 0;
STriangleLl *ll;
for(ll = tll; ll; ll = ll->next) {
STriangle *tr = ll->tri;
split[i] += (ll->tri->a).Element(i);
split[i] += (ll->tri->b).Element(i);
split[i] += (ll->tri->c).Element(i);
@ -672,7 +671,6 @@ void SKdNode::SplitLinesAgainstTriangle(SEdgeList *sel, STriangle *tr) {
for(se = sel->l.First(); se; se = sel->l.NextAfter(se)) {
Vector pt = ((se->a).Plus(se->b)).ScaledBy(0.5);
double dt = pt.Dot(tn) - td;
if(pt.Dot(tn) - td > -LENGTH_EPS) {
// Edge is in front of or on our plane (remember, tn.z > 0)
// so it is exempt from further splitting

View File

@ -6,7 +6,7 @@
//-----------------------------------------------------------------------------
#include "solvespace.h"
static int I, N, FLAG;
static int I;
void SShell::MakeFromUnionOf(SShell *a, SShell *b) {
MakeFromBoolean(a, b, AS_UNION);
@ -109,7 +109,6 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
// And now uses the intersections to generate our split pwl edge(s)
Vector prev = Vector::From(VERY_POSITIVE, 0, 0);
for(pi = il.First(); pi; pi = il.NextAfter(pi)) {
double t = (pi->p.Minus(LineStart)).DivPivoting(LineDirection);
// On-edge intersection will generate same split point for
// both surfaces, so don't create zero-length edge.
if(!prev.Equals(pi->p)) {
@ -360,8 +359,6 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
{
// the midpoint of the edge
Point2d muv = (auv.Plus(buv)).ScaledBy(0.5);
// a vector parallel to the edge
Point2d abuv = buv.Minus(auv).WithMagnitude(0.01);
*pt = PointAt(muv);

View File

@ -312,8 +312,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB,
SPointList spl = {};
int a;
for(a = 0; a < 2; a++) {
SShell *shA = (a == 0) ? agnstA : agnstB,
*shB = (a == 0) ? agnstB : agnstA;
SShell *shA = (a == 0) ? agnstA : agnstB;
SSurface *srfA = (a == 0) ? this : b,
*srfB = (a == 0) ? b : this;

View File

@ -401,7 +401,7 @@ int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
{
WriteEquationsExceptFor(Constraint::NO_CONSTRAINT, g);
int i, j = 0;
int i;
bool rankOk;
/*

View File

@ -374,7 +374,6 @@ void TextWindow::ShowGroupInfo(void) {
g->color.alphaF(),
&TextWindow::ScreenOpacity);
} else if(g->type == Group::IMPORTED) {
bool sup = g->suppress;
Printf(false, " %Fd%f%LP%s suppress this group's solid model",
&TextWindow::ScreenChangeGroupOption,
g->suppress ? CHECK_TRUE : CHECK_FALSE);

View File

@ -64,8 +64,6 @@ bool GLOffscreen::begin(int width, int height) {
}
uint8_t *GLOffscreen::end(bool flip) {
uint32_t *pixels_tgt = flip ? _pixels_inv : _pixels;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
glReadPixels(0, 0, _width, _height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, _pixels_inv);

View File

@ -810,9 +810,6 @@ void Vector::ClosestPointBetweenLines(Vector a0, Vector da,
Vector b0, Vector db,
double *ta, double *tb)
{
Vector a1 = a0.Plus(da),
b1 = a1.Plus(db);
// Make a semi-orthogonal coordinate system from those directions;
// note that dna and dnb need not be perpendicular.
Vector dn = da.Cross(db); // normal to both