Skip to content

Commit

Permalink
Gcc7 no array bounds (AMReX-Codes#1196)
Browse files Browse the repository at this point in the history
* Wno-array-bounds for gcc 7

* [[gnu::fallthrought]] is available for gcc >= 7 only.  Test the result of dynamic_cast.
  • Loading branch information
WeiqunZhang authored and dwillcox committed Oct 3, 2020
1 parent baea153 commit 3ec71da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Src/Base/AMReX_Extension.H
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
#define AMREX_FALLTHROUGH [[fallthrough]]
#elif defined(__clang__)
#define AMREX_FALLTHROUGH [[clang::fallthrough]]
#elif defined(__GNUC__)
#elif defined(__GNUC__) && (__GNUC__ >= 7)
#define AMREX_FALLTHROUGH [[gnu::fallthrough]]
#else
#define AMREX_FALLTHROUGH ((void)0)
Expand Down
20 changes: 14 additions & 6 deletions Src/LinearSolvers/MLMG/AMReX_MLMG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,13 @@ MLMG::ResNormInf (int alev, bool local)
pmf = scratch[alev].get();
MultiFab::Copy(*pmf, res[alev][mglev], 0, 0, ncomp, 0);
auto factory = dynamic_cast<EBFArrayBoxFactory const*>(linop.Factory(alev));
const MultiFab& vfrac = factory->getVolFrac();
for (int n=0; n < ncomp; ++n) {
MultiFab::Multiply(*pmf, vfrac, 0, n, 1, 0);
if (factory) {
const MultiFab& vfrac = factory->getVolFrac();
for (int n=0; n < ncomp; ++n) {
MultiFab::Multiply(*pmf, vfrac, 0, n, 1, 0);
}
} else {
amrex::Abort("MLMG::ResNormInf: not EB Factory");
}
}
#endif
Expand Down Expand Up @@ -1067,9 +1071,13 @@ MLMG::MLRhsNormInf (bool local)
pmf = scratch[alev].get();
MultiFab::Copy(*pmf, rhs[alev], 0, 0, ncomp, 0);
auto factory = dynamic_cast<EBFArrayBoxFactory const*>(linop.Factory(alev));
const MultiFab& vfrac = factory->getVolFrac();
for (int n=0; n < ncomp; ++n) {
MultiFab::Multiply(*pmf, vfrac, 0, n, 1, 0);
if (factory) {
const MultiFab& vfrac = factory->getVolFrac();
for (int n=0; n < ncomp; ++n) {
MultiFab::Multiply(*pmf, vfrac, 0, n, 1, 0);
}
} else {
amrex::Abort("MLMG::MLRhsNormInf: not EB Factory");
}
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions Tools/GNUMake/comps/gnu.mak
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ ifeq ($(WARN_ALL),TRUE)
warning_flags += -Wshadow
endif

ifeq ($(gcc_major_version),7)
warning_flags += -Wno-array-bounds
endif

CXXFLAGS += $(warning_flags) -Woverloaded-virtual
CFLAGS += $(warning_flags)
endif
Expand Down

0 comments on commit 3ec71da

Please sign in to comment.