From 85753d240f5b9a1214656165125808971499d61a Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 12:16:22 -0400 Subject: [PATCH 1/8] Fix instances of Clang's -Wunqualified-std-cast-call --- multigame.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/multigame.cpp b/multigame.cpp index 6373734a..e5bd98e0 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -26,25 +26,24 @@ struct gamedata { if(ssize & 7) ssize = (ssize | 7) + 1; if(mode == 0) { record.resize(index+ssize); - T& at = *(new (&record[index]) T()); - at = move(x); + ::new (&record[index]) T(std::move(x)); } else { T& at = (T&) record[index]; - x = move(at); + x = std::move(at); at.~T(); } index += ssize; } template void store_ptr(T& x) { - T* copy; if(mode == 0) { - copy = new T; - *copy = move(x); + T* copy = new T(std::move(x)); + store(copy); } - store(copy); - if(mode != 0) { - x = move(*copy); + else { + T* copy = nullptr; + store(copy); + x = std::move(*copy); delete copy; } } From 0ae74aad62127ee301a5b11a1342d0182f2c8b0e Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 13:23:05 -0400 Subject: [PATCH 2/8] Fix more instances of Clang's -Wunqualified-std-cast-call --- archimedean.cpp | 2 +- complex.cpp | 4 ++-- complex2.cpp | 2 +- crystal.cpp | 2 +- drawing.cpp | 10 +++++----- environment.cpp | 2 +- expansion.cpp | 4 ++-- irregular.cpp | 4 ++-- mapeditor.cpp | 2 +- reg3.cpp | 2 +- rogueviz/banachtarski.cpp | 6 +++--- rogueviz/dynamic-wfc.cpp | 2 +- rogueviz/gobot.cpp | 4 ++-- rogueviz/som/kohonen.cpp | 4 ++-- rogueviz/som/tests.cpp | 2 +- surface.cpp | 4 ++-- textures.cpp | 8 ++++---- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/archimedean.cpp b/archimedean.cpp index 1acebb0a..8554ce7d 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -1314,7 +1314,7 @@ EX void show() { } else { tested.coloring = col; - tilings.push_back(move(tested)); + tilings.push_back(std::move(tested)); /* sort(tilings.begin(), tilings.end(), [] (archimedean_tiling& s1, archimedean_tiling& s2) { if(s1.euclidean_angle_sum < s2.euclidean_angle_sum - 1e-6) return true; if(s2.euclidean_angle_sum < s1.euclidean_angle_sum - 1e-6) return false; diff --git a/complex.cpp b/complex.cpp index 2bf761c5..685d331c 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2082,7 +2082,7 @@ EX namespace heat { } } - offscreen_heat = move(offscreen2); + offscreen_heat = std::move(offscreen2); for(int i=0; i S7) remove_half_dimension(); diff --git a/drawing.cpp b/drawing.cpp index 17ddc267..96921ec1 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2206,13 +2206,13 @@ EX void sort_drawqueue() { #if MINIMIZE_GL_CALLS map>> subqueue; - for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->outline_group()].push_back(move(p)); + for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->outline_group()].push_back(std::move(p)); ptds.clear(); - for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(move(r)); + for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(std::move(r)); subqueue.clear(); - for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->color].push_back(move(p)); + for(auto& p: ptds) subqueue[(p->prio == PPR::CIRCLE || p->prio == PPR::OUTCIRCLE) ? 0 : p->color].push_back(std::move(p)); ptds.clear(); - for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(move(r)); + for(auto& p: subqueue) for(auto& r: p.second) ptds.push_back(std::move(r)); #endif for(auto& p: ptds) { @@ -2233,7 +2233,7 @@ EX void sort_drawqueue() { vector> ptds2; ptds2.resize(siz); - for(int i = 0; iprio)]++] = move(ptds[i]); + for(int i = 0; iprio)]++] = std::move(ptds[i]); swap(ptds, ptds2); } diff --git a/environment.cpp b/environment.cpp index 2bb2bad8..3e1c241d 100644 --- a/environment.cpp +++ b/environment.cpp @@ -859,7 +859,7 @@ EX void monstersTurn() { changes.value_keep(crush_now); changes.value_keep(crush_next); - crush_now = move(crush_next); + crush_now = std::move(crush_next); crush_next.clear(); DEBB(DF_TURN, ("heat")); diff --git a/expansion.cpp b/expansion.cpp index 60a534f9..57961ba8 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -190,7 +190,7 @@ void expansion_analyzer::reduce_grouping() { for(int i=0; i bestval) bestval = mindist, s.owner = c, s.p = h, s.relmatrices = move(relmatrices); + if(mindist > bestval) bestval = mindist, s.owner = c, s.p = h, s.relmatrices = std::move(relmatrices); } } make_cells_of_heptagon(); diff --git a/mapeditor.cpp b/mapeditor.cpp index 44c65867..6ce2d700 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -2371,7 +2371,7 @@ EX namespace mapeditor { } if(uni == 'c') dsCur->list.push_back(best); else if(uni == 'd') { - vector oldlist = move(dsCur->list); + vector oldlist = std::move(dsCur->list); dsCur->list.clear(); int i; for(i=0; i>>> xptds; for(int i=0; i<4; i++) for(auto& p: subscr[i]) - xptds[int(p->prio)][i].push_back(move(p)); + xptds[int(p->prio)][i].push_back(std::move(p)); for(auto& sm: xptds) for(auto& sm2: sm.second) { int i = sm2.first; ptds.clear(); - for(auto& p: sm2.second) ptds.push_back(move(p)); + for(auto& p: sm2.second) ptds.push_back(std::move(p)); pconf.scale = .5; pconf.xposition = (!(i&2)) ? xdst : -xdst; diff --git a/rogueviz/dynamic-wfc.cpp b/rogueviz/dynamic-wfc.cpp index 3cfb792c..8ddad074 100644 --- a/rogueviz/dynamic-wfc.cpp +++ b/rogueviz/dynamic-wfc.cpp @@ -313,7 +313,7 @@ void wfc() { nfreq.emplace_back(p); nfreq.back().code |= (code_t(c) << sh); } - freq = move(nfreq); + freq = std::move(nfreq); nfreq = {}; // println(hlog, "inpath = ", inpath); // println(hlog, "freqs = ", isize(freq)); diff --git a/rogueviz/gobot.cpp b/rogueviz/gobot.cpp index 0d01a18a..ef7fe285 100644 --- a/rogueviz/gobot.cpp +++ b/rogueviz/gobot.cpp @@ -157,8 +157,8 @@ void clean_old_shots() { sh.get().delete_message(); } else - remaining.emplace_back(move(sh)); - old_shots = move(remaining); + remaining.emplace_back(std::move(sh)); + old_shots = std::move(remaining); */ } diff --git a/rogueviz/som/kohonen.cpp b/rogueviz/som/kohonen.cpp index 19d45931..10c9407d 100644 --- a/rogueviz/som/kohonen.cpp +++ b/rogueviz/som/kohonen.cpp @@ -91,7 +91,7 @@ void loadsamples(const string& fname) { if(c == '!' && s.name == "") shown = true; else if(!rv_ignore(c)) s.name += c; } - data.push_back(move(s)); + data.push_back(std::move(s)); if(shown) samples_to_show.push_back(isize(data)-1); } @@ -624,7 +624,7 @@ void verify_crawlers() { breakcheck: cellcrawler cr; cr.build(cellwalker(c, id.second)); - allcrawlers[id.first] = move(cr); + allcrawlers[id.first] = std::move(cr); uniq++; } } diff --git a/rogueviz/som/tests.cpp b/rogueviz/som/tests.cpp index 261927b0..f4579e20 100644 --- a/rogueviz/som/tests.cpp +++ b/rogueviz/som/tests.cpp @@ -97,7 +97,7 @@ void create_data() { where.push_back(c); sample s; embeddings::get_coordinates(s.val, c, c0); - data.push_back(move(s)); + data.push_back(std::move(s)); } samples = isize(data); test_orig.size = samples; diff --git a/surface.cpp b/surface.cpp index 2bca9180..a29a43a5 100644 --- a/surface.cpp +++ b/surface.cpp @@ -480,8 +480,8 @@ void run_kuen() { int it = 0; for(auto p: rug::points) p->dexp_id = it++; - vector mesh = move(rug::points); - vector old_triangles = move(rug::triangles); + vector mesh = std::move(rug::points); + vector old_triangles = std::move(rug::triangles); rug::clear_model(); diff --git a/textures.cpp b/textures.cpp index 5a747348..c52aed0e 100644 --- a/textures.cpp +++ b/textures.cpp @@ -979,7 +979,7 @@ string tes; void init_textureconfig() { #if CAP_CONFIG - texturesavers = move(savers); + texturesavers = std::move(savers); for(int i=0; i<3; i++) for(int j=0; j<3; j++) addsaver(config.itt[i][j], "texturematrix_" + its(i) + its(j), i==j ? 1 : 0); @@ -1131,10 +1131,10 @@ bool texture_config::load() { models::configure(); drawthemap(); config.tstate = config.tstate_max = tsActive; - string s = move(texture_tuner); + string s = std::move(texture_tuner); perform_mapping(); - texture_tuner = move(s); + texture_tuner = std::move(s); if(texture_tuner != "") { texture_tuned = true; @@ -1665,7 +1665,7 @@ void texture_config::true_remap() { if(GOLDBERG || IRREGULAR) pshift += si.dir; mapTexture(c, mi2, si, ggmatrix(c), pshift); mapTexture2(mi2); - mi2.tvertices = move(new_tvertices); + mi2.tvertices = std::move(new_tvertices); // printf("%08x remapping %d vertices to %d vertices\n", si.id, isize(mi.tvertices), isize(mi2.tvertices)); } catch(out_of_range&) { From dd55129ed36a5aeaf3e3b2ef909288cfcafd0766 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 13:09:24 -0400 Subject: [PATCH 3/8] Fix "extra ;" warnings on GCC --- rogueviz/gobot.cpp | 3 +-- rogueviz/presentation.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/rogueviz/gobot.cpp b/rogueviz/gobot.cpp index ef7fe285..18ee26da 100644 --- a/rogueviz/gobot.cpp +++ b/rogueviz/gobot.cpp @@ -610,8 +610,7 @@ auto gobot_hook = shot_state = 2; } return false; - }); - + }) ; #endif diff --git a/rogueviz/presentation.cpp b/rogueviz/presentation.cpp index 4f53394b..e18aff78 100644 --- a/rogueviz/presentation.cpp +++ b/rogueviz/presentation.cpp @@ -542,9 +542,8 @@ int runslide = arg::add3("-slides", [] { + arg::add3("-presangle", [] { arg::shift_arg_formula(angle); dir = 0; - }); + }) ; - } #endif } From 3c3f2b2b21c11bcb9542911c345e1ede95fbe4d4 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 13:13:17 -0400 Subject: [PATCH 4/8] Silence overzealous -Wunused-result warnings on GCC --- nonisotropic.cpp | 8 ++++---- rogueviz/presentation.cpp | 6 +++--- rogueviz/som/analyzer.cpp | 12 ++++++------ rogueviz/som/tests.cpp | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/nonisotropic.cpp b/nonisotropic.cpp index 3bbc0e36..793e763d 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -88,11 +88,11 @@ EX namespace sn { FILE *f = fopen(fname.c_str(), "rb"); if(!f) f = fopen((rsrcdir + fname).c_str(), "rb"); if(!f) { addMessage(XLAT("geodesic table missing")); pmodel = mdPerspective; return; } - ignore(fread(&PRECX, 4, 1, f)); - ignore(fread(&PRECY, 4, 1, f)); - ignore(fread(&PRECZ, 4, 1, f)); + hr::ignore(fread(&PRECX, 4, 1, f)); + hr::ignore(fread(&PRECY, 4, 1, f)); + hr::ignore(fread(&PRECZ, 4, 1, f)); tab.resize(PRECX * PRECY * PRECZ); - ignore(fread(&tab[0], sizeof(compressed_point) * PRECX * PRECY * PRECZ, 1, f)); + hr::ignore(fread(&tab[0], sizeof(compressed_point) * PRECX * PRECY * PRECZ, 1, f)); fclose(f); loaded = true; } diff --git a/rogueviz/presentation.cpp b/rogueviz/presentation.cpp index e18aff78..11e4ef21 100644 --- a/rogueviz/presentation.cpp +++ b/rogueviz/presentation.cpp @@ -160,7 +160,7 @@ string gen_latex(presmode mode, string s, int res) { string filename = format("latex-cache/%08X.png", hash); if(mode == pmStartAll) { if(!file_exists(filename)) { - system("mkdir latex-cache"); + hr::ignore(system("mkdir latex-cache")); FILE *f = fopen("latex-cache/rogueviz-latex.tex", "w"); fprintf(f, "\\documentclass[border=2pt]{standalone}\n" @@ -172,9 +172,9 @@ string gen_latex(presmode mode, string s, int res) { "\\end{varwidth}\n" "\\end{document}\n", s.c_str()); fclose(f); - system("cd latex-cache; pdflatex rogueviz-latex.tex"); + hr::ignore(system("cd latex-cache; pdflatex rogueviz-latex.tex")); string pngline = "cd latex-cache; pdftopng -r " + its(res) + " rogueviz-latex.pdf t"; - system(pngline.c_str()); + hr::ignore(system(pngline.c_str())); rename("latex-cache/t-000001.png", filename.c_str()); } } diff --git a/rogueviz/som/analyzer.cpp b/rogueviz/som/analyzer.cpp index 41dcf7f1..e2dacec4 100644 --- a/rogueviz/som/analyzer.cpp +++ b/rogueviz/som/analyzer.cpp @@ -36,13 +36,13 @@ void load_maniset(maniset& m, int scale) { m.names.push_back(buf); auto& md = m.mdata[buf]; int N, M; - fscanf(f, "%d%d", &N, &M); + hr::ignore(fscanf(f, "%d%d", &N, &M)); println(hlog, "reading ", buf, " of size ", N, " and ", M, " edges"); md.size = N; auto& ed = md.edges; for(int i=0; i Date: Tue, 5 Jul 2022 13:14:27 -0400 Subject: [PATCH 5/8] Fix -Wmisleading-indentation warning on Clang --- rogueviz/gobot.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rogueviz/gobot.cpp b/rogueviz/gobot.cpp index 18ee26da..96808e58 100644 --- a/rogueviz/gobot.cpp +++ b/rogueviz/gobot.cpp @@ -533,10 +533,9 @@ void go_menu() { else if(current.owner[i] != Free) owned_by[current.owner[i]]++; - shstream ss; - println(ss, "black: ", stones[0], " stones, ", owned_by[0], " area, ", current.captures[1], " prisoners"); - println(ss, "white: ", stones[1], " stones, ", owned_by[1], " area, ", current.captures[0], " prisoners"); - + shstream ss; + println(ss, "black: ", stones[0], " stones, ", owned_by[0], " area, ", current.captures[1], " prisoners"); + println(ss, "white: ", stones[1], " stones, ", owned_by[1], " area, ", current.captures[0], " prisoners"); dialog::addSelItem("play black", its(stones[0]), 'b'); dialog::add_action([] { try_to_play(mouse_label(), 0); }); From ad47db4240be99bfef46d33e8e9ec3e1427df27a Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 13:16:10 -0400 Subject: [PATCH 6/8] Suppress -Wchar-subscripts on Clang For example: ./rogueviz/platformer.cpp:388:14: error: array subscript is of type 'char' [-Werror,-Wchar-subscripts] if(keystate['3']) ^~~~ --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f37f5bde..867582c4 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ ifeq (${TOOLCHAIN},clang) CXXFLAGS_STD = -std=c++11 CXXFLAGS_EARLY += -fPIC CXXFLAGS_EARLY += -W -Wall -Wextra -Wsuggest-override -pedantic - CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option + CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-char-subscripts -Wno-unknown-warning-option CXXFLAGS_EARLY += -Wno-invalid-offsetof endif From 2ec10ff7f2392f7b032953ff2b782bdd4f7be03f Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 13:19:39 -0400 Subject: [PATCH 7/8] Fix -Wsuggest-override on Clang --- rogueviz/rewriting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rogueviz/rewriting.cpp b/rogueviz/rewriting.cpp index c1260b92..c77e0a6f 100644 --- a/rogueviz/rewriting.cpp +++ b/rogueviz/rewriting.cpp @@ -39,7 +39,7 @@ struct hrmap_rewrite : hrmap_hyperbolic { map > asg; map, heptagon*> asg_rev; - heptagon *create_step(heptagon *h, int direction) { + heptagon *create_step(heptagon *h, int direction) override { if(h->move(direction)) return h->move(direction); if(asg.empty()) { asg[h] = {h, start}; h->zebraval = 0; } From 1b8296a1f862da6b5c6fe2efb77ebfe2ec924c45 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Tue, 5 Jul 2022 14:14:53 -0400 Subject: [PATCH 8/8] Fix Clang error where lambdas can't capture structured bindings until C++20 ./rogueviz/nil-compass.cpp:98:10: error: reference to local binding 'i' declared in enclosing function 'rogueviz::nilcompass::draw_compass' if(i == _i && is == _is) return col; ^ --- rogueviz/nil-compass.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rogueviz/nil-compass.cpp b/rogueviz/nil-compass.cpp index 34d0d3cc..7fc95148 100644 --- a/rogueviz/nil-compass.cpp +++ b/rogueviz/nil-compass.cpp @@ -90,22 +90,22 @@ bool draw_compass(cell *c, const shiftmatrix& V) { } poly_outline = 0; - for(auto& [col, i, is, sh]: shapes) { + for(const auto& s: shapes) { ld t = 36 + (ticks - zeroticks) / 1000.; auto remap = [&] (int _i, int _is) { - if(i == _i && is == _is) return col; - int c = part(col, 1) + part(col, 2) + part(col, 3); + if(s.i == _i && s.is == _is) return col; + int c = part(s.col, 1) + part(s.col, 2) + part(s.col, 3); c += 1; c /= 12; - color_t col1 = col; + color_t col1 = s.col; part(col1, 1) = part(col1, 2) = part(col1, 3) = c; - return gradient(col, col1, 0, 0.9, 1); + return gradient(s.col, col1, 0, 0.9, 1); }; vector> clist = { - {36, col}, - {42.5, col}, + {36, s.col}, + {42.5, s.col}, {42.7, remap(1, -1)}, {43.9, remap(1, -1)}, {44.1, remap(0, +1)}, @@ -118,8 +118,8 @@ bool draw_compass(cell *c, const shiftmatrix& V) { {48.1, remap(2, -1)}, {48.3, remap(2, +1)}, {49.1, remap(2, +1)}, - {49.3, col}, - {99, col} + {49.3, s.col}, + {99, s.col} }; int step = 0; @@ -128,7 +128,7 @@ bool draw_compass(cell *c, const shiftmatrix& V) { auto t1 = ilerp(clist[step].first, clist[step+1].first, t); auto col1 = gradient(clist[step].second, clist[step+1].second, 0, smoothen(t1), 1); - queuepoly(V, sh, col1); + queuepoly(V, s.sh, col1); } return false;