Skip to content

Commit

Permalink
Merge pull request #162 from sparkprime/overloads
Browse files Browse the repository at this point in the history
Enable -Woverloaded-virtual and fix resulting warnings
  • Loading branch information
sparkprime committed Apr 22, 2016
2 parents 8025a01 + a1bda24 commit ef3fef8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OD ?= od

OPT ?= -O3

CXXFLAGS ?= -g $(OPT) -Wall -Wextra -pedantic -std=c++0x -fPIC -Iinclude
CXXFLAGS ?= -g $(OPT) -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude
CFLAGS ?= -g $(OPT) -Wall -Wextra -pedantic -std=c99 -fPIC -Iinclude
EMCXXFLAGS = $(CXXFLAGS) --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0
EMCFLAGS = $(CFLAGS) --memory-init-file 0 -s DISABLE_EXCEPTION_CATCHING=0
Expand Down
8 changes: 7 additions & 1 deletion core/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ class Pass {
}
}

virtual void file(AST *body, Fodder &final_fodder)
virtual void file(AST *&body, Fodder &final_fodder)
{
expr(body);
fodder(final_fodder);
Expand All @@ -960,6 +960,7 @@ class Pass {


class EnforceStringStyle : public Pass {
using Pass::visit;
public:
EnforceStringStyle(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }
void visit(LiteralString *lit)
Expand Down Expand Up @@ -1108,6 +1109,7 @@ bool contains_newline(const Fodder &fodder)

/* Commas should appear at the end of an object/array only if the closing token is on a new line. */
class FixTrailingCommas : public Pass {
using Pass::visit;
public:
FixTrailingCommas(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }
Fodder comments;
Expand Down Expand Up @@ -1182,6 +1184,7 @@ class FixTrailingCommas : public Pass {

/* Remove nested parens. */
class FixParens : public Pass {
using Pass::visit;
public:
FixParens(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }
void visit(Parens *expr)
Expand All @@ -1200,6 +1203,7 @@ class FixParens : public Pass {

/* Ensure ApplyBrace syntax sugar is used in the case of A + { }. */
class FixPlusObject : public Pass {
using Pass::visit;
public:
FixPlusObject(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }
void visitExpr(AST *&expr)
Expand All @@ -1225,6 +1229,7 @@ class FixPlusObject : public Pass {

/* Remove final colon in slices. */
class NoRedundantSliceColon : public Pass {
using Pass::visit;
public:
NoRedundantSliceColon(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }

Expand All @@ -1243,6 +1248,7 @@ class NoRedundantSliceColon : public Pass {

/* Ensure syntax sugar is used where possible. */
class PrettyFieldNames : public Pass {
using Pass::visit;
public:
PrettyFieldNames(Allocator &alloc, const FmtOpts &opts) : Pass(alloc, opts) { }

Expand Down

0 comments on commit ef3fef8

Please sign in to comment.