Skip to content

Commit 4614fe5

Browse files
authored
No more warnings (#124)
* No more warnings * Shut up, clang * Silence Clang also in Release mode
1 parent 6f59311 commit 4614fe5

25 files changed

+88
-76
lines changed

cmake/custom/compilers/CXXFlags.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
2424
"-Wuninitialized"
2525
"-Wmissing-declarations"
2626
"-Wwrite-strings"
27-
"-Weffc++"
2827
"-Wno-sign-compare"
28+
"-Wno-implicit-fallthrough"
29+
"-Wno-missing-field-initializers"
2930
)
3031
list(APPEND XCFun_CXX_FLAGS_RELEASE
3132
"-O3"
@@ -54,16 +55,20 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
5455
"-Wuninitialized"
5556
"-Wmissing-declarations"
5657
"-Wwrite-strings"
57-
"-Weffc++"
58-
"-Wdocumentation"
5958
"-Wno-sign-compare"
59+
"-Wno-implicit-fallthrough"
60+
"-Wno-missing-field-initializers"
61+
"-Wno-undefined-var-template"
6062
)
6163
list(APPEND XCFun_CXX_FLAGS_RELEASE
6264
"-O3"
6365
"-ffast-math"
6466
"-funroll-loops"
6567
"-ftree-vectorize"
6668
"-Wno-unused"
69+
"-Wno-implicit-fallthrough"
70+
"-Wno-missing-field-initializers"
71+
"-Wno-undefined-var-template"
6772
)
6873
endif()
6974

src/XCFunctional.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ int xcfun_test() {
8080
fun, fd->test_vars, fd->test_mode, fd->test_order)) == 0) {
8181
int n = xcfun_output_length(fun);
8282
auto out = new double[n];
83-
if (!fd->test_in)
83+
if (fd->test_in.empty())
8484
xcfun::die("Functional has no test input!", f);
85-
xcfun_eval(fun, fd->test_in, out);
85+
xcfun_eval(fun, fd->test_in.data(), out);
8686
int nerr = 0;
8787
for (auto i = 0; i < n; ++i)
8888
if (std::abs(out[i] - fd->test_out[i]) >

src/XCFunctional.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct XCFunctional {
3232
xcfun_mode mode{XC_MODE_UNSET};
3333
xcfun_vars vars{XC_VARS_UNSET};
3434
std::array<functional_data *, XC_NR_FUNCTIONALS> active_functionals{{nullptr}};
35-
std::array<double, XC_NR_PARAMETERS_AND_FUNCTIONALS> settings;
35+
std::array<double, XC_NR_PARAMETERS_AND_FUNCTIONALS> settings{{0.0}};
3636
};
3737

3838
namespace xcfun {

src/config.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ typedef qd_real ireal_t;
4949
#define XCFUN_NUM_CONVERT // Must convert real types at i/o
5050
#define INNER_TO_OUTER(INNER) to_double(INNER)
5151
#endif
52+
53+
typedef ireal_t parameter;

src/densvars.hpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,29 @@ template <typename T> struct densvars {
217217
b_43 = pow(b, 4.0 / 3.0);
218218
}
219219

220-
const XCFunctional * parent;
220+
const XCFunctional * parent{nullptr};
221221
double get_param(enum xc_parameter p) const { return parent->settings[p]; }
222222

223-
T a, b, gaa, gab, gbb;
224-
/* na+nb, na-nb, (grad n)^2, (grad n).(grad s), (grad s)^2 */
225-
T n, s, gnn, gns, gss;
226-
227-
T tau, taua, taub; // Kinetic energy densities.
228-
229-
T lapa, lapb; // Density Laplacians
230-
231-
T zeta; // s/n
232-
T r_s; // (3/4pi)^1/3*n^(-1/3)
233-
T n_m13; // pow(n,-1.0/3.0)
234-
T a_43, b_43; // pow(a,4.0/3.0), pow(b,4.0/3.0)
235-
236-
T jpaa, jpbb; // square of the alpha and beta paramagnetic current vectors.
223+
T a{static_cast<T>(0)};
224+
T b{static_cast<T>(0)};
225+
T gaa{static_cast<T>(0)};
226+
T gab{static_cast<T>(0)};
227+
T gbb{static_cast<T>(0)};
228+
T n{static_cast<T>(0)}; /// na+nb
229+
T s{static_cast<T>(0)}; /// na - nb
230+
T gnn{static_cast<T>(0)}; /// (grad n) ^ 2
231+
T gns{static_cast<T>(0)}; /// (grad n).(grad s)
232+
T gss{static_cast<T>(0)}; /// (grad s) ^ 2
233+
T tau{static_cast<T>(0)}; /// Kinetic energy density.
234+
T taua{static_cast<T>(0)}; /// Alpha kinetic energy density.
235+
T taub{static_cast<T>(0)}; /// Beta kinetic energy density.
236+
T lapa{static_cast<T>(0)}; /// Alpha Laplacian density.
237+
T lapb{static_cast<T>(0)}; /// Beta Laplacian density.
238+
T zeta{static_cast<T>(0)}; /// s/n
239+
T r_s{static_cast<T>(0)}; /// (3/4pi)^1/3*n^(-1/3)
240+
T n_m13{static_cast<T>(0)}; /// pow(n,-1.0/3.0)
241+
T a_43{static_cast<T>(0)};
242+
T b_43{static_cast<T>(0)}; /// pow(a,4.0/3.0), pow(b,4.0/3.0)
243+
T jpaa{static_cast<T>(0)}; /// square of the alpha paramagnetic current vector.
244+
T jpbb{static_cast<T>(0)}; /// square of the beta paramagnetic current vector.
237245
};

src/functionals/apbec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ template <typename num> static num phi(const densvars<num> & d) {
2222
}
2323

2424
template <typename num> static num energy(const densvars<num> & d) {
25-
using xc_constants::param_gamma;
25+
using xcfun_constants::param_gamma;
2626
const parameter beta = 0.079030523241;
2727
num bg = beta / param_gamma;
2828
num eps = pw92eps::pw92eps(d);

src/functionals/constants.hpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,25 @@
1414

1515
#pragma once
1616

17-
#include "functional.hpp"
17+
#include <cmath>
1818

19-
#ifndef M_PI // M_PI is not standard for some reason
20-
#define M_PI 3.14159265358979323846
21-
#endif
19+
#include "config.hpp"
2220

2321
#ifndef PI
24-
#define PI 3.14159265358979323846
22+
constexpr auto PI = M_PI;
2523
#endif
2624

2725
#ifndef PI2
28-
#define PI2 (M_PI * M_PI)
26+
constexpr auto PI2 = (M_PI * M_PI);
2927
#endif
3028

31-
namespace xc_constants {
29+
namespace xcfun_constants {
3230
const parameter c_slater = pow(81 / (32 * M_PI), 1.0 / 3.0); // Typically called C_x
33-
const parameter CF = 0.3 * pow(3 * M_PI * M_PI, 2.0 / 3.0);
31+
const parameter CF = 0.3 * pow(3 * PI2, 2.0 / 3.0);
3432

3533
// PBE constants.
36-
const parameter param_gamma = (1 - log(2.0)) / (M_PI * M_PI);
37-
const parameter param_beta_pbe_paper = 0.066725;
38-
const parameter param_beta_accurate = 0.06672455060314922;
34+
const parameter param_gamma = (1 - log(2.0)) / (PI2);
35+
constexpr parameter param_beta_pbe_paper = 0.066725;
36+
constexpr parameter param_beta_accurate = 0.06672455060314922;
3937
const parameter param_beta_gamma = param_beta_accurate / param_gamma;
40-
} // namespace xc_constants
38+
} // namespace xcfun_constants

src/functionals/list_of_functionals.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#pragma once
1616

17-
enum xc_functional_id {
17+
enum xcfun_functional_id {
1818
XC_SLATERX,
1919
XC_PW86X,
2020
XC_VWN3C,

src/functionals/lypc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ template <typename num> static num lypc(const densvars<num> & d) {
2020
const parameter B = 0.132;
2121
const parameter C = 0.2533;
2222
const parameter Dd = 0.349;
23-
using xc_constants::CF;
23+
using xcfun_constants::CF;
2424
num icbrtn = pow(d.n, -1.0 / 3.0);
2525
num P = 1 / (1 + Dd * icbrtn);
2626
num omega = exp(-C * icbrtn) * P * pow(d.n, -11.0 / 3.0);

src/functionals/m0xy_fun.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
#pragma once
1616

17+
#include <cstdio>
18+
1719
#include "pw92eps.hpp"
1820
#include "pw9xx.hpp"
19-
#include <stdio.h>
2021

21-
// common functions for MO5 and M06 family of (hybrid) meta-gga functionals
22+
// common functions for M05 and M06 family of (hybrid) meta-gga functionals
2223

2324
namespace m0xy_metagga_xc_internal {
2425

@@ -61,7 +62,7 @@ const parameter scalefactorTFconst = 3.17480210393640;
6162
// which was used as benchmark here for energy and first derivatives.
6263

6364
template <typename num> static num zet(const num & rho, const num & tau) {
64-
using xc_constants::CF;
65+
using xcfun_constants::CF;
6566

6667
return 2 * tau / pow(rho, 5.0 / 3.0) - CF * scalefactorTFconst;
6768
}
@@ -140,7 +141,7 @@ template <typename num>
140141
static num Dsigma(const num & na, const num & gaa, const num & taua)
141142
// static num Dsigma(const num &chi2, const num &zet)
142143
{
143-
// using xc_constants::CF;
144+
// using xcfun_constants::CF;
144145

145146
// return (1.0 - 0.25*chi2/(zet + CF*scalefactorTFconst));
146147
// Idiotic to subtract the constant (inside zet) and then add it back again
@@ -233,7 +234,7 @@ static num m05_c_anti(const parameter param_c[5],
233234
template <typename num>
234235
static num m05_c_para(const parameter param_c[5],
235236
const num & chi2,
236-
const num & zet,
237+
const num & /* zet */,
237238
const num & Dsigma) {
238239
// this is an "universal" constant for all M05/M06 functionals
239240
const parameter gamma_c_parallel = 0.06;

0 commit comments

Comments
 (0)