Fix GCC warnings
authorJeremy Hayes <jeremy@lunarg.com>
Mon, 9 Aug 2021 20:41:50 +0000 (14:41 -0600)
committerJeremy Hayes <jeremy@lunarg.com>
Tue, 31 Aug 2021 22:40:35 +0000 (16:40 -0600)
Fix -Wsign-compare warnings.
Fix -Wunused-parameter warnings.

SPIRV/GlslangToSpv.cpp
glslang/MachineIndependent/Constant.cpp
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/attribute.cpp
glslang/MachineIndependent/glslang.m4
glslang/MachineIndependent/glslang.y
glslang/MachineIndependent/glslang_tab.cpp

index c323bcd..71b00d7 100644 (file)
@@ -3384,7 +3384,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
         const auto& spirvInst = node->getSpirvInstruction();
         if (spirvInst.set == "") {
             std::vector<spv::IdImmediate> idImmOps;
-            for (int i = 0; i < glslangOperands.size(); ++i) {
+            for (unsigned int i = 0; i < glslangOperands.size(); ++i) {
                 if (glslangOperands[i]->getAsTyped()->getQualifier().isSpirvLiteral()) {
                     // Translate the constant to a literal value
                     std::vector<unsigned> literals;
index 4629cc2..7f5d4c4 100644 (file)
@@ -531,7 +531,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
             case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
             // Note: avoid UBSAN error regarding negating 0x80000000
             case EbtInt:   newConstArray[i].setIConst(
-                                unionArray[i].getIConst() == 0x80000000
+                                static_cast<unsigned int>(unionArray[i].getIConst()) == 0x80000000
                                     ? -0x7FFFFFFF - 1
                                     : -unionArray[i].getIConst());
                            break;
index de44884..442741d 100644 (file)
@@ -241,7 +241,7 @@ protected:
     // override this to set the language-specific name
     virtual const char* getAtomicCounterBlockName() const { return ""; }
     virtual void setAtomicCounterBlockDefaults(TType&) const {}
-    virtual void setInvariant(const TSourceLoc& loc, const char* builtin) {}
+    virtual void setInvariant(const TSourceLoc&, const char*) {}
     virtual void finalizeAtomicCounterBlockLayout(TVariable&) {}
     bool isAtomicCounterBlock(const TSymbol& symbol) {
         const TVariable* var = symbol.getAsVariable();
@@ -472,7 +472,7 @@ public:
     // Determine loop control from attributes
     void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
     // Function attributes
-    void handleFunctionAttributes(const TSourceLoc&, const TAttributes&, TFunction*);
+    void handleFunctionAttributes(const TSourceLoc&, const TAttributes&);
 
     // GL_EXT_spirv_intrinsics
     TSpirvRequirement* makeSpirvRequirement(const TSourceLoc& loc, const TString& name,
index 8a92f6a..df7fdc2 100644 (file)
@@ -347,7 +347,7 @@ void TParseContext::handleLoopAttributes(const TAttributes& attributes, TIntermN
 //
 // Function attributes
 //
-void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttributes& attributes, TFunction* function)
+void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttributes& attributes)
 {
     for (auto it = attributes.begin(); it != attributes.end(); ++it) {
         if (it->size() > 0) {
index 93041ce..b30c734 100644 (file)
@@ -983,20 +983,20 @@ function_prototype
         $$.function = $1;
         $$.loc = $2.loc;
         parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($2.loc, *$3, $$.function);
+        parseContext.handleFunctionAttributes($2.loc, *$3);
     }
     | attribute function_declarator RIGHT_PAREN {
         $$.function = $2;
         $$.loc = $3.loc;
         parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
+        parseContext.handleFunctionAttributes($3.loc, *$1);
     }
     | attribute function_declarator RIGHT_PAREN attribute {
         $$.function = $2;
         $$.loc = $3.loc;
         parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
-        parseContext.handleFunctionAttributes($3.loc, *$4, $$.function);
+        parseContext.handleFunctionAttributes($3.loc, *$1);
+        parseContext.handleFunctionAttributes($3.loc, *$4);
     }
     ;
 
index b77f461..c535ecc 100644 (file)
@@ -983,20 +983,20 @@ function_prototype
         $$.function = $1;
         $$.loc = $2.loc;
         parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($2.loc, *$3, $$.function);
+        parseContext.handleFunctionAttributes($2.loc, *$3);
     }
     | attribute function_declarator RIGHT_PAREN {
         $$.function = $2;
         $$.loc = $3.loc;
         parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
+        parseContext.handleFunctionAttributes($3.loc, *$1);
     }
     | attribute function_declarator RIGHT_PAREN attribute {
         $$.function = $2;
         $$.loc = $3.loc;
         parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
-        parseContext.handleFunctionAttributes($3.loc, *$4, $$.function);
+        parseContext.handleFunctionAttributes($3.loc, *$1);
+        parseContext.handleFunctionAttributes($3.loc, *$4);
     }
     ;
 
index dba06ae..648bc37 100644 (file)
@@ -6204,7 +6204,7 @@ yyreduce:
         (yyval.interm).function = (yyvsp[-2].interm.function);
         (yyval.interm).loc = (yyvsp[-1].lex).loc;
         parseContext.requireExtensions((yyvsp[-1].lex).loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[0].interm.attributes), (yyval.interm).function);
+        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[0].interm.attributes));
     }
 #line 6210 "MachineIndependent/glslang_tab.cpp"
     break;
@@ -6215,7 +6215,7 @@ yyreduce:
         (yyval.interm).function = (yyvsp[-1].interm.function);
         (yyval.interm).loc = (yyvsp[0].lex).loc;
         parseContext.requireExtensions((yyvsp[0].lex).loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes((yyvsp[0].lex).loc, *(yyvsp[-2].interm.attributes), (yyval.interm).function);
+        parseContext.handleFunctionAttributes((yyvsp[0].lex).loc, *(yyvsp[-2].interm.attributes));
     }
 #line 6221 "MachineIndependent/glslang_tab.cpp"
     break;
@@ -6226,8 +6226,8 @@ yyreduce:
         (yyval.interm).function = (yyvsp[-2].interm.function);
         (yyval.interm).loc = (yyvsp[-1].lex).loc;
         parseContext.requireExtensions((yyvsp[-1].lex).loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
-        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[-3].interm.attributes), (yyval.interm).function);
-        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[0].interm.attributes), (yyval.interm).function);
+        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[-3].interm.attributes));
+        parseContext.handleFunctionAttributes((yyvsp[-1].lex).loc, *(yyvsp[0].interm.attributes));
     }
 #line 6233 "MachineIndependent/glslang_tab.cpp"
     break;