Enable -Wextra-semi and -Wextra-semi-stmt.
This will prevent users from accidentally making semicolon errors in
the future.
Bug: chromium:926235
Change-Id: I79a6fa376fb1ad8f0fcf1b65b1f572a035d1f4e9
Reviewed-on: https://chromium-review.googlesource.com/c/1446493
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp
index 429026e..2ce67b7 100644
--- a/src/compiler/preprocessor/Tokenizer.cpp
+++ b/src/compiler/preprocessor/Tokenizer.cpp
@@ -700,6 +700,8 @@
#if defined(__clang__)
// Flex uses `/*FALLTHROUGH*/` instead of dedicated statements.
# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+// Flex isn't semi-colon clean.
+# pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
// Workaround for flex using the register keyword, deprecated in C++11.
diff --git a/src/compiler/preprocessor/Tokenizer.l b/src/compiler/preprocessor/Tokenizer.l
index 3df7367..94db185 100644
--- a/src/compiler/preprocessor/Tokenizer.l
+++ b/src/compiler/preprocessor/Tokenizer.l
@@ -41,6 +41,8 @@
#if defined(__clang__)
// Flex uses `/*FALLTHROUGH*/` instead of dedicated statements.
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+// Flex isn't semi-colon clean.
+#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
// Workaround for flex using the register keyword, deprecated in C++11.
diff --git a/src/compiler/translator/Common.h b/src/compiler/translator/Common.h
index 925bcfe..d0b8347 100644
--- a/src/compiler/translator/Common.h
+++ b/src/compiler/translator/Common.h
@@ -34,7 +34,7 @@
//
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
//
-#define POOL_ALLOCATOR_NEW_DELETE() \
+#define POOL_ALLOCATOR_NEW_DELETE \
void *operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \
void *operator new(size_t, void *_Where) { return (_Where); } \
void operator delete(void *) {} \
@@ -65,7 +65,7 @@
class TVector : public std::vector<T, pool_allocator<T>>
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
typedef typename std::vector<T, pool_allocator<T>>::size_type size_type;
TVector() : std::vector<T, pool_allocator<T>>() {}
@@ -77,7 +77,7 @@
class TUnorderedMap : public std::unordered_map<K, D, H, CMP, pool_allocator<std::pair<const K, D>>>
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
typedef pool_allocator<std::pair<const K, D>> tAllocator;
TUnorderedMap() : std::unordered_map<K, D, H, CMP, tAllocator>() {}
@@ -93,7 +93,7 @@
class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<const K, D>>>
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
typedef pool_allocator<std::pair<const K, D>> tAllocator;
TMap() : std::map<K, D, CMP, tAllocator>() {}
diff --git a/src/compiler/translator/Compiler.h b/src/compiler/translator/Compiler.h
index 86590b3..2227819 100644
--- a/src/compiler/translator/Compiler.h
+++ b/src/compiler/translator/Compiler.h
@@ -146,7 +146,8 @@
protected:
// Add emulated functions to the built-in function emulator.
virtual void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu,
- ShCompileOptions compileOptions){};
+ ShCompileOptions compileOptions)
+ {}
// Translate to object code. May generate performance warnings through the diagnostics.
virtual void translate(TIntermBlock *root,
ShCompileOptions compileOptions,
diff --git a/src/compiler/translator/ConstantUnion.h b/src/compiler/translator/ConstantUnion.h
index 6dab5be..155fcd4 100644
--- a/src/compiler/translator/ConstantUnion.h
+++ b/src/compiler/translator/ConstantUnion.h
@@ -20,7 +20,7 @@
class TConstantUnion
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TConstantUnion();
bool cast(TBasicType newType, const TConstantUnion &constant);
diff --git a/src/compiler/translator/Declarator.h b/src/compiler/translator/Declarator.h
index 7801b65..5b5d26b 100644
--- a/src/compiler/translator/Declarator.h
+++ b/src/compiler/translator/Declarator.h
@@ -19,7 +19,7 @@
class TDeclarator : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TDeclarator(const ImmutableString &name, const TSourceLoc &line);
TDeclarator(const ImmutableString &name,
diff --git a/src/compiler/translator/FunctionLookup.h b/src/compiler/translator/FunctionLookup.h
index bebe09a..62b07f2 100644
--- a/src/compiler/translator/FunctionLookup.h
+++ b/src/compiler/translator/FunctionLookup.h
@@ -19,7 +19,7 @@
class TFunctionLookup : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
static TFunctionLookup *CreateConstructor(const TType *type);
static TFunctionLookup *CreateFunctionCall(const ImmutableString &name, const TSymbol *symbol);
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 1ebe6aa..f460174 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -194,11 +194,14 @@
}
#define REPLACE_IF_IS(node, type, original, replacement) \
- if (node == original) \
+ do \
{ \
- node = static_cast<type *>(replacement); \
- return true; \
- }
+ if (node == original) \
+ { \
+ node = static_cast<type *>(replacement); \
+ return true; \
+ } \
+ } while (0)
size_t TIntermSymbol::getChildCount() const
{
diff --git a/src/compiler/translator/IntermNode.h b/src/compiler/translator/IntermNode.h
index 66d434e..2380599 100644
--- a/src/compiler/translator/IntermNode.h
+++ b/src/compiler/translator/IntermNode.h
@@ -68,7 +68,7 @@
class TIntermNode : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TIntermNode()
{
// TODO: Move this to TSourceLoc constructor
diff --git a/src/compiler/translator/ParseContext_autogen.h b/src/compiler/translator/ParseContext_autogen.h
index add5aee..f5eafd8 100644
--- a/src/compiler/translator/ParseContext_autogen.h
+++ b/src/compiler/translator/ParseContext_autogen.h
@@ -2,7 +2,7 @@
// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
// builtin_function_declarations.txt.
//
-// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
diff --git a/src/compiler/translator/QualifierTypes.h b/src/compiler/translator/QualifierTypes.h
index 071093a..950ba5f 100644
--- a/src/compiler/translator/QualifierTypes.h
+++ b/src/compiler/translator/QualifierTypes.h
@@ -34,9 +34,9 @@
class TQualifierWrapperBase : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TQualifierWrapperBase(const TSourceLoc &line) : mLine(line) {}
- virtual ~TQualifierWrapperBase(){};
+ virtual ~TQualifierWrapperBase() {}
virtual TQualifierType getType() const = 0;
virtual ImmutableString getQualifierString() const = 0;
virtual unsigned int getRank() const = 0;
@@ -176,7 +176,7 @@
using QualifierSequence = TVector<const TQualifierWrapperBase *>;
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TTypeQualifierBuilder(const TStorageQualifierWrapper *scope, int shaderVersion);
// Adds the passed qualifier to the end of the sequence.
void appendQualifier(const TQualifierWrapperBase *qualifier);
diff --git a/src/compiler/translator/ShaderStorageBlockFunctionHLSL.cpp b/src/compiler/translator/ShaderStorageBlockFunctionHLSL.cpp
index 60535fe..01b246d 100644
--- a/src/compiler/translator/ShaderStorageBlockFunctionHLSL.cpp
+++ b/src/compiler/translator/ShaderStorageBlockFunctionHLSL.cpp
@@ -409,7 +409,6 @@
out << ssboFunction.typeString << " " << ssboFunction.functionName
<< "(RWByteAddressBuffer buffer, uint loc, " << ssboFunction.typeString
<< " value)\n";
- ;
out << "{\n";
OutputSSBOAtomicMemoryFunctionBody(out, ssboFunction);
@@ -420,7 +419,6 @@
out << ssboFunction.typeString << " " << ssboFunction.functionName
<< "(RWByteAddressBuffer buffer, uint loc, " << ssboFunction.typeString
<< " compare_value, " << ssboFunction.typeString << " value)\n";
- ;
out << "{\n";
OutputSSBOAtomicMemoryFunctionBody(out, ssboFunction);
break;
diff --git a/src/compiler/translator/ShaderStorageBlockOutputHLSL.h b/src/compiler/translator/ShaderStorageBlockOutputHLSL.h
index caceca3..2ef2364 100644
--- a/src/compiler/translator/ShaderStorageBlockOutputHLSL.h
+++ b/src/compiler/translator/ShaderStorageBlockOutputHLSL.h
@@ -22,7 +22,7 @@
struct TReferencedBlock : angle::NonCopyable
{
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TReferencedBlock(const TInterfaceBlock *block, const TVariable *instanceVariable);
const TInterfaceBlock *block;
const TVariable *instanceVariable; // May be nullptr if the block is not instanced.
diff --git a/src/compiler/translator/StructureHLSL.h b/src/compiler/translator/StructureHLSL.h
index 4d490eb..ba4a8d1 100644
--- a/src/compiler/translator/StructureHLSL.h
+++ b/src/compiler/translator/StructureHLSL.h
@@ -67,7 +67,7 @@
struct TStructProperties : public angle::NonCopyable
{
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TStructProperties() {}
diff --git a/src/compiler/translator/Symbol.h b/src/compiler/translator/Symbol.h
index ab8a2af..3b74a0b 100644
--- a/src/compiler/translator/Symbol.h
+++ b/src/compiler/translator/Symbol.h
@@ -24,7 +24,7 @@
class TSymbol : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TSymbol(TSymbolTable *symbolTable,
const ImmutableString &name,
SymbolType symbolType,
diff --git a/src/compiler/translator/SymbolTable_autogen.cpp b/src/compiler/translator/SymbolTable_autogen.cpp
index 47d1545..1ab25b2 100644
--- a/src/compiler/translator/SymbolTable_autogen.cpp
+++ b/src/compiler/translator/SymbolTable_autogen.cpp
@@ -2,7 +2,7 @@
// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
// builtin_function_declarations.txt.
//
-// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -2194,7 +2194,7 @@
return &kVar_gl_WorkGroupSize;
}
-}; // namespace BuiltInVariable
+} // namespace BuiltInVariable
namespace BuiltInParameters
{
@@ -7347,7 +7347,7 @@
BuiltInId::texture_USamplerCube1_Float3,
BuiltInName::texture,
TExtension::UNDEFINED,
- BuiltInParameters::p0Y2B2B2B,
+ BuiltInParameters::p0Y2B0B,
2,
StaticType::Get<EbtUInt, EbpUndefined, EvqGlobal, 4, 1>(),
EOpCallBuiltInFunction,
@@ -9624,7 +9624,7 @@
BuiltInId::textureGather_USamplerCube1_Float3,
BuiltInName::textureGather,
TExtension::UNDEFINED,
- BuiltInParameters::p0Y2B2B2B,
+ BuiltInParameters::p0Y2B0B,
2,
StaticType::Get<EbtUInt, EbpUndefined, EvqGlobal, 4, 1>(),
EOpCallBuiltInFunction,
diff --git a/src/compiler/translator/SymbolTable_autogen.h b/src/compiler/translator/SymbolTable_autogen.h
index bb8a415..2168743 100644
--- a/src/compiler/translator/SymbolTable_autogen.h
+++ b/src/compiler/translator/SymbolTable_autogen.h
@@ -2,7 +2,7 @@
// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
// builtin_function_declarations.txt.
//
-// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
diff --git a/src/compiler/translator/SymbolUniqueId.h b/src/compiler/translator/SymbolUniqueId.h
index c9b7648..7d0979e 100644
--- a/src/compiler/translator/SymbolUniqueId.h
+++ b/src/compiler/translator/SymbolUniqueId.h
@@ -19,7 +19,7 @@
class TSymbolUniqueId
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
explicit TSymbolUniqueId(const TSymbol &symbol);
constexpr TSymbolUniqueId(const TSymbolUniqueId &) = default;
TSymbolUniqueId &operator =(const TSymbolUniqueId &);
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index 7491edf..e6bfd1c 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -30,7 +30,7 @@
class TField : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TField(TType *type, const ImmutableString &name, const TSourceLoc &line, SymbolType symbolType)
: mType(type), mName(name), mLine(line), mSymbolType(symbolType)
{
@@ -91,7 +91,7 @@
class TType
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TType();
explicit TType(TBasicType t, unsigned char ps = 1, unsigned char ss = 1);
TType(TBasicType t,
diff --git a/src/compiler/translator/builtin_symbols_hash_autogen.txt b/src/compiler/translator/builtin_symbols_hash_autogen.txt
index b79f34f..50754b5 100644
--- a/src/compiler/translator/builtin_symbols_hash_autogen.txt
+++ b/src/compiler/translator/builtin_symbols_hash_autogen.txt
@@ -1 +1 @@
-87bb6e2c1015c9e9aaf2a89e1595cd30
\ No newline at end of file
+c0555364e16391744b56e1f5d9c614c0
\ No newline at end of file
diff --git a/src/compiler/translator/gen_builtin_symbols.py b/src/compiler/translator/gen_builtin_symbols.py
index 765a802..e519391 100644
--- a/src/compiler/translator/gen_builtin_symbols.py
+++ b/src/compiler/translator/gen_builtin_symbols.py
@@ -187,7 +187,7 @@
{get_variable_definitions}
-}}; // namespace BuiltInVariable
+}} // namespace BuiltInVariable
namespace BuiltInParameters
{{
diff --git a/src/compiler/translator/glslang.l b/src/compiler/translator/glslang.l
index c6aa91d..8af29a8 100644
--- a/src/compiler/translator/glslang.l
+++ b/src/compiler/translator/glslang.l
@@ -40,6 +40,8 @@
#endif
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+// Flex isn't semi-colon clean.
+#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
}
diff --git a/src/compiler/translator/glslang.y b/src/compiler/translator/glslang.y
index 262db79..5d113e3 100644
--- a/src/compiler/translator/glslang.y
+++ b/src/compiler/translator/glslang.y
@@ -123,41 +123,41 @@
} \
} while (0)
-#define VERTEX_ONLY(S, L) { \
+#define VERTEX_ONLY(S, L) do { \
if (context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex shaders only", S); \
} \
-}
+} while (0)
-#define COMPUTE_ONLY(S, L) { \
+#define COMPUTE_ONLY(S, L) do { \
if (context->getShaderType() != GL_COMPUTE_SHADER) { \
context->error(L, " supported in compute shaders only", S); \
} \
-}
+} while (0)
#define ES2_ONLY(S, L) { \
- if (context->getShaderVersion() != 100) { \
+ if (context->getShaderVersion() != 100) do { \
context->error(L, " supported in GLSL ES 1.00 only", S); \
} \
-}
+} while (0)
-#define ES3_OR_NEWER(TOKEN, LINE, REASON) { \
+#define ES3_OR_NEWER(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() < 300) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \
-}
+} while (0)
-#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \
+#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview)) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \
-}
+} while (0)
-#define ES3_1_ONLY(TOKEN, LINE, REASON) { \
+#define ES3_1_ONLY(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() != 310) { \
context->error(LINE, REASON " supported in GLSL ES 3.10 only", TOKEN); \
} \
-}
+} while (0)
%}
%token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
diff --git a/src/compiler/translator/glslang_lex.cpp b/src/compiler/translator/glslang_lex.cpp
index 01d59a6..860eb3f 100644
--- a/src/compiler/translator/glslang_lex.cpp
+++ b/src/compiler/translator/glslang_lex.cpp
@@ -25,6 +25,8 @@
#endif
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+// Flex isn't semi-colon clean.
+#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#endif
diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp
index ae76e36..d26de9a 100644
--- a/src/compiler/translator/glslang_tab.cpp
+++ b/src/compiler/translator/glslang_tab.cpp
@@ -392,41 +392,41 @@
} \
} while (0)
-#define VERTEX_ONLY(S, L) { \
+#define VERTEX_ONLY(S, L) do { \
if (context->getShaderType() != GL_VERTEX_SHADER) { \
context->error(L, " supported in vertex shaders only", S); \
} \
-}
+} while (0)
-#define COMPUTE_ONLY(S, L) { \
+#define COMPUTE_ONLY(S, L) do { \
if (context->getShaderType() != GL_COMPUTE_SHADER) { \
context->error(L, " supported in compute shaders only", S); \
} \
-}
+} while (0)
-#define ES2_ONLY(S, L) { \
+#define ES2_ONLY(S, L) do { \
if (context->getShaderVersion() != 100) { \
context->error(L, " supported in GLSL ES 1.00 only", S); \
} \
-}
+} while (0)
-#define ES3_OR_NEWER(TOKEN, LINE, REASON) { \
+#define ES3_OR_NEWER(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() < 300) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \
-}
+} while (0)
-#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) { \
+#define ES3_OR_NEWER_OR_MULTIVIEW(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() < 300 && !context->isExtensionEnabled(TExtension::OVR_multiview)) { \
context->error(LINE, REASON " supported in GLSL ES 3.00 and above only", TOKEN); \
} \
-}
+} while (0)
-#define ES3_1_ONLY(TOKEN, LINE, REASON) { \
+#define ES3_1_ONLY(TOKEN, LINE, REASON) do { \
if (context->getShaderVersion() != 310) { \
context->error(LINE, REASON " supported in GLSL ES 3.10 only", TOKEN); \
} \
-}
+} while (0)
diff --git a/src/compiler/translator/tree_util/BuiltIn_autogen.h b/src/compiler/translator/tree_util/BuiltIn_autogen.h
index 510092b..65b1ba7 100644
--- a/src/compiler/translator/tree_util/BuiltIn_autogen.h
+++ b/src/compiler/translator/tree_util/BuiltIn_autogen.h
@@ -2,7 +2,7 @@
// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
// builtin_function_declarations.txt.
//
-// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
diff --git a/src/compiler/translator/tree_util/IntermTraverse.h b/src/compiler/translator/tree_util/IntermTraverse.h
index 094261a..30687a4 100644
--- a/src/compiler/translator/tree_util/IntermTraverse.h
+++ b/src/compiler/translator/tree_util/IntermTraverse.h
@@ -33,7 +33,7 @@
class TIntermTraverser : angle::NonCopyable
{
public:
- POOL_ALLOCATOR_NEW_DELETE();
+ POOL_ALLOCATOR_NEW_DELETE
TIntermTraverser(bool preVisit,
bool inVisit,
bool postVisit,