From f80b662f774e245d1834e64f45ecabea6d346ca8 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 8 Mar 2024 14:27:36 +0200 Subject: [PATCH 1/8] Fix for Centos6/7 compilation issues --- ASTNode.cpp | 2 +- ASTree.cpp | 2 +- CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ASTNode.cpp b/ASTNode.cpp index 6959d6adc..b93a405ca 100644 --- a/ASTNode.cpp +++ b/ASTNode.cpp @@ -11,7 +11,7 @@ void ASTNodeList::removeLast() void ASTNodeList::removeFirst() { - m_nodes.erase(m_nodes.cbegin()); + m_nodes.erase(m_nodes.begin()); } diff --git a/ASTree.cpp b/ASTree.cpp index 0f8ca3b5d..c58b7be0a 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -34,7 +34,7 @@ static bool printClassDocstring = true; // shortcut for all top/pop calls static PycRef StackPopTop(FastStack& stack) { - const auto node{ stack.top() }; + const auto node(stack.top()); stack.pop(); return node; } diff --git a/CMakeLists.txt b/CMakeLists.txt index b2dd5dae5..195500b18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ if (ENABLE_STACK_DEBUG) endif() if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wshadow -Werror ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror ${CMAKE_CXX_FLAGS}") elseif(MSVC) set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}") add_definitions(-D_CRT_SECURE_NO_WARNINGS) From 28fdb904a0b4ef3ee17b5033dbf5a055f809a8d9 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Mar 2024 22:24:40 +0200 Subject: [PATCH 2/8] Prefer the parameters be renamed and this warning (-Wshadow) kept to make GCC happy --- ASTNode.h | 168 ++++++++++++++++++++++++------------------------- pyc_code.h | 4 +- pyc_numeric.h | 24 +++---- pyc_object.h | 2 +- pyc_sequence.h | 12 ++-- pyc_string.cpp | 14 ++--- pyc_string.h | 4 +- 7 files changed, 114 insertions(+), 114 deletions(-) diff --git a/ASTNode.h b/ASTNode.h index 22b90e1d3..90ad8c7e4 100644 --- a/ASTNode.h +++ b/ASTNode.h @@ -24,7 +24,7 @@ class ASTNode { NODE_LOCALS, }; - ASTNode(int type = NODE_INVALID) : m_refs(), m_type(type), m_processed() { } + ASTNode(int _type = NODE_INVALID) : m_refs(), m_type(_type), m_processed() { } virtual ~ASTNode() { } int type() const { return internalGetType(this); } @@ -65,8 +65,8 @@ class ASTNodeList : public ASTNode { public: typedef std::list> list_t; - ASTNodeList(list_t nodes) - : ASTNode(NODE_NODELIST), m_nodes(std::move(nodes)) { } + ASTNodeList(list_t _nodes) + : ASTNode(NODE_NODELIST), m_nodes(std::move(_nodes)) { } const list_t& nodes() const { return m_nodes; } void removeFirst(); @@ -74,8 +74,8 @@ class ASTNodeList : public ASTNode { void append(PycRef node) { m_nodes.emplace_back(std::move(node)); } protected: - ASTNodeList(list_t nodes, ASTNode::Type type) - : ASTNode(type), m_nodes(std::move(nodes)) { } + ASTNodeList(list_t _nodes, ASTNode::Type _type) + : ASTNode(_type), m_nodes(std::move(_nodes)) { } private: list_t m_nodes; @@ -84,8 +84,8 @@ class ASTNodeList : public ASTNode { class ASTChainStore : public ASTNodeList { public: - ASTChainStore(list_t nodes, PycRef src) - : ASTNodeList(nodes, NODE_CHAINSTORE), m_src(std::move(src)) { } + ASTChainStore(list_t _nodes, PycRef _src) + : ASTNodeList(_nodes, NODE_CHAINSTORE), m_src(std::move(_src)) { } PycRef src() const { return m_src; } @@ -112,8 +112,8 @@ class ASTUnary : public ASTNode { UN_POSITIVE, UN_NEGATIVE, UN_INVERT, UN_NOT }; - ASTUnary(PycRef operand, int op) - : ASTNode(NODE_UNARY), m_op(op), m_operand(std::move(operand)) { } + ASTUnary(PycRef _operand, int _op) + : ASTNode(NODE_UNARY), m_op(_op), m_operand(std::move(_operand)) { } PycRef operand() const { return m_operand; } int op() const { return m_op; } @@ -141,9 +141,9 @@ class ASTBinary : public ASTNode { BIN_INVALID }; - ASTBinary(PycRef left, PycRef right, int op, - int type = NODE_BINARY) - : ASTNode(type), m_op(op), m_left(std::move(left)), m_right(std::move(right)) { } + ASTBinary(PycRef _left, PycRef _right, int _op, + int _type = NODE_BINARY) + : ASTNode(_type), m_op(_op), m_left(std::move(_left)), m_right(std::move(_right)) { } PycRef left() const { return m_left; } PycRef right() const { return m_right; } @@ -171,8 +171,8 @@ class ASTCompare : public ASTBinary { CMP_EXCEPTION, CMP_BAD }; - ASTCompare(PycRef left, PycRef right, int op) - : ASTBinary(std::move(left), std::move(right), op, NODE_COMPARE) { } + ASTCompare(PycRef _left, PycRef _right, int _op) + : ASTBinary(std::move(_left), std::move(_right), _op, NODE_COMPARE) { } const char* op_str() const override; }; @@ -184,15 +184,15 @@ class ASTSlice : public ASTBinary { SLICE0, SLICE1, SLICE2, SLICE3 }; - ASTSlice(int op, PycRef left = {}, PycRef right = {}) - : ASTBinary(std::move(left), std::move(right), op, NODE_SLICE) { } + ASTSlice(int _op, PycRef _left = {}, PycRef _right = {}) + : ASTBinary(std::move(_left), std::move(_right), _op, NODE_SLICE) { } }; class ASTStore : public ASTNode { public: - ASTStore(PycRef src, PycRef dest) - : ASTNode(NODE_STORE), m_src(std::move(src)), m_dest(std::move(dest)) { } + ASTStore(PycRef _src, PycRef _dest) + : ASTNode(NODE_STORE), m_src(std::move(_src)), m_dest(std::move(_dest)) { } PycRef src() const { return m_src; } PycRef dest() const { return m_dest; } @@ -209,8 +209,8 @@ class ASTReturn : public ASTNode { RETURN, YIELD, YIELD_FROM }; - ASTReturn(PycRef value, RetType rettype = RETURN) - : ASTNode(NODE_RETURN), m_value(std::move(value)), m_rettype(rettype) { } + ASTReturn(PycRef _value, RetType _rettype = RETURN) + : ASTNode(NODE_RETURN), m_value(std::move(_value)), m_rettype(_rettype) { } PycRef value() const { return m_value; } RetType rettype() const { return m_rettype; } @@ -223,8 +223,8 @@ class ASTReturn : public ASTNode { class ASTName : public ASTNode { public: - ASTName(PycRef name) - : ASTNode(NODE_NAME), m_name(std::move(name)) { } + ASTName(PycRef _name) + : ASTNode(NODE_NAME), m_name(std::move(_name)) { } PycRef name() const { return m_name; } @@ -235,8 +235,8 @@ class ASTName : public ASTNode { class ASTDelete : public ASTNode { public: - ASTDelete(PycRef value) - : ASTNode(NODE_DELETE), m_value(std::move(value)) { } + ASTDelete(PycRef _value) + : ASTNode(NODE_DELETE), m_value(std::move(_value)) { } PycRef value() const { return m_value; } @@ -249,8 +249,8 @@ class ASTFunction : public ASTNode { public: typedef std::list> defarg_t; - ASTFunction(PycRef code, defarg_t defArgs, defarg_t kwDefArgs) - : ASTNode(NODE_FUNCTION), m_code(std::move(code)), + ASTFunction(PycRef _code, defarg_t defArgs, defarg_t kwDefArgs) + : ASTNode(NODE_FUNCTION), m_code(std::move(_code)), m_defargs(std::move(defArgs)), m_kwdefargs(std::move(kwDefArgs)) { } PycRef code() const { return m_code; } @@ -266,9 +266,9 @@ class ASTFunction : public ASTNode { class ASTClass : public ASTNode { public: - ASTClass(PycRef code, PycRef bases, PycRef name) - : ASTNode(NODE_CLASS), m_code(std::move(code)), m_bases(std::move(bases)), - m_name(std::move(name)) { } + ASTClass(PycRef _code, PycRef _bases, PycRef _name) + : ASTNode(NODE_CLASS), m_code(std::move(_code)), m_bases(std::move(_bases)), + m_name(std::move(_name)) { } PycRef code() const { return m_code; } PycRef bases() const { return m_bases; } @@ -286,9 +286,9 @@ class ASTCall : public ASTNode { typedef std::list> pparam_t; typedef std::list, PycRef>> kwparam_t; - ASTCall(PycRef func, pparam_t pparams, kwparam_t kwparams) - : ASTNode(NODE_CALL), m_func(std::move(func)), m_pparams(std::move(pparams)), - m_kwparams(std::move(kwparams)) { } + ASTCall(PycRef _func, pparam_t _pparams, kwparam_t _kwparams) + : ASTNode(NODE_CALL), m_func(std::move(_func)), m_pparams(std::move(_pparams)), + m_kwparams(std::move(_kwparams)) { } PycRef func() const { return m_func; } const pparam_t& pparams() const { return m_pparams; } @@ -299,8 +299,8 @@ class ASTCall : public ASTNode { bool hasVar() const { return m_var != nullptr; } bool hasKW() const { return m_kw != nullptr; } - void setVar(PycRef var) { m_var = std::move(var); } - void setKW(PycRef kw) { m_kw = std::move(kw); } + void setVar(PycRef _var) { m_var = std::move(_var); } + void setKW(PycRef _kw) { m_kw = std::move(_kw); } private: PycRef m_func; @@ -315,8 +315,8 @@ class ASTImport : public ASTNode { public: typedef std::list> list_t; - ASTImport(PycRef name, PycRef fromlist) - : ASTNode(NODE_IMPORT), m_name(std::move(name)), m_fromlist(std::move(fromlist)) { } + ASTImport(PycRef _name, PycRef _fromlist) + : ASTNode(NODE_IMPORT), m_name(std::move(_name)), m_fromlist(std::move(_fromlist)) { } PycRef name() const { return m_name; } list_t stores() const { return m_stores; } @@ -336,8 +336,8 @@ class ASTTuple : public ASTNode { public: typedef std::vector> value_t; - ASTTuple(value_t values) - : ASTNode(NODE_TUPLE), m_values(std::move(values)), + ASTTuple(value_t _values) + : ASTNode(NODE_TUPLE), m_values(std::move(_values)), m_requireParens(true) { } const value_t& values() const { return m_values; } @@ -356,8 +356,8 @@ class ASTList : public ASTNode { public: typedef std::list> value_t; - ASTList(value_t values) - : ASTNode(NODE_LIST), m_values(std::move(values)) { } + ASTList(value_t _values) + : ASTNode(NODE_LIST), m_values(std::move(_values)) { } const value_t& values() const { return m_values; } @@ -369,8 +369,8 @@ class ASTSet : public ASTNode { public: typedef std::deque> value_t; - ASTSet(value_t values) - : ASTNode(NODE_SET), m_values(std::move(values)) { } + ASTSet(value_t _values) + : ASTNode(NODE_SET), m_values(std::move(_values)) { } const value_t& values() const { return m_values; } @@ -416,8 +416,8 @@ class ASTConstMap : public ASTNode { public: typedef std::vector> values_t; - ASTConstMap(PycRef keys, const values_t& values) - : ASTNode(NODE_CONST_MAP), m_keys(std::move(keys)), m_values(std::move(values)) { } + ASTConstMap(PycRef _keys, const values_t& _values) + : ASTNode(NODE_CONST_MAP), m_keys(std::move(_keys)), m_values(std::move(_values)) { } const PycRef& keys() const { return m_keys; } const values_t& values() const { return m_values; } @@ -430,8 +430,8 @@ class ASTConstMap : public ASTNode { class ASTSubscr : public ASTNode { public: - ASTSubscr(PycRef name, PycRef key) - : ASTNode(NODE_SUBSCR), m_name(std::move(name)), m_key(std::move(key)) { } + ASTSubscr(PycRef _name, PycRef _key) + : ASTNode(NODE_SUBSCR), m_name(std::move(_name)), m_key(std::move(_key)) { } PycRef name() const { return m_name; } PycRef key() const { return m_key; } @@ -446,8 +446,8 @@ class ASTPrint : public ASTNode { public: typedef std::list> values_t; - ASTPrint(PycRef value, PycRef stream = {}) - : ASTNode(NODE_PRINT), m_stream(std::move(stream)), m_eol() + ASTPrint(PycRef value, PycRef _stream = {}) + : ASTNode(NODE_PRINT), m_stream(std::move(_stream)), m_eol() { if (value != nullptr) m_values.emplace_back(std::move(value)); @@ -460,7 +460,7 @@ class ASTPrint : public ASTNode { bool eol() const { return m_eol; } void add(PycRef value) { m_values.emplace_back(std::move(value)); } - void setEol(bool eol) { m_eol = eol; } + void setEol(bool _eol) { m_eol = _eol; } private: values_t m_values; @@ -471,8 +471,8 @@ class ASTPrint : public ASTNode { class ASTConvert : public ASTNode { public: - ASTConvert(PycRef name) - : ASTNode(NODE_CONVERT), m_name(std::move(name)) { } + ASTConvert(PycRef _name) + : ASTNode(NODE_CONVERT), m_name(std::move(_name)) { } PycRef name() const { return m_name; } @@ -487,7 +487,7 @@ class ASTKeyword : public ASTNode { KW_PASS, KW_BREAK, KW_CONTINUE }; - ASTKeyword(Word key) : ASTNode(NODE_KEYWORD), m_key(key) { } + ASTKeyword(Word _key) : ASTNode(NODE_KEYWORD), m_key(_key) { } Word key() const { return m_key; } const char* word_str() const; @@ -501,7 +501,7 @@ class ASTRaise : public ASTNode { public: typedef std::list> param_t; - ASTRaise(param_t params) : ASTNode(NODE_RAISE), m_params(std::move(params)) { } + ASTRaise(param_t _params) : ASTNode(NODE_RAISE), m_params(std::move(_params)) { } const param_t& params() const { return m_params; } @@ -537,8 +537,8 @@ class ASTBlock : public ASTNode { BLK_WHILE, BLK_FOR, BLK_WITH, BLK_ASYNCFOR }; - ASTBlock(BlkType blktype, int end = 0, int inited = 0) - : ASTNode(NODE_BLOCK), m_blktype(blktype), m_end(end), m_inited(inited) { } + ASTBlock(BlkType _blktype, int _end = 0, int _inited = 0) + : ASTNode(NODE_BLOCK), m_blktype(_blktype), m_end(_end), m_inited(_inited) { } BlkType blktype() const { return m_blktype; } int end() const { return m_end; } @@ -551,9 +551,9 @@ class ASTBlock : public ASTNode { virtual int inited() const { return m_inited; } virtual void init() { m_inited = 1; } - virtual void init(int init) { m_inited = init; } + virtual void init(int _init) { m_inited = _init; } - void setEnd(int end) { m_end = end; } + void setEnd(int _end) { m_end = _end; } private: BlkType m_blktype; @@ -571,9 +571,9 @@ class ASTCondBlock : public ASTBlock { UNINITED, POPPED, PRE_POPPED }; - ASTCondBlock(ASTBlock::BlkType blktype, int end, PycRef cond, - bool negative = false) - : ASTBlock(blktype, end), m_cond(std::move(cond)), m_negative(negative) { } + ASTCondBlock(ASTBlock::BlkType _blktype, int _end, PycRef _cond, + bool _negative = false) + : ASTBlock(_blktype, _end), m_cond(std::move(_cond)), m_negative(_negative) { } PycRef cond() const { return m_cond; } bool negative() const { return m_negative; } @@ -586,8 +586,8 @@ class ASTCondBlock : public ASTBlock { class ASTIterBlock : public ASTBlock { public: - ASTIterBlock(ASTBlock::BlkType blktype, int start, int end, PycRef iter) - : ASTBlock(blktype, end), m_iter(std::move(iter)), m_idx(), m_comp(), m_start(start) { } + ASTIterBlock(ASTBlock::BlkType _blktype, int _start, int _end, PycRef _iter) + : ASTBlock(_blktype, _end), m_iter(std::move(_iter)), m_idx(), m_comp(), m_start(_start) { } PycRef iter() const { return m_iter; } PycRef index() const { return m_idx; } @@ -609,15 +609,15 @@ class ASTIterBlock : public ASTBlock { class ASTContainerBlock : public ASTBlock { public: - ASTContainerBlock(int finally, int except = 0) - : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(finally), m_except(except) { } + ASTContainerBlock(int _finally, int _except = 0) + : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(_finally), m_except(_except) { } bool hasFinally() const { return m_finally != 0; } bool hasExcept() const { return m_except != 0; } int finally() const { return m_finally; } int except() const { return m_except; } - void setExcept(int except) { m_except = except; } + void setExcept(int _except) { m_except = _except; } private: int m_finally; @@ -626,14 +626,14 @@ class ASTContainerBlock : public ASTBlock { class ASTWithBlock : public ASTBlock { public: - ASTWithBlock(int end) - : ASTBlock(ASTBlock::BLK_WITH, end) { } + ASTWithBlock(int _end) + : ASTBlock(ASTBlock::BLK_WITH, _end) { } PycRef expr() const { return m_expr; } PycRef var() const { return m_var; } - void setExpr(PycRef expr) { m_expr = std::move(expr); init(); } - void setVar(PycRef var) { m_var = std::move(var); } + void setExpr(PycRef _expr) { m_expr = std::move(_expr); init(); } + void setVar(PycRef _var) { m_var = std::move(_var); } private: PycRef m_expr; @@ -644,8 +644,8 @@ class ASTComprehension : public ASTNode { public: typedef std::list> generator_t; - ASTComprehension(PycRef result) - : ASTNode(NODE_COMPREHENSION), m_result(std::move(result)) { } + ASTComprehension(PycRef _result) + : ASTNode(NODE_COMPREHENSION), m_result(std::move(_result)) { } PycRef result() const { return m_result; } generator_t generators() const { return m_generators; } @@ -692,12 +692,12 @@ class ASTFormattedValue : public ASTNode { FMTSPEC = 4 }; - ASTFormattedValue(PycRef val, ConversionFlag conversion, - PycRef format_spec) + ASTFormattedValue(PycRef _val, ConversionFlag _conversion, + PycRef _format_spec) : ASTNode(NODE_FORMATTEDVALUE), - m_val(std::move(val)), - m_conversion(conversion), - m_format_spec(std::move(format_spec)) + m_val(std::move(_val)), + m_conversion(_conversion), + m_format_spec(std::move(_format_spec)) { } PycRef val() const { return m_val; } @@ -715,8 +715,8 @@ class ASTJoinedStr : public ASTNode { public: typedef std::list> value_t; - ASTJoinedStr(value_t values) - : ASTNode(NODE_JOINEDSTR), m_values(std::move(values)) { } + ASTJoinedStr(value_t _values) + : ASTNode(NODE_JOINEDSTR), m_values(std::move(_values)) { } const value_t& values() const { return m_values; } @@ -726,8 +726,8 @@ class ASTJoinedStr : public ASTNode { class ASTAnnotatedVar : public ASTNode { public: - ASTAnnotatedVar(PycRef name, PycRef type) - : ASTNode(NODE_ANNOTATED_VAR), m_name(std::move(name)), m_type(std::move(type)) { } + ASTAnnotatedVar(PycRef _name, PycRef _type) + : ASTNode(NODE_ANNOTATED_VAR), m_name(std::move(_name)), m_type(std::move(_type)) { } PycRef name() const noexcept { return m_name; } PycRef annotation() const noexcept { return m_type; } @@ -740,10 +740,10 @@ class ASTAnnotatedVar : public ASTNode { class ASTTernary : public ASTNode { public: - ASTTernary(PycRef if_block, PycRef if_expr, - PycRef else_expr) - : ASTNode(NODE_TERNARY), m_if_block(std::move(if_block)), - m_if_expr(std::move(if_expr)), m_else_expr(std::move(else_expr)) { } + ASTTernary(PycRef _if_block, PycRef _if_expr, + PycRef _else_expr) + : ASTNode(NODE_TERNARY), m_if_block(std::move(_if_block)), + m_if_expr(std::move(_if_expr)), m_else_expr(std::move(_else_expr)) { } PycRef if_block() const noexcept { return m_if_block; } PycRef if_expr() const noexcept { return m_if_expr; } diff --git a/pyc_code.h b/pyc_code.h index 4d6e47cd0..8e26eb254 100644 --- a/pyc_code.h +++ b/pyc_code.h @@ -31,8 +31,8 @@ class PycCode : public PycObject { CO_FUTURE_GENERATOR_STOP = 0x80000, }; - PycCode(int type = TYPE_CODE) - : PycObject(type), m_argCount(), m_posOnlyArgCount(), m_kwOnlyArgCount(), + PycCode(int _type = TYPE_CODE) + : PycObject(_type), m_argCount(), m_posOnlyArgCount(), m_kwOnlyArgCount(), m_numLocals(), m_stackSize(), m_flags(), m_firstLine() { } void load(PycData* stream, PycModule* mod) override; diff --git a/pyc_numeric.h b/pyc_numeric.h index 46ddb98be..252356e74 100644 --- a/pyc_numeric.h +++ b/pyc_numeric.h @@ -8,8 +8,8 @@ class PycInt : public PycObject { public: - PycInt(int value = 0, int type = TYPE_INT) - : PycObject(type), m_value(value) { } + PycInt(int _value = 0, int _type = TYPE_INT) + : PycObject(_type), m_value(_value) { } bool isEqual(PycRef obj) const override { @@ -27,8 +27,8 @@ class PycInt : public PycObject { class PycLong : public PycObject { public: - PycLong(int type = TYPE_LONG) - : PycObject(type), m_size(0) { } + PycLong(int _type = TYPE_LONG) + : PycObject(_type), m_size(0) { } bool isEqual(PycRef obj) const override; @@ -46,8 +46,8 @@ class PycLong : public PycObject { class PycFloat : public PycObject { public: - PycFloat(int type = TYPE_FLOAT) - : PycObject(type) { } + PycFloat(int _type = TYPE_FLOAT) + : PycObject(_type) { } bool isEqual(PycRef obj) const override; @@ -61,8 +61,8 @@ class PycFloat : public PycObject { class PycComplex : public PycFloat { public: - PycComplex(int type = TYPE_COMPLEX) - : PycFloat(type) { } + PycComplex(int _type = TYPE_COMPLEX) + : PycFloat(_type) { } bool isEqual(PycRef obj) const override; @@ -76,8 +76,8 @@ class PycComplex : public PycFloat { class PycCFloat : public PycObject { public: - PycCFloat(int type = TYPE_BINARY_FLOAT) - : PycObject(type), m_value(0.0) { } + PycCFloat(int _type = TYPE_BINARY_FLOAT) + : PycObject(_type), m_value(0.0) { } bool isEqual(PycRef obj) const override { @@ -95,8 +95,8 @@ class PycCFloat : public PycObject { class PycCComplex : public PycCFloat { public: - PycCComplex(int type = TYPE_BINARY_COMPLEX) - : PycCFloat(type), m_imag(0.0) { } + PycCComplex(int _type = TYPE_BINARY_COMPLEX) + : PycCFloat(_type), m_imag(0.0) { } bool isEqual(PycRef obj) const override { diff --git a/pyc_object.h b/pyc_object.h index ade46c784..c80aeb83b 100644 --- a/pyc_object.h +++ b/pyc_object.h @@ -129,7 +129,7 @@ class PycObject { TYPE_SHORT_ASCII_INTERNED = 'Z', // Python 3.4 -> }; - PycObject(int type = TYPE_UNKNOWN) : m_refs(0), m_type(type) { } + PycObject(int _type = TYPE_UNKNOWN) : m_refs(0), m_type(_type) { } virtual ~PycObject() { } int type() const { return m_type; } diff --git a/pyc_sequence.h b/pyc_sequence.h index 64ff66ca5..5624bb957 100644 --- a/pyc_sequence.h +++ b/pyc_sequence.h @@ -7,7 +7,7 @@ class PycSequence : public PycObject { public: - PycSequence(int type) : PycObject(type), m_size(0) { } + PycSequence(int _type) : PycObject(_type), m_size(0) { } int size() const { return m_size; } virtual PycRef get(int idx) const = 0; @@ -20,7 +20,7 @@ class PycSimpleSequence : public PycSequence { public: typedef std::vector> value_t; - PycSimpleSequence(int type) : PycSequence(type) { } + PycSimpleSequence(int _type) : PycSequence(_type) { } bool isEqual(PycRef obj) const override; @@ -36,7 +36,7 @@ class PycSimpleSequence : public PycSequence { class PycTuple : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycTuple(int type = TYPE_TUPLE) : PycSimpleSequence(type) { } + PycTuple(int _type = TYPE_TUPLE) : PycSimpleSequence(_type) { } void load(class PycData* stream, class PycModule* mod) override; }; @@ -44,13 +44,13 @@ class PycTuple : public PycSimpleSequence { class PycList : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { } + PycList(int _type = TYPE_LIST) : PycSimpleSequence(_type) { } }; class PycSet : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { } + PycSet(int _type = TYPE_SET) : PycSimpleSequence(_type) { } }; class PycDict : public PycObject { @@ -58,7 +58,7 @@ class PycDict : public PycObject { typedef std::tuple, PycRef> item_t; typedef std::vector value_t; - PycDict(int type = TYPE_DICT) : PycObject(type) { } + PycDict(int _type = TYPE_DICT) : PycObject(_type) { } bool isEqual(PycRef obj) const override; diff --git a/pyc_string.cpp b/pyc_string.cpp index 5dd78065a..4609d3533 100644 --- a/pyc_string.cpp +++ b/pyc_string.cpp @@ -22,18 +22,18 @@ void PycString::load(PycData* stream, PycModule* mod) m_type = str->m_type; m_value = str->m_value; } else { - int length; + int _length; if (type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) - length = stream->getByte(); + _length = stream->getByte(); else - length = stream->get32(); + _length = stream->get32(); - if (length < 0) + if (_length < 0) throw std::bad_alloc(); - m_value.resize(length); - if (length) { - stream->getBuffer(length, &m_value.front()); + m_value.resize(_length); + if (_length) { + stream->getBuffer(_length, &m_value.front()); if (type() == TYPE_ASCII || type() == TYPE_ASCII_INTERNED || type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) { if (!check_ascii(m_value)) diff --git a/pyc_string.h b/pyc_string.h index 43ae2ed7b..5596664c8 100644 --- a/pyc_string.h +++ b/pyc_string.h @@ -8,8 +8,8 @@ class PycString : public PycObject { public: - PycString(int type = TYPE_STRING) - : PycObject(type) { } + PycString(int _type = TYPE_STRING) + : PycObject(_type) { } bool isEqual(PycRef obj) const override; bool isEqual(const std::string& str) const { return m_value == str; } From 6bae7e6df5ed3b8a6317084ff9e627feeeb409a6 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Mar 2024 22:43:26 +0200 Subject: [PATCH 3/8] Fix unhappy MSVC compiler on special toekens --- ASTNode.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ASTNode.h b/ASTNode.h index 90ad8c7e4..300819403 100644 --- a/ASTNode.h +++ b/ASTNode.h @@ -609,15 +609,15 @@ class ASTIterBlock : public ASTBlock { class ASTContainerBlock : public ASTBlock { public: - ASTContainerBlock(int _finally, int _except = 0) - : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(_finally), m_except(_except) { } + ASTContainerBlock(int finally_, int except_ = 0) + : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(finally_), m_except(except_) { } bool hasFinally() const { return m_finally != 0; } bool hasExcept() const { return m_except != 0; } int finally() const { return m_finally; } int except() const { return m_except; } - void setExcept(int _except) { m_except = _except; } + void setExcept(int except_) { m_except = except_; } private: int m_finally; From ce439a67bb9856f71a2137f524b9e2939ca9e236 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Mar 2024 22:51:17 +0200 Subject: [PATCH 4/8] Return back -Wshadow compiler option into non-Windows envs --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 195500b18..b2dd5dae5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ if (ENABLE_STACK_DEBUG) endif() if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wshadow -Werror ${CMAKE_CXX_FLAGS}") elseif(MSVC) set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}") add_definitions(-D_CRT_SECURE_NO_WARNINGS) From 68a697dfc1326969fe1a8cf4d7c4d538c0124197 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Mar 2024 22:38:03 +0200 Subject: [PATCH 5/8] Revert "Fix for Centos6/7 compilation issues" This reverts commit f80b662f774e245d1834e64f45ecabea6d346ca8. --- ASTNode.cpp | 2 +- ASTree.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ASTNode.cpp b/ASTNode.cpp index b93a405ca..6959d6adc 100644 --- a/ASTNode.cpp +++ b/ASTNode.cpp @@ -11,7 +11,7 @@ void ASTNodeList::removeLast() void ASTNodeList::removeFirst() { - m_nodes.erase(m_nodes.begin()); + m_nodes.erase(m_nodes.cbegin()); } diff --git a/ASTree.cpp b/ASTree.cpp index c58b7be0a..0f8ca3b5d 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -34,7 +34,7 @@ static bool printClassDocstring = true; // shortcut for all top/pop calls static PycRef StackPopTop(FastStack& stack) { - const auto node(stack.top()); + const auto node{ stack.top() }; stack.pop(); return node; } From ba91ff2de598d15a73ec37419e83977229711d6a Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Mar 2024 22:40:50 +0200 Subject: [PATCH 6/8] Revert shadow changes and add option -Wno-error=shadow to cmakefile --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2dd5dae5..4dda56b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ if (ENABLE_STACK_DEBUG) endif() if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wshadow -Werror ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-error=shadow -Werror ${CMAKE_CXX_FLAGS}") elseif(MSVC) set(CMAKE_CXX_FLAGS "/WX ${CMAKE_CXX_FLAGS}") add_definitions(-D_CRT_SECURE_NO_WARNINGS) From fd80a359c74bbca38d05699f8a86c9d595ba3f3c Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Mar 2024 22:55:56 +0200 Subject: [PATCH 7/8] Restore changes for shadow warnings... --- ASTNode.h | 168 ++++++++++++++++++++++++------------------------- pyc_code.h | 4 +- pyc_numeric.h | 24 +++---- pyc_object.h | 2 +- pyc_sequence.h | 12 ++-- pyc_string.cpp | 14 ++--- pyc_string.h | 4 +- 7 files changed, 114 insertions(+), 114 deletions(-) diff --git a/ASTNode.h b/ASTNode.h index 300819403..22b90e1d3 100644 --- a/ASTNode.h +++ b/ASTNode.h @@ -24,7 +24,7 @@ class ASTNode { NODE_LOCALS, }; - ASTNode(int _type = NODE_INVALID) : m_refs(), m_type(_type), m_processed() { } + ASTNode(int type = NODE_INVALID) : m_refs(), m_type(type), m_processed() { } virtual ~ASTNode() { } int type() const { return internalGetType(this); } @@ -65,8 +65,8 @@ class ASTNodeList : public ASTNode { public: typedef std::list> list_t; - ASTNodeList(list_t _nodes) - : ASTNode(NODE_NODELIST), m_nodes(std::move(_nodes)) { } + ASTNodeList(list_t nodes) + : ASTNode(NODE_NODELIST), m_nodes(std::move(nodes)) { } const list_t& nodes() const { return m_nodes; } void removeFirst(); @@ -74,8 +74,8 @@ class ASTNodeList : public ASTNode { void append(PycRef node) { m_nodes.emplace_back(std::move(node)); } protected: - ASTNodeList(list_t _nodes, ASTNode::Type _type) - : ASTNode(_type), m_nodes(std::move(_nodes)) { } + ASTNodeList(list_t nodes, ASTNode::Type type) + : ASTNode(type), m_nodes(std::move(nodes)) { } private: list_t m_nodes; @@ -84,8 +84,8 @@ class ASTNodeList : public ASTNode { class ASTChainStore : public ASTNodeList { public: - ASTChainStore(list_t _nodes, PycRef _src) - : ASTNodeList(_nodes, NODE_CHAINSTORE), m_src(std::move(_src)) { } + ASTChainStore(list_t nodes, PycRef src) + : ASTNodeList(nodes, NODE_CHAINSTORE), m_src(std::move(src)) { } PycRef src() const { return m_src; } @@ -112,8 +112,8 @@ class ASTUnary : public ASTNode { UN_POSITIVE, UN_NEGATIVE, UN_INVERT, UN_NOT }; - ASTUnary(PycRef _operand, int _op) - : ASTNode(NODE_UNARY), m_op(_op), m_operand(std::move(_operand)) { } + ASTUnary(PycRef operand, int op) + : ASTNode(NODE_UNARY), m_op(op), m_operand(std::move(operand)) { } PycRef operand() const { return m_operand; } int op() const { return m_op; } @@ -141,9 +141,9 @@ class ASTBinary : public ASTNode { BIN_INVALID }; - ASTBinary(PycRef _left, PycRef _right, int _op, - int _type = NODE_BINARY) - : ASTNode(_type), m_op(_op), m_left(std::move(_left)), m_right(std::move(_right)) { } + ASTBinary(PycRef left, PycRef right, int op, + int type = NODE_BINARY) + : ASTNode(type), m_op(op), m_left(std::move(left)), m_right(std::move(right)) { } PycRef left() const { return m_left; } PycRef right() const { return m_right; } @@ -171,8 +171,8 @@ class ASTCompare : public ASTBinary { CMP_EXCEPTION, CMP_BAD }; - ASTCompare(PycRef _left, PycRef _right, int _op) - : ASTBinary(std::move(_left), std::move(_right), _op, NODE_COMPARE) { } + ASTCompare(PycRef left, PycRef right, int op) + : ASTBinary(std::move(left), std::move(right), op, NODE_COMPARE) { } const char* op_str() const override; }; @@ -184,15 +184,15 @@ class ASTSlice : public ASTBinary { SLICE0, SLICE1, SLICE2, SLICE3 }; - ASTSlice(int _op, PycRef _left = {}, PycRef _right = {}) - : ASTBinary(std::move(_left), std::move(_right), _op, NODE_SLICE) { } + ASTSlice(int op, PycRef left = {}, PycRef right = {}) + : ASTBinary(std::move(left), std::move(right), op, NODE_SLICE) { } }; class ASTStore : public ASTNode { public: - ASTStore(PycRef _src, PycRef _dest) - : ASTNode(NODE_STORE), m_src(std::move(_src)), m_dest(std::move(_dest)) { } + ASTStore(PycRef src, PycRef dest) + : ASTNode(NODE_STORE), m_src(std::move(src)), m_dest(std::move(dest)) { } PycRef src() const { return m_src; } PycRef dest() const { return m_dest; } @@ -209,8 +209,8 @@ class ASTReturn : public ASTNode { RETURN, YIELD, YIELD_FROM }; - ASTReturn(PycRef _value, RetType _rettype = RETURN) - : ASTNode(NODE_RETURN), m_value(std::move(_value)), m_rettype(_rettype) { } + ASTReturn(PycRef value, RetType rettype = RETURN) + : ASTNode(NODE_RETURN), m_value(std::move(value)), m_rettype(rettype) { } PycRef value() const { return m_value; } RetType rettype() const { return m_rettype; } @@ -223,8 +223,8 @@ class ASTReturn : public ASTNode { class ASTName : public ASTNode { public: - ASTName(PycRef _name) - : ASTNode(NODE_NAME), m_name(std::move(_name)) { } + ASTName(PycRef name) + : ASTNode(NODE_NAME), m_name(std::move(name)) { } PycRef name() const { return m_name; } @@ -235,8 +235,8 @@ class ASTName : public ASTNode { class ASTDelete : public ASTNode { public: - ASTDelete(PycRef _value) - : ASTNode(NODE_DELETE), m_value(std::move(_value)) { } + ASTDelete(PycRef value) + : ASTNode(NODE_DELETE), m_value(std::move(value)) { } PycRef value() const { return m_value; } @@ -249,8 +249,8 @@ class ASTFunction : public ASTNode { public: typedef std::list> defarg_t; - ASTFunction(PycRef _code, defarg_t defArgs, defarg_t kwDefArgs) - : ASTNode(NODE_FUNCTION), m_code(std::move(_code)), + ASTFunction(PycRef code, defarg_t defArgs, defarg_t kwDefArgs) + : ASTNode(NODE_FUNCTION), m_code(std::move(code)), m_defargs(std::move(defArgs)), m_kwdefargs(std::move(kwDefArgs)) { } PycRef code() const { return m_code; } @@ -266,9 +266,9 @@ class ASTFunction : public ASTNode { class ASTClass : public ASTNode { public: - ASTClass(PycRef _code, PycRef _bases, PycRef _name) - : ASTNode(NODE_CLASS), m_code(std::move(_code)), m_bases(std::move(_bases)), - m_name(std::move(_name)) { } + ASTClass(PycRef code, PycRef bases, PycRef name) + : ASTNode(NODE_CLASS), m_code(std::move(code)), m_bases(std::move(bases)), + m_name(std::move(name)) { } PycRef code() const { return m_code; } PycRef bases() const { return m_bases; } @@ -286,9 +286,9 @@ class ASTCall : public ASTNode { typedef std::list> pparam_t; typedef std::list, PycRef>> kwparam_t; - ASTCall(PycRef _func, pparam_t _pparams, kwparam_t _kwparams) - : ASTNode(NODE_CALL), m_func(std::move(_func)), m_pparams(std::move(_pparams)), - m_kwparams(std::move(_kwparams)) { } + ASTCall(PycRef func, pparam_t pparams, kwparam_t kwparams) + : ASTNode(NODE_CALL), m_func(std::move(func)), m_pparams(std::move(pparams)), + m_kwparams(std::move(kwparams)) { } PycRef func() const { return m_func; } const pparam_t& pparams() const { return m_pparams; } @@ -299,8 +299,8 @@ class ASTCall : public ASTNode { bool hasVar() const { return m_var != nullptr; } bool hasKW() const { return m_kw != nullptr; } - void setVar(PycRef _var) { m_var = std::move(_var); } - void setKW(PycRef _kw) { m_kw = std::move(_kw); } + void setVar(PycRef var) { m_var = std::move(var); } + void setKW(PycRef kw) { m_kw = std::move(kw); } private: PycRef m_func; @@ -315,8 +315,8 @@ class ASTImport : public ASTNode { public: typedef std::list> list_t; - ASTImport(PycRef _name, PycRef _fromlist) - : ASTNode(NODE_IMPORT), m_name(std::move(_name)), m_fromlist(std::move(_fromlist)) { } + ASTImport(PycRef name, PycRef fromlist) + : ASTNode(NODE_IMPORT), m_name(std::move(name)), m_fromlist(std::move(fromlist)) { } PycRef name() const { return m_name; } list_t stores() const { return m_stores; } @@ -336,8 +336,8 @@ class ASTTuple : public ASTNode { public: typedef std::vector> value_t; - ASTTuple(value_t _values) - : ASTNode(NODE_TUPLE), m_values(std::move(_values)), + ASTTuple(value_t values) + : ASTNode(NODE_TUPLE), m_values(std::move(values)), m_requireParens(true) { } const value_t& values() const { return m_values; } @@ -356,8 +356,8 @@ class ASTList : public ASTNode { public: typedef std::list> value_t; - ASTList(value_t _values) - : ASTNode(NODE_LIST), m_values(std::move(_values)) { } + ASTList(value_t values) + : ASTNode(NODE_LIST), m_values(std::move(values)) { } const value_t& values() const { return m_values; } @@ -369,8 +369,8 @@ class ASTSet : public ASTNode { public: typedef std::deque> value_t; - ASTSet(value_t _values) - : ASTNode(NODE_SET), m_values(std::move(_values)) { } + ASTSet(value_t values) + : ASTNode(NODE_SET), m_values(std::move(values)) { } const value_t& values() const { return m_values; } @@ -416,8 +416,8 @@ class ASTConstMap : public ASTNode { public: typedef std::vector> values_t; - ASTConstMap(PycRef _keys, const values_t& _values) - : ASTNode(NODE_CONST_MAP), m_keys(std::move(_keys)), m_values(std::move(_values)) { } + ASTConstMap(PycRef keys, const values_t& values) + : ASTNode(NODE_CONST_MAP), m_keys(std::move(keys)), m_values(std::move(values)) { } const PycRef& keys() const { return m_keys; } const values_t& values() const { return m_values; } @@ -430,8 +430,8 @@ class ASTConstMap : public ASTNode { class ASTSubscr : public ASTNode { public: - ASTSubscr(PycRef _name, PycRef _key) - : ASTNode(NODE_SUBSCR), m_name(std::move(_name)), m_key(std::move(_key)) { } + ASTSubscr(PycRef name, PycRef key) + : ASTNode(NODE_SUBSCR), m_name(std::move(name)), m_key(std::move(key)) { } PycRef name() const { return m_name; } PycRef key() const { return m_key; } @@ -446,8 +446,8 @@ class ASTPrint : public ASTNode { public: typedef std::list> values_t; - ASTPrint(PycRef value, PycRef _stream = {}) - : ASTNode(NODE_PRINT), m_stream(std::move(_stream)), m_eol() + ASTPrint(PycRef value, PycRef stream = {}) + : ASTNode(NODE_PRINT), m_stream(std::move(stream)), m_eol() { if (value != nullptr) m_values.emplace_back(std::move(value)); @@ -460,7 +460,7 @@ class ASTPrint : public ASTNode { bool eol() const { return m_eol; } void add(PycRef value) { m_values.emplace_back(std::move(value)); } - void setEol(bool _eol) { m_eol = _eol; } + void setEol(bool eol) { m_eol = eol; } private: values_t m_values; @@ -471,8 +471,8 @@ class ASTPrint : public ASTNode { class ASTConvert : public ASTNode { public: - ASTConvert(PycRef _name) - : ASTNode(NODE_CONVERT), m_name(std::move(_name)) { } + ASTConvert(PycRef name) + : ASTNode(NODE_CONVERT), m_name(std::move(name)) { } PycRef name() const { return m_name; } @@ -487,7 +487,7 @@ class ASTKeyword : public ASTNode { KW_PASS, KW_BREAK, KW_CONTINUE }; - ASTKeyword(Word _key) : ASTNode(NODE_KEYWORD), m_key(_key) { } + ASTKeyword(Word key) : ASTNode(NODE_KEYWORD), m_key(key) { } Word key() const { return m_key; } const char* word_str() const; @@ -501,7 +501,7 @@ class ASTRaise : public ASTNode { public: typedef std::list> param_t; - ASTRaise(param_t _params) : ASTNode(NODE_RAISE), m_params(std::move(_params)) { } + ASTRaise(param_t params) : ASTNode(NODE_RAISE), m_params(std::move(params)) { } const param_t& params() const { return m_params; } @@ -537,8 +537,8 @@ class ASTBlock : public ASTNode { BLK_WHILE, BLK_FOR, BLK_WITH, BLK_ASYNCFOR }; - ASTBlock(BlkType _blktype, int _end = 0, int _inited = 0) - : ASTNode(NODE_BLOCK), m_blktype(_blktype), m_end(_end), m_inited(_inited) { } + ASTBlock(BlkType blktype, int end = 0, int inited = 0) + : ASTNode(NODE_BLOCK), m_blktype(blktype), m_end(end), m_inited(inited) { } BlkType blktype() const { return m_blktype; } int end() const { return m_end; } @@ -551,9 +551,9 @@ class ASTBlock : public ASTNode { virtual int inited() const { return m_inited; } virtual void init() { m_inited = 1; } - virtual void init(int _init) { m_inited = _init; } + virtual void init(int init) { m_inited = init; } - void setEnd(int _end) { m_end = _end; } + void setEnd(int end) { m_end = end; } private: BlkType m_blktype; @@ -571,9 +571,9 @@ class ASTCondBlock : public ASTBlock { UNINITED, POPPED, PRE_POPPED }; - ASTCondBlock(ASTBlock::BlkType _blktype, int _end, PycRef _cond, - bool _negative = false) - : ASTBlock(_blktype, _end), m_cond(std::move(_cond)), m_negative(_negative) { } + ASTCondBlock(ASTBlock::BlkType blktype, int end, PycRef cond, + bool negative = false) + : ASTBlock(blktype, end), m_cond(std::move(cond)), m_negative(negative) { } PycRef cond() const { return m_cond; } bool negative() const { return m_negative; } @@ -586,8 +586,8 @@ class ASTCondBlock : public ASTBlock { class ASTIterBlock : public ASTBlock { public: - ASTIterBlock(ASTBlock::BlkType _blktype, int _start, int _end, PycRef _iter) - : ASTBlock(_blktype, _end), m_iter(std::move(_iter)), m_idx(), m_comp(), m_start(_start) { } + ASTIterBlock(ASTBlock::BlkType blktype, int start, int end, PycRef iter) + : ASTBlock(blktype, end), m_iter(std::move(iter)), m_idx(), m_comp(), m_start(start) { } PycRef iter() const { return m_iter; } PycRef index() const { return m_idx; } @@ -609,15 +609,15 @@ class ASTIterBlock : public ASTBlock { class ASTContainerBlock : public ASTBlock { public: - ASTContainerBlock(int finally_, int except_ = 0) - : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(finally_), m_except(except_) { } + ASTContainerBlock(int finally, int except = 0) + : ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(finally), m_except(except) { } bool hasFinally() const { return m_finally != 0; } bool hasExcept() const { return m_except != 0; } int finally() const { return m_finally; } int except() const { return m_except; } - void setExcept(int except_) { m_except = except_; } + void setExcept(int except) { m_except = except; } private: int m_finally; @@ -626,14 +626,14 @@ class ASTContainerBlock : public ASTBlock { class ASTWithBlock : public ASTBlock { public: - ASTWithBlock(int _end) - : ASTBlock(ASTBlock::BLK_WITH, _end) { } + ASTWithBlock(int end) + : ASTBlock(ASTBlock::BLK_WITH, end) { } PycRef expr() const { return m_expr; } PycRef var() const { return m_var; } - void setExpr(PycRef _expr) { m_expr = std::move(_expr); init(); } - void setVar(PycRef _var) { m_var = std::move(_var); } + void setExpr(PycRef expr) { m_expr = std::move(expr); init(); } + void setVar(PycRef var) { m_var = std::move(var); } private: PycRef m_expr; @@ -644,8 +644,8 @@ class ASTComprehension : public ASTNode { public: typedef std::list> generator_t; - ASTComprehension(PycRef _result) - : ASTNode(NODE_COMPREHENSION), m_result(std::move(_result)) { } + ASTComprehension(PycRef result) + : ASTNode(NODE_COMPREHENSION), m_result(std::move(result)) { } PycRef result() const { return m_result; } generator_t generators() const { return m_generators; } @@ -692,12 +692,12 @@ class ASTFormattedValue : public ASTNode { FMTSPEC = 4 }; - ASTFormattedValue(PycRef _val, ConversionFlag _conversion, - PycRef _format_spec) + ASTFormattedValue(PycRef val, ConversionFlag conversion, + PycRef format_spec) : ASTNode(NODE_FORMATTEDVALUE), - m_val(std::move(_val)), - m_conversion(_conversion), - m_format_spec(std::move(_format_spec)) + m_val(std::move(val)), + m_conversion(conversion), + m_format_spec(std::move(format_spec)) { } PycRef val() const { return m_val; } @@ -715,8 +715,8 @@ class ASTJoinedStr : public ASTNode { public: typedef std::list> value_t; - ASTJoinedStr(value_t _values) - : ASTNode(NODE_JOINEDSTR), m_values(std::move(_values)) { } + ASTJoinedStr(value_t values) + : ASTNode(NODE_JOINEDSTR), m_values(std::move(values)) { } const value_t& values() const { return m_values; } @@ -726,8 +726,8 @@ class ASTJoinedStr : public ASTNode { class ASTAnnotatedVar : public ASTNode { public: - ASTAnnotatedVar(PycRef _name, PycRef _type) - : ASTNode(NODE_ANNOTATED_VAR), m_name(std::move(_name)), m_type(std::move(_type)) { } + ASTAnnotatedVar(PycRef name, PycRef type) + : ASTNode(NODE_ANNOTATED_VAR), m_name(std::move(name)), m_type(std::move(type)) { } PycRef name() const noexcept { return m_name; } PycRef annotation() const noexcept { return m_type; } @@ -740,10 +740,10 @@ class ASTAnnotatedVar : public ASTNode { class ASTTernary : public ASTNode { public: - ASTTernary(PycRef _if_block, PycRef _if_expr, - PycRef _else_expr) - : ASTNode(NODE_TERNARY), m_if_block(std::move(_if_block)), - m_if_expr(std::move(_if_expr)), m_else_expr(std::move(_else_expr)) { } + ASTTernary(PycRef if_block, PycRef if_expr, + PycRef else_expr) + : ASTNode(NODE_TERNARY), m_if_block(std::move(if_block)), + m_if_expr(std::move(if_expr)), m_else_expr(std::move(else_expr)) { } PycRef if_block() const noexcept { return m_if_block; } PycRef if_expr() const noexcept { return m_if_expr; } diff --git a/pyc_code.h b/pyc_code.h index 8e26eb254..4d6e47cd0 100644 --- a/pyc_code.h +++ b/pyc_code.h @@ -31,8 +31,8 @@ class PycCode : public PycObject { CO_FUTURE_GENERATOR_STOP = 0x80000, }; - PycCode(int _type = TYPE_CODE) - : PycObject(_type), m_argCount(), m_posOnlyArgCount(), m_kwOnlyArgCount(), + PycCode(int type = TYPE_CODE) + : PycObject(type), m_argCount(), m_posOnlyArgCount(), m_kwOnlyArgCount(), m_numLocals(), m_stackSize(), m_flags(), m_firstLine() { } void load(PycData* stream, PycModule* mod) override; diff --git a/pyc_numeric.h b/pyc_numeric.h index 252356e74..46ddb98be 100644 --- a/pyc_numeric.h +++ b/pyc_numeric.h @@ -8,8 +8,8 @@ class PycInt : public PycObject { public: - PycInt(int _value = 0, int _type = TYPE_INT) - : PycObject(_type), m_value(_value) { } + PycInt(int value = 0, int type = TYPE_INT) + : PycObject(type), m_value(value) { } bool isEqual(PycRef obj) const override { @@ -27,8 +27,8 @@ class PycInt : public PycObject { class PycLong : public PycObject { public: - PycLong(int _type = TYPE_LONG) - : PycObject(_type), m_size(0) { } + PycLong(int type = TYPE_LONG) + : PycObject(type), m_size(0) { } bool isEqual(PycRef obj) const override; @@ -46,8 +46,8 @@ class PycLong : public PycObject { class PycFloat : public PycObject { public: - PycFloat(int _type = TYPE_FLOAT) - : PycObject(_type) { } + PycFloat(int type = TYPE_FLOAT) + : PycObject(type) { } bool isEqual(PycRef obj) const override; @@ -61,8 +61,8 @@ class PycFloat : public PycObject { class PycComplex : public PycFloat { public: - PycComplex(int _type = TYPE_COMPLEX) - : PycFloat(_type) { } + PycComplex(int type = TYPE_COMPLEX) + : PycFloat(type) { } bool isEqual(PycRef obj) const override; @@ -76,8 +76,8 @@ class PycComplex : public PycFloat { class PycCFloat : public PycObject { public: - PycCFloat(int _type = TYPE_BINARY_FLOAT) - : PycObject(_type), m_value(0.0) { } + PycCFloat(int type = TYPE_BINARY_FLOAT) + : PycObject(type), m_value(0.0) { } bool isEqual(PycRef obj) const override { @@ -95,8 +95,8 @@ class PycCFloat : public PycObject { class PycCComplex : public PycCFloat { public: - PycCComplex(int _type = TYPE_BINARY_COMPLEX) - : PycCFloat(_type), m_imag(0.0) { } + PycCComplex(int type = TYPE_BINARY_COMPLEX) + : PycCFloat(type), m_imag(0.0) { } bool isEqual(PycRef obj) const override { diff --git a/pyc_object.h b/pyc_object.h index c80aeb83b..ade46c784 100644 --- a/pyc_object.h +++ b/pyc_object.h @@ -129,7 +129,7 @@ class PycObject { TYPE_SHORT_ASCII_INTERNED = 'Z', // Python 3.4 -> }; - PycObject(int _type = TYPE_UNKNOWN) : m_refs(0), m_type(_type) { } + PycObject(int type = TYPE_UNKNOWN) : m_refs(0), m_type(type) { } virtual ~PycObject() { } int type() const { return m_type; } diff --git a/pyc_sequence.h b/pyc_sequence.h index 5624bb957..64ff66ca5 100644 --- a/pyc_sequence.h +++ b/pyc_sequence.h @@ -7,7 +7,7 @@ class PycSequence : public PycObject { public: - PycSequence(int _type) : PycObject(_type), m_size(0) { } + PycSequence(int type) : PycObject(type), m_size(0) { } int size() const { return m_size; } virtual PycRef get(int idx) const = 0; @@ -20,7 +20,7 @@ class PycSimpleSequence : public PycSequence { public: typedef std::vector> value_t; - PycSimpleSequence(int _type) : PycSequence(_type) { } + PycSimpleSequence(int type) : PycSequence(type) { } bool isEqual(PycRef obj) const override; @@ -36,7 +36,7 @@ class PycSimpleSequence : public PycSequence { class PycTuple : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycTuple(int _type = TYPE_TUPLE) : PycSimpleSequence(_type) { } + PycTuple(int type = TYPE_TUPLE) : PycSimpleSequence(type) { } void load(class PycData* stream, class PycModule* mod) override; }; @@ -44,13 +44,13 @@ class PycTuple : public PycSimpleSequence { class PycList : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycList(int _type = TYPE_LIST) : PycSimpleSequence(_type) { } + PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { } }; class PycSet : public PycSimpleSequence { public: typedef PycSimpleSequence::value_t value_t; - PycSet(int _type = TYPE_SET) : PycSimpleSequence(_type) { } + PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { } }; class PycDict : public PycObject { @@ -58,7 +58,7 @@ class PycDict : public PycObject { typedef std::tuple, PycRef> item_t; typedef std::vector value_t; - PycDict(int _type = TYPE_DICT) : PycObject(_type) { } + PycDict(int type = TYPE_DICT) : PycObject(type) { } bool isEqual(PycRef obj) const override; diff --git a/pyc_string.cpp b/pyc_string.cpp index 4609d3533..5dd78065a 100644 --- a/pyc_string.cpp +++ b/pyc_string.cpp @@ -22,18 +22,18 @@ void PycString::load(PycData* stream, PycModule* mod) m_type = str->m_type; m_value = str->m_value; } else { - int _length; + int length; if (type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) - _length = stream->getByte(); + length = stream->getByte(); else - _length = stream->get32(); + length = stream->get32(); - if (_length < 0) + if (length < 0) throw std::bad_alloc(); - m_value.resize(_length); - if (_length) { - stream->getBuffer(_length, &m_value.front()); + m_value.resize(length); + if (length) { + stream->getBuffer(length, &m_value.front()); if (type() == TYPE_ASCII || type() == TYPE_ASCII_INTERNED || type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) { if (!check_ascii(m_value)) diff --git a/pyc_string.h b/pyc_string.h index 5596664c8..43ae2ed7b 100644 --- a/pyc_string.h +++ b/pyc_string.h @@ -8,8 +8,8 @@ class PycString : public PycObject { public: - PycString(int _type = TYPE_STRING) - : PycObject(_type) { } + PycString(int type = TYPE_STRING) + : PycObject(type) { } bool isEqual(PycRef obj) const override; bool isEqual(const std::string& str) const { return m_value == str; } From 8367a8e0ab7de2874a7233ae81a84ffe5ca05485 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 12 Mar 2024 22:58:43 +0200 Subject: [PATCH 8/8] Return back a fix for Centos6/7 compilation issues not related to shadow ones --- ASTNode.cpp | 2 +- ASTree.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ASTNode.cpp b/ASTNode.cpp index 6959d6adc..b93a405ca 100644 --- a/ASTNode.cpp +++ b/ASTNode.cpp @@ -11,7 +11,7 @@ void ASTNodeList::removeLast() void ASTNodeList::removeFirst() { - m_nodes.erase(m_nodes.cbegin()); + m_nodes.erase(m_nodes.begin()); } diff --git a/ASTree.cpp b/ASTree.cpp index 0f8ca3b5d..c58b7be0a 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -34,7 +34,7 @@ static bool printClassDocstring = true; // shortcut for all top/pop calls static PycRef StackPopTop(FastStack& stack) { - const auto node{ stack.top() }; + const auto node(stack.top()); stack.pop(); return node; }