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
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
brew install z3
|
||||
brew install coreutils z3
|
||||
|
||||
- name: Install Qt
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
@ -44,7 +44,7 @@ jobs:
|
|||
make -j$(nproc) check
|
||||
cd ..
|
||||
|
||||
- name: Unsigned char
|
||||
- name: Build and test with Unsigned char
|
||||
run: |
|
||||
make clean
|
||||
make -j$(nproc) CXXFLAGS=-funsigned-char testrunner
|
||||
|
@ -67,6 +67,11 @@ jobs:
|
|||
- name: Validate
|
||||
run: |
|
||||
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
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
@ -112,7 +117,7 @@ jobs:
|
|||
qmake
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Fuzzer
|
||||
- name: Build Fuzzer
|
||||
run: |
|
||||
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:
|
||||
type = 'variable'
|
||||
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:
|
||||
reportError(var.typeStartToken, 'warning', 'Local static ' + type + ': ' + var.nameToken.str, 'threadsafety')
|
||||
|
||||
|
|
Loading…
Reference in New Issue