threadsafety shall not warn about const vars (in C++11) (#2847)
threadsafety shall not warn about const vars (in C++11) For C++03 a new id threadsafety-const was created.
This commit is contained in:
parent
d7a8e25d92
commit
2fa837c716
|
@ -28,7 +28,7 @@ jobs:
|
||||||
- name: Install missing software on macos
|
- name: Install missing software on macos
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest'
|
||||||
run: |
|
run: |
|
||||||
brew install z3
|
brew install coreutils z3
|
||||||
|
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
@ -44,7 +44,7 @@ jobs:
|
||||||
make -j$(nproc) check
|
make -j$(nproc) check
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Unsigned char
|
- name: Build and test with Unsigned char
|
||||||
run: |
|
run: |
|
||||||
make clean
|
make clean
|
||||||
make -j$(nproc) CXXFLAGS=-funsigned-char testrunner
|
make -j$(nproc) CXXFLAGS=-funsigned-char testrunner
|
||||||
|
@ -67,6 +67,11 @@ jobs:
|
||||||
- name: Validate
|
- name: Validate
|
||||||
run: |
|
run: |
|
||||||
make -j$(nproc) validateCFG validatePlatforms
|
make -j$(nproc) validateCFG validatePlatforms
|
||||||
|
|
||||||
|
- name: Test addons
|
||||||
|
run: |
|
||||||
|
./cppcheck --addon=threadsafety addons/test/threadsafety
|
||||||
|
./cppcheck --addon=threadsafety --std=c++03 addons/test/threadsafety
|
||||||
|
|
||||||
- name: Build GUI on ubuntu
|
- name: Build GUI on ubuntu
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
@ -112,7 +117,7 @@ jobs:
|
||||||
qmake
|
qmake
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
|
||||||
- name: Fuzzer
|
- name: Build Fuzzer
|
||||||
run: |
|
run: |
|
||||||
g++ -fsyntax-only -std=c++11 -Ilib oss-fuzz/*.cpp
|
g++ -fsyntax-only -std=c++11 -Ilib oss-fuzz/*.cpp
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
struct Dummy {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
void func() {
|
||||||
|
static Dummy dummy;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
struct Dummy {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
void func() {
|
||||||
|
static const Dummy dummy;
|
||||||
|
}
|
|
@ -20,7 +20,8 @@ def checkstatic(data):
|
||||||
else:
|
else:
|
||||||
type = 'variable'
|
type = 'variable'
|
||||||
if var.isConst:
|
if var.isConst:
|
||||||
reportError(var.typeStartToken, 'warning', 'Local constant static ' + type + ' \'' + var.nameToken.str + '\', dangerous if it is initialized in parallel threads', 'threadsafety')
|
if data.standards.cpp == 'c++03':
|
||||||
|
reportError(var.typeStartToken, 'warning', 'Local constant static ' + type + ' \'' + var.nameToken.str + '\', dangerous if it is initialized in parallel threads', 'threadsafety-const')
|
||||||
else:
|
else:
|
||||||
reportError(var.typeStartToken, 'warning', 'Local static ' + type + ': ' + var.nameToken.str, 'threadsafety')
|
reportError(var.typeStartToken, 'warning', 'Local static ' + type + ': ' + var.nameToken.str, 'threadsafety')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue