Skip to content

Commit c1b6eb1

Browse files
authored
Merge pull request #1266 from danieldresser-ie/wextra
Match default compiler warning flags to Gaffer
2 parents 5325d99 + 0542c71 commit c1b6eb1

22 files changed

+74
-74
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
sleep 20
196196
# Print SCons logs and MacOS crash logs
197197
shopt -s nullglob
198-
for logFile in buildConfig.log ~/Library/Logs/DiagnosticReports/*.crash
198+
for logFile in config.log buildConfig.log ~/Library/Logs/DiagnosticReports/*.crash
199199
do
200200
echo $logFile
201201
cat $logFile

SConstruct

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ except NameError :
8181
o.Add(
8282
"CXX",
8383
"The C++ compiler.",
84-
"g++" if Environment()["PLATFORM"] != "win32" else "cl",
84+
{"darwin" : "clang++", "win32" : "cl"}.get(Environment()["PLATFORM"], "g++")
85+
8586
)
8687

8788
o.Add(
8889
"CXXFLAGS",
8990
"The extra flags to pass to the C++ compiler during compilation.",
90-
[ "-pipe", "-Wall" ] if Environment()["PLATFORM"] != "win32" else [],
91+
[ "-pipe", "-Wall", "-Wextra" ] if Environment()["PLATFORM"] != "win32" else [],
9192
)
9293

9394
o.Add(
@@ -1109,7 +1110,7 @@ if env["PLATFORM"] != "win32" :
11091110
env.Append( CXXFLAGS = [ "-Wno-unused-local-typedef", "-Wno-deprecated-declarations" ] )
11101111

11111112
elif env["PLATFORM"]=="posix" :
1112-
if "g++" in os.path.basename( env["CXX"] ) :
1113+
if "g++" in os.path.basename( env["CXX"] ) and not "clang++" in os.path.basename( env["CXX"] ) :
11131114
gccVersion = subprocess.check_output( [ env["CXX"], "-dumpversion" ], env=env["ENV"], universal_newlines=True )
11141115
gccVersion = gccVersion.strip()
11151116
gccVersion = [ int( v ) for v in gccVersion.split( "." ) ]
@@ -1119,7 +1120,12 @@ if env["PLATFORM"] != "win32" :
11191120
env.Append( CXXFLAGS = [ "-std=$CXXSTD", "-fvisibility=hidden" ] )
11201121

11211122
if "clang++" in os.path.basename( env["CXX"] ) :
1122-
env.Append( CXXFLAGS = ["-Wno-unused-local-typedef"] )
1123+
# Turn off the parts of `-Wall` and `-Wextra` that we don't like.
1124+
env.Append( CXXFLAGS = ["-Wno-unused-local-typedef", "-Wno-unused-parameter"] )
1125+
1126+
elif "g++" in os.path.basename( env["CXX"] ) :
1127+
# Turn off the parts of `-Wextra` that we don't like.
1128+
env.Append( CXXFLAGS = [ "-Wno-cast-function-type", "-Wno-unused-parameter" ] )
11231129

11241130
if env["ASAN"] :
11251131
env.Append(

config/ie/options

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pythonVersion = getOption( "PYTHON_VERSION", None )
6565
sixVersion = getOption( "SIX_VERSION", "1.14.0" )
6666
targetApp = getOption( "APP", None )
6767

68+
6869
# get cortex config information from the registry. if we have setting specific to this platform then use them, otherwise
6970
# fall back to the generic settings for this compatibility version.
7071

@@ -166,7 +167,7 @@ else :
166167
if not m :
167168
raise RuntimeError( "Cannot determine compiler version (%s)" % compilerVersion )
168169

169-
CXXFLAGS = [ "-pipe", "-Wall", "-pthread" ]
170+
CXXFLAGS = [ "-pipe", "-Wall", "-Wextra", "-pthread" ]
170171

171172
LINKFLAGS = []
172173

contrib/IECoreAlembic/src/IECoreAlembic/AlembicScene.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ class AlembicScene::AlembicReader : public AlembicIO
547547
scalarPropertyReader->getSample( sampleIndex, &value );
548548
return new IECore::Color4fData( C4f( value[0] / 255.0f, value[1] / 255.0f, value[2] / 255.0f, value[3] / 255.0f ) );
549549
}
550+
break;
550551
}
551552
case kInt8POD:
552553
{
@@ -597,6 +598,7 @@ class AlembicScene::AlembicReader : public AlembicIO
597598
default:
598599
break;
599600
}
601+
break;
600602
}
601603
case kUint32POD:
602604
{
@@ -641,6 +643,7 @@ class AlembicScene::AlembicReader : public AlembicIO
641643
default:
642644
break;
643645
}
646+
break;
644647
}
645648
case kUint64POD:
646649
{
@@ -680,6 +683,7 @@ class AlembicScene::AlembicReader : public AlembicIO
680683
return new IECore::Color4fData( C4f( value[0], value[1], value[2], value[3] ) );
681684
}
682685
}
686+
break;
683687
}
684688
case kFloat32POD:
685689
{
@@ -710,6 +714,7 @@ class AlembicScene::AlembicReader : public AlembicIO
710714
{
711715
return new IECore::Color3fData( C3f( value[0], value[1], value[2] ) );
712716
}
717+
break;
713718
}
714719
case 4:
715720
{
@@ -728,6 +733,7 @@ class AlembicScene::AlembicReader : public AlembicIO
728733
{
729734
return new IECore::Color4fData( C4f( tmpValue[0], tmpValue[1], tmpValue[2], tmpValue[3] ) );
730735
}
736+
break;
731737
}
732738
case 6:
733739
{
@@ -773,6 +779,7 @@ class AlembicScene::AlembicReader : public AlembicIO
773779
default:
774780
break;
775781
}
782+
break;
776783
}
777784
case kFloat64POD:
778785
{
@@ -808,6 +815,7 @@ class AlembicScene::AlembicReader : public AlembicIO
808815
{
809816
return new IECore::Box2dData( Box2d( V2d( tmpValue[0], tmpValue[1] ), V2d( tmpValue[2], tmpValue[3] ) ) );
810817
}
818+
break;
811819
}
812820
case 6:
813821
{
@@ -853,7 +861,7 @@ class AlembicScene::AlembicReader : public AlembicIO
853861
default:
854862
break;
855863
}
856-
864+
break;
857865
}
858866

859867
case kStringPOD:

contrib/IECoreAlembic/src/IECoreAlembic/CurvesReader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CubicBasisf convertBasis( const ICurvesSchema::Sample &sample )
6868
return CubicBasisf::bSpline();
6969
case kHermiteBasis :
7070
case kPowerBasis :
71+
default :
7172
IECore::msg( IECore::Msg::Warning, "CurvesAlgo::convert", "Unsupported basis" );
7273
return CubicBasisf::bSpline();
7374
}

include/IECore/InternedString.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ class IECORE_API InternedString
6666

6767
inline InternedString();
6868
inline InternedString( const std::string &value );
69-
inline InternedString( const InternedString &other );
7069
inline InternedString( const char *value );
7170
inline InternedString( const char *value, size_t length );
7271

72+
InternedString( const InternedString &other ) = default;
73+
InternedString &operator= ( const InternedString &rhs ) = default;
74+
~InternedString() = default;
75+
7376
#if BOOST_VERSION > 105500
7477

7578
inline InternedString( const boost::string_view &value );
@@ -78,8 +81,6 @@ class IECORE_API InternedString
7881

7982
inline InternedString( int64_t number );
8083

81-
inline ~InternedString();
82-
8384
// The equality operators are extremely fast because they
8485
// need only compare the address of the internal string,
8586
// because it was made unique upon construction.

include/IECore/InternedString.inl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ inline InternedString::InternedString( const std::string &value )
4848
{
4949
}
5050

51-
inline InternedString::InternedString( const InternedString &other )
52-
: m_value( other.m_value )
53-
{
54-
}
55-
5651
inline InternedString::InternedString( const char *value )
5752
: m_value( internedString( value ) )
5853
{
@@ -77,10 +72,6 @@ inline InternedString::InternedString( int64_t number )
7772
{
7873
}
7974

80-
inline InternedString::~InternedString()
81-
{
82-
}
83-
8475
inline bool InternedString::operator != ( const InternedString &other ) const
8576
{
8677
return m_value!=other.m_value;

include/IECore/MurmurHash.inl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,37 @@ inline void MurmurHash::appendRaw( const void *data, size_t bytes, int elementSi
125125
switch( bytes & 15)
126126
{
127127
case 15: k2 ^= uint64_t(tail[14]) << 48;
128+
[[fallthrough]];
128129
case 14: k2 ^= uint64_t(tail[13]) << 40;
130+
[[fallthrough]];
129131
case 13: k2 ^= uint64_t(tail[12]) << 32;
132+
[[fallthrough]];
130133
case 12: k2 ^= uint64_t(tail[11]) << 24;
134+
[[fallthrough]];
131135
case 11: k2 ^= uint64_t(tail[10]) << 16;
136+
[[fallthrough]];
132137
case 10: k2 ^= uint64_t(tail[ 9]) << 8;
138+
[[fallthrough]];
133139
case 9: k2 ^= uint64_t(tail[ 8]) << 0;
134-
k2 *= c2; k2 = rotl64(k2,33); k2 *= c1; h2 ^= k2;
140+
k2 *= c2; k2 = rotl64(k2,33); k2 *= c1; h2 ^= k2;
141+
[[fallthrough]];
135142

136143
case 8: k1 ^= uint64_t(tail[ 7]) << 56;
144+
[[fallthrough]];
137145
case 7: k1 ^= uint64_t(tail[ 6]) << 48;
146+
[[fallthrough]];
138147
case 6: k1 ^= uint64_t(tail[ 5]) << 40;
148+
[[fallthrough]];
139149
case 5: k1 ^= uint64_t(tail[ 4]) << 32;
150+
[[fallthrough]];
140151
case 4: k1 ^= uint64_t(tail[ 3]) << 24;
152+
[[fallthrough]];
141153
case 3: k1 ^= uint64_t(tail[ 2]) << 16;
154+
[[fallthrough]];
142155
case 2: k1 ^= uint64_t(tail[ 1]) << 8;
156+
[[fallthrough]];
143157
case 1: k1 ^= uint64_t(tail[ 0]) << 0;
144-
k1 *= c1; k1 = rotl64(k1,31); k1 *= c2; h1 ^= k1;
158+
k1 *= c1; k1 = rotl64(k1,31); k1 *= c2; h1 ^= k1;
145159
};
146160

147161
// finalisation

include/IECore/PathMatcher.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ class IECORE_API PathMatcher
6868
};
6969

7070
PathMatcher();
71-
/// Copy constructor. Uses lazy-copy-on-write so
72-
/// that copies are cheap until edited.
73-
PathMatcher( const PathMatcher &other );
71+
/// We use lazy-copy-on-write so that copies are cheap until edited.
72+
/// This means we can use default copy and assignment
73+
PathMatcher( const PathMatcher &other ) = default;
74+
PathMatcher& operator= ( const PathMatcher &other ) = default;
75+
~PathMatcher() = default;
7476

7577
template<typename PathIterator>
7678
PathMatcher( PathIterator pathsBegin, PathIterator pathsEnd );

include/IECore/StringAlgo.inl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ inline bool matchCharacterClass( char c, const char *&pattern )
7676
}
7777
continue;
7878
}
79-
else
80-
{
81-
// The '-' was at the start or end of the
82-
// pattern, fall through to treat it
83-
// as a regular character below.
84-
}
79+
80+
// The '-' was at the start or end of the
81+
// pattern, fall through to treat it
82+
// as a regular character below.
83+
[[fallthrough]];
8584
default :
8685
if( d == c )
8786
{
@@ -160,7 +159,7 @@ inline bool matchInternal( const char *s, const char *&pattern, bool spaceTermin
160159
return *s == '\0';
161160
}
162161
// Fall through to default
163-
162+
[[fallthrough]];
164163
default :
165164

166165
if( c != *s++ )

0 commit comments

Comments
 (0)