From 51c775a5df70fe5a538c3e4bcccd3ab857ba5b59 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Jan 2017 12:27:40 +0200 Subject: [PATCH] Fix some clang compile warnings --- source/batch.cpp | 2 +- source/gl.h | 3 +++ source/mesh.cpp | 2 +- source/programbuilder.cpp | 18 +++++++++--------- source/programcompiler.h | 17 +++++++++++++++++ source/programsyntax.h | 1 + source/resourcemanager.cpp | 6 +++--- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/source/batch.cpp b/source/batch.cpp index 3d7dfc72..cba63567 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -64,7 +64,7 @@ Batch::Batch(PrimitiveType t): /* Make sure we have glEnable/DisableClientState to go with NV_primitive_restart */ if(!MSP_primitive_restart && NV_primitive_restart) - (bool)MSP_legacy_features; + (void)(bool)MSP_legacy_features; } Batch::~Batch() diff --git a/source/gl.h b/source/gl.h index f7cba6b7..d558706c 100644 --- a/source/gl.h +++ b/source/gl.h @@ -2,10 +2,13 @@ #define MSP_GL_GL_H_ #ifdef __APPLE__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wkeyword-macro" #define extern extern __attribute__((weak_import)) #include #include #undef extern +#pragma clang diagnostic pop #elif defined(__ANDROID__) #include #include diff --git a/source/mesh.cpp b/source/mesh.cpp index 55d7fc06..8c1e79c4 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -275,7 +275,7 @@ Mesh::AsyncLoader::AsyncLoader(Mesh &m, IO::Seekable &i): phase(0) { // Make sure the extension is initialized in the rendering thread. - (bool)NV_primitive_restart; + (void)(bool)NV_primitive_restart; mesh.disallow_rendering = true; if(mesh.defer_buffers) diff --git a/source/programbuilder.cpp b/source/programbuilder.cpp index e4739da0..247c249b 100644 --- a/source/programbuilder.cpp +++ b/source/programbuilder.cpp @@ -893,7 +893,7 @@ void ProgramBuilder::ShaderVariable::resolve_space(const string &space) (*i)->resolve_space(space); } -void ProgramBuilder::ShaderVariable::resolve_array(const StandardFeatures &features, unsigned size_hint) +void ProgramBuilder::ShaderVariable::resolve_array(const StandardFeatures &feat, unsigned size_hint) { if(array_size) return; @@ -910,9 +910,9 @@ void ProgramBuilder::ShaderVariable::resolve_array(const StandardFeatures &featu if(variable && variable->scope==UNIFORM) { if(array_subscript=="MAX_LIGHTS") - array_size = features.max_lights; + array_size = feat.max_lights; else if(array_subscript=="MAX_CLIP_PLANES") - array_size = features.max_clip_planes; + array_size = feat.max_clip_planes; else if(isnumrc(array_subscript)) array_size = lexical_cast(array_subscript); else @@ -936,7 +936,7 @@ void ProgramBuilder::ShaderVariable::resolve_array(const StandardFeatures &featu { for(list::const_iterator i=referenced_vars.begin(); i!=referenced_vars.end(); ++i) if(!(*i)->array_subscript.empty() && !(*i)->array_size) - (*i)->resolve_array(features, array_size); + (*i)->resolve_array(feat, array_size); } } @@ -1092,19 +1092,19 @@ string ProgramBuilder::ShaderVariable::create_declaration(char iface, bool loop) return format("%s %s%s", variable->type, resolved_name, array); } -string ProgramBuilder::ShaderVariable::create_replacement(VariableScope from_scope, unsigned enabled_scopes, const char *loop) const +string ProgramBuilder::ShaderVariable::create_replacement(VariableScope from_scope, unsigned scopes, const char *loop) const { string replacement = resolved_name; InterfaceFlags iface = NO_INTERFACE; if(variable) { iface = get_interface_flags(from_scope); - VariableScope prev_scope = previous_scope(from_scope, enabled_scopes); + VariableScope prev_scope = previous_scope(from_scope, scopes); if((iface&INPUT) && interfaces[prev_scope]) replacement = format("%c_%s", interfaces[prev_scope], replacement); else if(inlined) { - replacement = create_expression(enabled_scopes, loop); + replacement = create_expression(scopes, loop); if(inline_parens) replacement = "("+replacement+")"; return replacement; @@ -1123,12 +1123,12 @@ string ProgramBuilder::ShaderVariable::create_replacement(VariableScope from_sco return replacement; } -string ProgramBuilder::ShaderVariable::create_expression(unsigned enabled_scopes, const char *loop) const +string ProgramBuilder::ShaderVariable::create_expression(unsigned scopes, const char *loop) const { map replace_map; for(list::const_iterator i=referenced_vars.begin(); i!=referenced_vars.end(); ++i) { - string replacement = (*i)->create_replacement(variable->scope, enabled_scopes, loop); + string replacement = (*i)->create_replacement(variable->scope, scopes, loop); if(replacement!=(*i)->name) replace_map[(*i)->name] = replacement; } diff --git a/source/programcompiler.h b/source/programcompiler.h index ac1f910d..5bb71474 100644 --- a/source/programcompiler.h +++ b/source/programcompiler.h @@ -40,6 +40,7 @@ private: virtual void apply(ProgramSyntax::Stage &); const std::string &get_result() const { return formatted; } + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::Literal &); virtual void visit(ProgramSyntax::ParenthesizedExpression &); @@ -71,6 +72,7 @@ private: std::list nodes; const ResultType &get_result() const { return nodes; } + using Visitor::visit; virtual void visit(T &n) { nodes.push_back(&n); } }; @@ -83,6 +85,7 @@ private: DeclarationCombiner(); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::FunctionDeclaration &); virtual void visit(ProgramSyntax::VariableDeclaration &); @@ -101,6 +104,7 @@ private: VariableResolver(); virtual void apply(ProgramSyntax::Stage &); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::VariableReference &); virtual void visit(ProgramSyntax::MemberAccess &); @@ -115,6 +119,7 @@ private: { std::map > functions; + using Visitor::visit; virtual void visit(ProgramSyntax::FunctionCall &); virtual void visit(ProgramSyntax::FunctionDeclaration &); }; @@ -128,6 +133,7 @@ private: void flatten_block(ProgramSyntax::Block &); void apply_and_increment(ProgramSyntax::Block &, std::list >::iterator &); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); }; @@ -142,6 +148,7 @@ private: static std::string get_out_prefix(ProgramSyntax::StageType); virtual void apply(ProgramSyntax::Stage &); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); std::string change_prefix(const std::string &, const std::string &) const; bool generate_interface(ProgramSyntax::VariableDeclaration &, const std::string &, const std::string &); @@ -153,6 +160,7 @@ private: struct VariableRenamer: Visitor { + using Visitor::visit; virtual void visit(ProgramSyntax::VariableReference &); virtual void visit(ProgramSyntax::VariableDeclaration &); }; @@ -172,6 +180,7 @@ private: DeclarationReorderer(); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::InterfaceLayout &) { kind = LAYOUT; } virtual void visit(ProgramSyntax::StructDeclaration &) { kind = STRUCT; } @@ -191,6 +200,7 @@ private: InlineableFunctionLocator(); const ResultType &get_result() const { return inlineable; } + using Visitor::visit; virtual void visit(ProgramSyntax::FunctionCall &); virtual void visit(ProgramSyntax::FunctionDeclaration &); }; @@ -205,6 +215,7 @@ private: FunctionInliner(const std::set &); void visit_and_inline(RefPtr &); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::UnaryExpression &); virtual void visit(ProgramSyntax::BinaryExpression &); @@ -223,6 +234,7 @@ private: ExpressionEvaluator(); ExpressionEvaluator(const ValueMap &); + using ProgramSyntax::NodeVisitor::visit; virtual void visit(ProgramSyntax::Literal &); virtual void visit(ProgramSyntax::ParenthesizedExpression &); virtual void visit(ProgramSyntax::VariableReference &); @@ -237,6 +249,7 @@ private: ConstantConditionEliminator(); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::Assignment &); virtual void visit(ProgramSyntax::VariableDeclaration &); @@ -271,6 +284,7 @@ private: virtual void apply(ProgramSyntax::Stage &); const ResultType &get_result() const { return unused_nodes; } + using Visitor::visit; virtual void visit(ProgramSyntax::VariableReference &); virtual void visit(ProgramSyntax::MemberAccess &); virtual void visit(ProgramSyntax::BinaryExpression &); @@ -295,6 +309,7 @@ private: std::set used_definitions; const ResultType &get_result() const { return unused_nodes; } + using Visitor::visit; virtual void visit(ProgramSyntax::FunctionCall &); virtual void visit(ProgramSyntax::FunctionDeclaration &); }; @@ -306,6 +321,7 @@ private: NodeRemover() { } NodeRemover(const std::set &); + using Visitor::visit; virtual void visit(ProgramSyntax::Block &); virtual void visit(ProgramSyntax::VariableDeclaration &); }; @@ -320,6 +336,7 @@ private: LegacyConverter(const Version &); bool check_version(const Version &); + using Visitor::visit; virtual void visit(ProgramSyntax::VariableReference &); virtual void visit(ProgramSyntax::FunctionCall &); virtual void visit(ProgramSyntax::VariableDeclaration &); diff --git a/source/programsyntax.h b/source/programsyntax.h index d681c50b..b72d401d 100644 --- a/source/programsyntax.h +++ b/source/programsyntax.h @@ -336,6 +336,7 @@ struct NodeVisitor struct TraversingVisitor: NodeVisitor { + using NodeVisitor::visit; virtual void visit(Block &); virtual void visit(ParenthesizedExpression &); virtual void visit(MemberAccess &); diff --git a/source/resourcemanager.cpp b/source/resourcemanager.cpp index 6b4f0f24..9835adde 100644 --- a/source/resourcemanager.cpp +++ b/source/resourcemanager.cpp @@ -414,13 +414,13 @@ void ResourceManager::LoadingThread::main() } } -ResourceManager::ManagedResource *ResourceManager::LoadingThread::front(LoadQueue &queue) +ResourceManager::ManagedResource *ResourceManager::LoadingThread::front(LoadQueue &que) { MutexLock lock(queue_mutex); - if(queue.empty()) + if(que.empty()) return 0; - return queue.front(); + return que.front(); } void ResourceManager::LoadingThread::add_resource(ManagedResource &r) -- 2.45.2