Skip to content

Commit

Permalink
Merge pull request #4389 from thehans/fix_warns
Browse files Browse the repository at this point in the history
Warnings: annihilated
  • Loading branch information
thehans committed Oct 25, 2022
2 parents 2b73ab1 + 4382416 commit 6fc6a9d
Show file tree
Hide file tree
Showing 52 changed files with 147 additions and 121 deletions.
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.10)

if(POLICY CMP0071)
# Let AUTOMOC and AUTOUIC process GENERATED files.
cmake_policy(SET CMP0071 OLD)
cmake_policy(SET CMP0071 NEW)
endif()
if(POLICY CMP0072)
# FindOpenGL prefers GLVND by default when available.
Expand Down Expand Up @@ -295,6 +295,12 @@ else()
find_graphics()
endif()

if (("${Boost_VERSION}" VERSION_GREATER "1.72") AND ("${Boost_VERSION}" VERSION_LESS "1.76"))
# Avoid warning messages from boost which are also caused by boost's code.
# https://github.com/boostorg/property_tree/issues/51
target_compile_definitions(OpenSCAD PUBLIC BOOST_BIND_GLOBAL_PLACEHOLDERS)
endif()

# Note: Saving CMAKE_MODULE_PATH as CGAL will overwrite it.
# Reconsider this after CGAL 5.4: https://github.com/CGAL/cgal/pull/6029
set(ORIGINAL_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
Expand Down Expand Up @@ -867,6 +873,12 @@ set(GUI_HEADERS
src/gui/NetworkSignal.h
)


if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Ignore specific warning on external lib
set_source_files_properties("src/ext/polyclipping/clipper.cpp" PROPERTIES COMPILE_FLAGS "-Wno-class-memaccess")
endif()

list(APPEND Sources src/openscad.cc ${CORE_SOURCES} ${CGAL_SOURCES} ${OFFSCREEN_SOURCES})

set(RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
Expand Down
6 changes: 0 additions & 6 deletions scripts/msys2-install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,4 @@ do
pacman --noconfirm --ask 20 --sync --needed ${pkg}
done

date "+### %Y-%m-%d %T downgrading cgal"
pactree mingw-w64-x86_64-cgal
curl --insecure -O https://files.openscad.org/tmp/mingw-w64-x86_64-cgal-5.2-3-any.pkg.tar.zst
curl --insecure -O https://files.openscad.org/tmp/mingw-w64-x86_64-cgal-5.2-3-any.pkg.tar.zst.sig
pacman -U --noconfirm mingw-w64-x86_64-cgal-5.2-3-any.pkg.tar.zst

date "+### %Y-%m-%d %T msys2-install-dependencies finished"
1 change: 0 additions & 1 deletion src/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#pragma once

#include <unordered_map>
#include <boost/format.hpp>
#include "printutils.h"

template <class Key, class T>
Expand Down
1 change: 0 additions & 1 deletion src/core/Expression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "Feature.h"
#include "Parameters.h"
#include "printutils.h"
#include <boost/bind.hpp>
#include "boost-utils.h"
#include <boost/regex.hpp>
#include <boost/assign/std/vector.hpp>
Expand Down
20 changes: 3 additions & 17 deletions src/core/LinearExtrudeNode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ static std::shared_ptr<AbstractNode> builtin_linear_extrude(const ModuleInstanti

node->layername = parameters["layer"].isUndefined() ? "" : parameters["layer"].toString();

double tmp_convexity = 0.0;
parameters["convexity"].getFiniteDouble(tmp_convexity);
node->convexity = static_cast<int>(tmp_convexity);
parameters["convexity"].getPositiveInt(node->convexity);

bool originOk = parameters["origin"].getVec2(node->origin_x, node->origin_y);
originOk &= std::isfinite(node->origin_x) && std::isfinite(node->origin_y);
Expand All @@ -117,23 +115,11 @@ static std::shared_ptr<AbstractNode> builtin_linear_extrude(const ModuleInstanti

if (node->height <= 0) node->height = 0;

if (node->convexity <= 0) node->convexity = 1;

if (node->scale_x < 0) node->scale_x = 0;
if (node->scale_y < 0) node->scale_y = 0;

double slicesVal = 0;
parameters["slices"].getFiniteDouble(slicesVal);
node->slices = static_cast<int>(slicesVal);
if (node->slices > 0) {
node->has_slices = true;
}

double segmentsVal = 0;
if (parameters["segments"].getFiniteDouble(segmentsVal)) {
node->has_segments = true;
node->segments = static_cast<int>(std::max(segmentsVal, 0.0));
}
node->has_slices = parameters["slices"].getUnsignedInt(node->slices);
node->has_segments = parameters["segments"].getUnsignedInt(node->segments);

node->twist = 0.0;
parameters["twist"].getFiniteDouble(node->twist);
Expand Down
4 changes: 2 additions & 2 deletions src/core/LinearExtrudeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class LinearExtrudeNode : public AbstractPolyNode
double fn = 0.0, fs = 0.0, fa = 0.0;
double scale_x = 1.0, scale_y = 1.0;
double twist = 0.0;
int convexity = 1;
int slices = 1, segments = 0;
unsigned int convexity = 1u;
unsigned int slices = 1u, segments = 0u;
bool has_twist = false, has_slices = false, has_segments = false;
bool center = false;

Expand Down
3 changes: 0 additions & 3 deletions src/core/ScopeContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include "SourceFileCache.h"
#include <cmath>
#include "boost-utils.h"
#ifdef DEBUG
#include <boost/format.hpp>
#endif

// Experimental code. See issue #399
#if 0
Expand Down
27 changes: 25 additions & 2 deletions src/core/Value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <cmath>
#include <numeric>
#include <sstream>
#include <boost/format.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
/*Unicode support for string lengths and array accesses*/
Expand Down Expand Up @@ -288,6 +287,30 @@ bool Value::getFiniteDouble(double& v) const
return false;
}

bool Value::getUnsignedInt(unsigned int& v) const
{
double result;
if (getFiniteDouble(result) &&
result >= 0.0 && result <= std::numeric_limits<unsigned int>::max())
{
v = result;
return true;
}
return false;
}

bool Value::getPositiveInt(unsigned int& v) const
{
double result;
if (getFiniteDouble(result) &&
result >= 1 && result <= std::numeric_limits<unsigned int>::max())
{
v = result;
return true;
}
return false;
}

const str_utf8_wrapper& Value::toStrUtf8Wrapper() const {
return boost::get<str_utf8_wrapper>(this->value);
}
Expand Down Expand Up @@ -329,7 +352,7 @@ class tostream_visitor : public boost::static_visitor<>
}

void operator()(const VectorType& v) const {
if (StackCheck::inst().check()) {
if (StackCheck::inst().check()) {
throw VectorEchoStringException::create();
}
stream << '[';
Expand Down
2 changes: 2 additions & 0 deletions src/core/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ class Value
// Other conversion utility functions
bool getDouble(double& v) const;
bool getFiniteDouble(double& v) const;
bool getUnsignedInt(unsigned int& v) const;
bool getPositiveInt(unsigned int& v) const;
std::string toString() const;
std::string toEchoString() const;
std::string toEchoStringNoThrow() const; //use this for warnings
Expand Down
6 changes: 4 additions & 2 deletions src/core/builtin_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int process_id = getpid();
std::mt19937 deterministic_rng(std::time(nullptr) + process_id);
#include <array>

static inline bool check_arguments(const char *function_name, const Arguments& arguments, const Location& loc, int expected_count, bool warn = true)
static inline bool check_arguments(const char *function_name, const Arguments& arguments, const Location& loc, unsigned int expected_count, bool warn = true)
{
if (arguments.size() != expected_count) {
if (warn) {
Expand All @@ -74,11 +74,12 @@ static inline bool check_arguments(const char *function_name, const Arguments& a
}
return true;
}
/* // Commented due to compiler warning of unused function.
static inline bool try_check_arguments(const Arguments& arguments, int expected_count)
{
return check_arguments(nullptr, arguments, Location::NONE, expected_count, false);
}

*/
template <size_t N>
static inline bool check_arguments(const char *function_name, const Arguments& arguments, const Location& loc, const Value::Type (& expected_types) [N], bool warn = true)
{
Expand All @@ -95,6 +96,7 @@ static inline bool check_arguments(const char *function_name, const Arguments& a
}
return true;
}

template <size_t N>
static inline bool try_check_arguments(const Arguments& arguments, const Value::Type (& expected_types) [N])
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/customizer/comment_lexer.l
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
%option prefix="comment_lexer"
%option nounput
%option noinput

%{
#include "Assignment.h"
Expand Down
2 changes: 2 additions & 0 deletions src/core/customizer/comment_parser.y
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
%expect 3

%{
#include <sstream>
#include <string.h>
Expand Down
5 changes: 2 additions & 3 deletions src/core/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/

%option prefix="lexer"
%option nounput
%option noinput

%{

Expand Down Expand Up @@ -54,9 +56,6 @@ extern "C" int __cdecl _isatty(int _FileHandle);

std::string stringcontents;
int lexerget_lineno(void);
#ifdef __GNUC__
static void yyunput(int, char*) __attribute__((unused));
#endif
extern const char *parser_input_buffer;
extern SourceFile *rootfile;

Expand Down
4 changes: 2 additions & 2 deletions src/geometry/PolySet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ void PolySet::resize(const Vector3d& newsize, const Eigen::Matrix<bool, 3, 1>& a
*/
void PolySet::quantizeVertices(std::vector<Vector3d> *pPointsOut)
{
Grid3d<int> grid(GRID_FINE);
std::vector<int> indices; // Vertex indices in one polygon
Grid3d<unsigned int> grid(GRID_FINE);
std::vector<unsigned int> indices; // Vertex indices in one polygon
for (std::vector<Polygon>::iterator iter = this->polygons.begin(); iter != this->polygons.end();) {
Polygon& p = *iter;
indices.resize(p.size());
Expand Down
5 changes: 5 additions & 0 deletions src/geometry/Polygon2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class Polygon2d : public Geometry

typedef std::vector<Outline2d> Outlines2d;
const Outlines2d& outlines() const { return theoutlines; }
// Note: The "using" here is a kludge to avoid a compiler warning.
// It would be better to fix the class relationships, so that Polygon2d does
// not inherit an unused 3d transform function.
// But that will likely require significant refactoring.
using Geometry::transform;

void transform(const Transform2d& mat);
void resize(const Vector2d& newsize, const Eigen::Matrix<bool, 2, 1>& autosize);
Expand Down
6 changes: 3 additions & 3 deletions src/geometry/cgal/cgalutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ template void transform(CGAL_HybridMesh& mesh, const Transform3d& matrix);

template <typename K>
Transform3d computeResizeTransform(
const CGAL::Iso_cuboid_3<K>& bb, int dimension, const Vector3d& newsize,
const CGAL::Iso_cuboid_3<K>& bb, unsigned int dimension, const Vector3d& newsize,
const Eigen::Matrix<bool, 3, 1>& autosize)
{
// Based on resize() in Giles Bathgate's RapCAD (but not exactly)
Expand Down Expand Up @@ -476,10 +476,10 @@ Transform3d computeResizeTransform(
}

template Transform3d computeResizeTransform(
const CGAL_Iso_cuboid_3& bb, int dimension, const Vector3d& newsize,
const CGAL_Iso_cuboid_3& bb, unsigned int dimension, const Vector3d& newsize,
const Eigen::Matrix<bool, 3, 1>& autosize);
template Transform3d computeResizeTransform(
const CGAL::Iso_cuboid_3<CGAL_HybridKernel3>& bb, int dimension, const Vector3d& newsize,
const CGAL::Iso_cuboid_3<CGAL_HybridKernel3>& bb, unsigned int dimension, const Vector3d& newsize,
const Eigen::Matrix<bool, 3, 1>& autosize);

shared_ptr<const PolySet> getGeometryAsPolySet(const shared_ptr<const Geometry>& geom)
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/cgal/cgalutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ template <typename K>
void transform(CGAL::Surface_mesh<CGAL::Point_3<K>>& mesh, const Transform3d& matrix);
template <typename K>
Transform3d computeResizeTransform(
const CGAL::Iso_cuboid_3<K>& bb, int dimension, const Vector3d& newsize,
const CGAL::Iso_cuboid_3<K>& bb, unsigned int dimension, const Vector3d& newsize,
const Eigen::Matrix<bool, 3, 1>& autosize);
bool tessellatePolygon(const PolygonK& polygon,
Polygons& triangles,
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/roof_vd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Faces_2_plus_1 vd_inner_faces(const voronoi_diagram& vd,
double fa, double fs) {
Faces_2_plus_1 ret;

auto cell_contains_boundary_point = [&vd, &segments](const voronoi_diagram::cell_type *cell,
auto cell_contains_boundary_point = [&segments](const voronoi_diagram::cell_type *cell,
const Point& point) {
Segment segment = segments[cell->source_index()];
return (cell->contains_segment() && segment_has_endpoint(segment, point) )
Expand Down
1 change: 1 addition & 0 deletions src/glview/cgal/CGAL_OGL_VBOPolyhedron.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class CGAL_OGL_VBOPolyhedron : public VBOPolyhedron, public CGAL_OGL_Polyhedron
PRINTD("CGAL_OGL_VBOPolyhedron() end");
}

using VBOPolyhedron::draw; // draw()
void draw(bool showedges) const override {
PRINTDB("VBO draw(showedges = %d)", showedges);
// grab current state to restore after
Expand Down
1 change: 1 addition & 0 deletions src/glview/cgal/CGAL_OGL_VBO_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class VBOPolyhedron : public virtual Polyhedron
if (halffacets_elements_vbo) glDeleteBuffers(1, &halffacets_elements_vbo);
}

using CGAL::OGL::Polyhedron::draw;
void draw(Vertex_iterator v, VertexArray& vertex_array) const {
PRINTD("draw(Vertex_iterator)");

Expand Down
7 changes: 4 additions & 3 deletions src/glview/preview/OpenCSGRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ void OpenCSGRenderer::renderCSGProducts(const std::shared_ptr<CSGProducts>& prod
}

if (shaderinfo && shaderinfo->progid) {
if (shaderinfo->type != EDGE_RENDERING ||
(shaderinfo->type == EDGE_RENDERING && showedges)) glUseProgram(shaderinfo->progid); GL_ERROR_CHECK();
if (shaderinfo->type != EDGE_RENDERING || (shaderinfo->type == EDGE_RENDERING && showedges)) {
glUseProgram(shaderinfo->progid); GL_ERROR_CHECK();
}
}

for (const auto& csgobj : product.intersections) {
Expand Down Expand Up @@ -450,7 +451,7 @@ void OpenCSGRenderer::renderCSGProducts(const std::shared_ptr<CSGProducts>& prod
colormode = ColorMode::CUTOUT;
}

const Color4f color = setColor(colormode, c.data(), shaderinfo);
(void) setColor(colormode, c.data(), shaderinfo);
glPushMatrix();
glMultMatrixd(csgobj.leaf->matrix.data());
// negative objects should only render rear faces
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MouseSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void MouseSelector::init_shader() {
*/
void MouseSelector::setup_framebuffer(const GLView *view) {
if (!this->framebuffer ||
this->framebuffer->width() != view->cam.pixel_width ||
this->framebuffer->height() != view->cam.pixel_height) {
static_cast<unsigned int>(this->framebuffer->width()) != view->cam.pixel_width ||
static_cast<unsigned int>(this->framebuffer->height()) != view->cam.pixel_height) {
this->framebuffer.reset(
new QOpenGLFramebufferObject(
view->cam.pixel_width,
Expand All @@ -147,8 +147,8 @@ int MouseSelector::select(const Renderer *renderer, int x, int y) {
// x/y is originated topleft, so turn y around
y = this->view->cam.pixel_height - y;

if (x > this->view->cam.pixel_width || x < 0 ||
y > this->view->cam.pixel_height || y < 0) {
if (x > static_cast<int>(this->view->cam.pixel_width) || x < 0 ||
y > static_cast<int>(this->view->cam.pixel_height) || y < 0) {
return -1;
}

Expand Down
6 changes: 3 additions & 3 deletions src/gui/ScintillaEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ void ScintillaEditor::onCharacterThresholdChanged(int val)

void ScintillaEditor::resetHighlighting(){
qsci->recolor(); //lex and restyle the whole text

//remove all indicators
qsci->SendScintilla(QsciScintilla::SCI_SETINDICATORCURRENT, hyperlinkIndicatorNumber);
qsci->SendScintilla(QsciScintilla::SCI_INDICATORCLEARRANGE, 0, qsci->length());
Expand Down Expand Up @@ -1356,7 +1356,7 @@ void ScintillaEditor::onIndicatorClicked(int line, int col, Qt::KeyboardModifier
int val = qsci->SendScintilla(QsciScintilla::SCI_INDICATORVALUEAT, ScintillaEditor::hyperlinkIndicatorNumber, pos);

// checking if indicator clicked is hyperlinkIndicator
if (val >= hyperlinkIndicatorOffset && val <= hyperlinkIndicatorOffset + indicatorData.size()) {
if (val >= hyperlinkIndicatorOffset && val <= hyperlinkIndicatorOffset + static_cast<int>(indicatorData.size())) {
if (indicatorsActive) {
emit hyperlinkIndicatorClicked(val - hyperlinkIndicatorOffset);
}
Expand All @@ -1371,7 +1371,7 @@ void ScintillaEditor::onIndicatorReleased(int line, int col, Qt::KeyboardModifie
int val = qsci->SendScintilla(QsciScintilla::SCI_INDICATORVALUEAT, ScintillaEditor::hyperlinkIndicatorNumber, pos);

// checking if indicator clicked is hyperlinkIndicator
if (val >= hyperlinkIndicatorOffset && val <= hyperlinkIndicatorOffset + indicatorData.size()) {
if (val >= hyperlinkIndicatorOffset && val <= hyperlinkIndicatorOffset + static_cast<int>(indicatorData.size())) {
if (!indicatorsActive) {
QTimer::singleShot(0, this, [this] {
QToolTip::showText(QCursor::pos(), "Use <b>CTRL + Click</b> to open the file", this, rect(), toolTipDuration());
Expand Down

0 comments on commit 6fc6a9d

Please sign in to comment.