Skip to content

Commit c468a33

Browse files
author
Daniel Marjamäki
committed
Fix #678 workaround needed for gcc bug (old gcc), defaulted noexcept constructors
1 parent 36e6e12 commit c468a33

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

.github/workflows/gcc-versions.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# the purpose of this github action is to test that simplecpp source code can be compiled using old gcc versions.
2+
# the gcc images we use here are copied from the official gcc images on docker hub
3+
4+
name: gcc-versions
5+
6+
on:
7+
push:
8+
branches:
9+
- 'main'
10+
- 'releases/**'
11+
- '2.*'
12+
tags:
13+
- '2.*'
14+
pull_request:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
build:
21+
22+
strategy:
23+
matrix:
24+
#image: ["ghcr.io/cppcheck-opensource/gcc:5.4", "ghcr.io/cppcheck-opensource/gcc:6.5", "ghcr.io/cppcheck-opensource/gcc:7.5", "ghcr.io/cppcheck-opensource/gcc:8.5", "ghcr.io/cppcheck-opensource/gcc:9.5"]
25+
image: ["ghcr.io/cppcheck-opensource/gcc:5.4"]
26+
fail-fast: false
27+
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
persist-credentials: false
34+
35+
- name: Build cppcheck
36+
run: |
37+
docker run --rm -v ${{ github.workspace }}:/src -w /src ${{ matrix.image }} make -j$(nproc) CXXOPTS="-Werror" test

simplecpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,8 +3131,8 @@ simplecpp::FileDataCache::FileDataCache()
31313131
{}
31323132

31333133
simplecpp::FileDataCache::~FileDataCache() = default;
3134-
simplecpp::FileDataCache::FileDataCache(FileDataCache &&) noexcept = default;
3135-
simplecpp::FileDataCache &simplecpp::FileDataCache::operator=(simplecpp::FileDataCache &&) noexcept = default;
3134+
simplecpp::FileDataCache::FileDataCache(FileDataCache &&) SIMPLECPP_NOEXCEPT = default;
3135+
simplecpp::FileDataCache &simplecpp::FileDataCache::operator=(simplecpp::FileDataCache &&) SIMPLECPP_NOEXCEPT = default;
31363136

31373137
static bool getFileId(const std::string &path, FileID &id);
31383138

simplecpp.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@
6060
# endif
6161
#endif
6262

63+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 9
64+
// Hack to workaround GCC bug.
65+
// Details: https://trac.cppcheck.net/ticket/14850
66+
// seen on g++ before 10.x
67+
#define SIMPLECPP_NOEXCEPT
68+
#else
69+
#define SIMPLECPP_NOEXCEPT noexcept
70+
#endif
71+
6372
namespace simplecpp {
6473
/** C code standard */
6574
enum cstd_t : std::int8_t { CUnknown=-1, C89, C99, C11, C17, C23, C2Y };
@@ -454,10 +463,10 @@ namespace simplecpp {
454463
~FileDataCache();
455464

456465
FileDataCache(const FileDataCache &) = delete;
457-
FileDataCache(FileDataCache &&) noexcept;
466+
FileDataCache(FileDataCache &&) SIMPLECPP_NOEXCEPT;
458467

459468
FileDataCache &operator=(const FileDataCache &) = delete;
460-
FileDataCache &operator=(FileDataCache &&) noexcept;
469+
FileDataCache &operator=(FileDataCache &&) SIMPLECPP_NOEXCEPT;
461470

462471
/** Get the cached data for a file, or load and then return it if it isn't cached.
463472
* returns the file data and true if the file was loaded, false if it was cached. */

0 commit comments

Comments
 (0)