build: enable -Wextra by default
Also delete redundant 'return 0' from configure code snippets.
Change-Id: Ie3618db4abece6fb2d8ec8b52b88e84b4eb3a5b0
Refs: #3293
diff --git a/.waf-tools/compiler-features.py b/.waf-tools/compiler-features.py
index 8389025..cf41970 100644
--- a/.waf-tools/compiler-features.py
+++ b/.waf-tools/compiler-features.py
@@ -73,7 +73,7 @@
STD_TO_STRING = '''
#include <string>
int
-main(int argc, char** argv)
+main()
{
std::string s = std::to_string(0);
s = std::to_string(0l);
@@ -85,7 +85,6 @@
s = std::to_string(0.0);
s = std::to_string(0.0l);
s.clear();
- return 0;
}
'''
@@ -107,7 +106,6 @@
v.insert(it, 2);
it = v.cend() - 1;
v.erase(it);
- return 0;
}
'''
diff --git a/.waf-tools/cryptopp.py b/.waf-tools/cryptopp.py
index bf49c04..a005123 100644
--- a/.waf-tools/cryptopp.py
+++ b/.waf-tools/cryptopp.py
@@ -40,7 +40,6 @@
StringSource(buffer, true, new HashFilter(hash, new FileSink(std::cout)));
StringSource(reinterpret_cast<const uint8_t*>(buffer.c_str()), buffer.size(),
true, new HashFilter(hash, new FileSink(std::cout)));
- return 0;
}
'''
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index f82fe10..9f15fcc 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -40,7 +40,7 @@
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
- conf.add_supported_cxxflags(extraFlags['LINKFLAGS'])
+ conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
conf.env.DEFINES += extraFlags['DEFINES']
@@ -83,15 +83,15 @@
class CompilerFlags(object):
def getGeneralFlags(self, conf):
- """Get dict {'CXXFLAGS':[...], LINKFLAGS:[...], DEFINES:[...]} that are always needed"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
def getDebugFlags(self, conf):
- """Get tuple {CXXFLAGS, LINKFLAGS, DEFINES} that are needed in debug mode"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
def getOptimizedFlags(self, conf):
- """Get tuple {CXXFLAGS, LINKFLAGS, DEFINES} that are needed in optimized mode"""
+ """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
class GccBasicFlags(CompilerFlags):
@@ -100,21 +100,25 @@
"""
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic',
- '-Wall',
- '-O0',
+ flags['CXXFLAGS'] += ['-O0',
'-g3',
+ '-pedantic',
+ '-Wall',
+ '-Wextra',
'-Werror',
+ '-Wno-unused-parameter',
'-Wno-error=maybe-uninitialized', # Bug #1615
]
return flags
def getOptimizedFlags(self, conf):
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
- flags['CXXFLAGS'] += ['-pedantic',
- '-Wall',
- '-O2',
+ flags['CXXFLAGS'] += ['-O2',
'-g',
+ '-pedantic',
+ '-Wall',
+ '-Wextra',
+ '-Wno-unused-parameter',
]
return flags
@@ -136,6 +140,9 @@
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (5, 1, 0):
+ flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
'-fdiagnostics-color', # gcc >= 4.9
]
@@ -143,6 +150,9 @@
def getOptimizedFlags(self, conf):
flags = super(GccFlags, self).getOptimizedFlags(conf)
+ version = tuple(int(i) for i in conf.env['CC_VERSION'])
+ if version < (5, 1, 0):
+ flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
return flags
diff --git a/.waf-tools/osx-security.py b/.waf-tools/osx-security.py
index 9bcb3a8..f7f273e 100644
--- a/.waf-tools/osx-security.py
+++ b/.waf-tools/osx-security.py
@@ -10,11 +10,7 @@
#include <Security/SecRandom.h>
#include <CoreServices/CoreServices.h>
#include <Security/SecDigestTransform.h>
-
-int main(int argc, char **argv) {
- (void)argc; (void)argv;
- return 0;
-}
+int main() {}
'''
@conf