From 0adefe2492f4de17f90be72626b0e1e5caba2652 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Tue, 16 Jan 2024 00:35:06 +0100 Subject: [PATCH] Enable more warnings --- src/CMakeLists.txt | 3 ++ src/ast/ASTNodes.cpp | 3 +- src/ast/ASTNodes.h | 28 ++++++------- src/irgenerator/DebugInfoGenerator.cpp | 3 -- src/irgenerator/GenExpressions.cpp | 46 ++++++++++----------- src/irgenerator/GenImplicit.cpp | 6 +-- src/irgenerator/GenVTable.cpp | 26 ++++++------ src/irgenerator/OpRuleConversionManager.cpp | 5 --- src/linker/ExternalLinkerInterface.h | 2 +- src/model/Function.h | 4 +- src/model/StructBase.h | 4 +- src/symboltablebuilder/SymbolTableEntry.h | 2 +- src/symboltablebuilder/SymbolType.h | 2 +- src/util/CodeLoc.h | 10 ++--- test/CMakeLists.txt | 3 ++ 15 files changed, 72 insertions(+), 75 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f9234a05..1ac447f11 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -153,6 +153,9 @@ set(SOURCES add_executable(spice ${SOURCES} ${ANTLR_Spice_CXX_OUTPUTS}) +# Enable pedantic warnings +target_compile_options(spice PRIVATE -Wpedantic -Wall) + # Include Antlr components include_directories(../lib/antlr4/runtime/Cpp/runtime/src) include_directories(${ANTLR_Spice_OUTPUT_DIR}) diff --git a/src/ast/ASTNodes.cpp b/src/ast/ASTNodes.cpp index 54f02b2e0..6c144a48b 100644 --- a/src/ast/ASTNodes.cpp +++ b/src/ast/ASTNodes.cpp @@ -31,7 +31,8 @@ std::string ASTNode::getErrorMessage() const { } for (size_t suffixContext = 0; suffixContext < ERROR_MESSAGE_CONTEXT; suffixContext++) { extSourceInterval.b++; - if (extSourceInterval.b > inputStream->size() || inputStream->getText(extSourceInterval).find('\n') != std::string::npos) { + if (static_cast(extSourceInterval.b) > inputStream->size() || + inputStream->getText(extSourceInterval).find('\n') != std::string::npos) { extSourceInterval.b--; break; } diff --git a/src/ast/ASTNodes.h b/src/ast/ASTNodes.h index e8d1d72f1..fb7a6dcd5 100644 --- a/src/ast/ASTNodes.h +++ b/src/ast/ASTNodes.h @@ -87,14 +87,14 @@ class ASTNode { customItemsInitialization(manifestationCount); } - virtual std::vector> *getOpFctPointers() { // LCOV_EXCL_LINE - assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE - return nullptr; // LCOV_EXCL_LINE - } // LCOV_EXCL_LINE - virtual const std::vector> *getOpFctPointers() const { // LCOV_EXCL_LINE - assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE - return nullptr; // LCOV_EXCL_LINE - } // LCOV_EXCL_LINE + virtual std::vector> *getOpFctPointers() { // LCOV_EXCL_LINE + assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE + return nullptr; // LCOV_EXCL_LINE + } // LCOV_EXCL_LINE + [[nodiscard]] virtual const std::vector> *getOpFctPointers() const { // LCOV_EXCL_LINE + assert_fail("The given node does not overload the getOpFctPointers function"); // LCOV_EXCL_LINE + return nullptr; // LCOV_EXCL_LINE + } // LCOV_EXCL_LINE virtual void customItemsInitialization(size_t) {} // Noop @@ -130,7 +130,7 @@ class ASTNode { return children.size() == 1 && children.front()->returnsOnAllControlPaths(doSetPredecessorsUnreachable); } - [[nodiscard]] virtual std::vector *getFctManifestations(const std::string &fctName) { // LCOV_EXCL_LINE + [[nodiscard]] virtual std::vector *getFctManifestations(const std::string &) { // LCOV_EXCL_LINE assert_fail("Must be called on a FctDefNode, ProcDefNode, ExtDeclNode, StructDefNode or SignatureNode"); // LCOV_EXCL_LINE return nullptr; // LCOV_EXCL_LINE } // LCOV_EXCL_LINE @@ -240,7 +240,7 @@ class FctDefBaseNode : public ASTNode { // Other methods [[nodiscard]] std::string getSymbolTableEntryName() const { return Function::getSymbolTableEntryName(name->name, codeLoc); } - std::vector *getFctManifestations(const std::string &_) override { return &manifestations; } + std::vector *getFctManifestations(const std::string &) override { return &manifestations; } [[nodiscard]] bool isFctOrProcDef() const override { return true; } bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override; @@ -469,7 +469,7 @@ class ExtDeclNode : public ASTNode { [[nodiscard]] TypeLstNode *argTypeLst() const { return getChild(); } // Other methods - std::vector *getFctManifestations(const std::string &_) override { return &extFunctionManifestations; } + std::vector *getFctManifestations(const std::string &) override { return &extFunctionManifestations; } [[nodiscard]] std::string getScopeId() const { const char *prefix = hasReturnType ? "func:" : "proc:"; return prefix + codeLoc.toString(); @@ -908,7 +908,7 @@ class SignatureNode : public ASTNode { [[nodiscard]] TypeLstNode *paramTypeLst() const { return getChild(hasTemplateTypes ? 1 : 0); } // Other methods - std::vector *getFctManifestations(const std::string &_) override { return &signatureManifestations; } + std::vector *getFctManifestations(const std::string &) override { return &signatureManifestations; } // Public members Type signatureType = SignatureNode::TYPE_NONE; @@ -1160,7 +1160,7 @@ class ReturnStmtNode : public ASTNode { [[nodiscard]] AssignExprNode *assignExpr() const { return getChild(); } // Other methods - [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override { return true; } + [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; } [[nodiscard]] StmtLstNode *getParentScopeNode() const { assert(dynamic_cast(parent->parent) != nullptr); return spice_pointer_cast(parent->parent); @@ -1332,7 +1332,7 @@ class PanicCallNode : public ASTNode { // Other methods [[nodiscard]] bool hasCompileTimeValue() const override { return false; } - [[nodiscard]] bool returnsOnAllControlPaths(bool *doSetPredecessorsUnreachable) const override { return true; } + [[nodiscard]] bool returnsOnAllControlPaths(bool *) const override { return true; } }; // ======================================================= AssignExprNode ======================================================== diff --git a/src/irgenerator/DebugInfoGenerator.cpp b/src/irgenerator/DebugInfoGenerator.cpp index 37cad8c7e..e33000c23 100644 --- a/src/irgenerator/DebugInfoGenerator.cpp +++ b/src/irgenerator/DebugInfoGenerator.cpp @@ -275,8 +275,6 @@ void DebugInfoGenerator::finalize() { diBuilder->finalize(); } -#pragma clang diagnostic push -#pragma ide diagnostic ignored "misc-no-recursion" llvm::DIType *DebugInfoGenerator::getDITypeForSymbolType(const ASTNode *node, const SymbolType &symbolType) const { // Pointer type if (symbolType.isPtr()) { @@ -417,6 +415,5 @@ llvm::DIType *DebugInfoGenerator::getDITypeForSymbolType(const ASTNode *node, co return baseDiType; } -#pragma clang diagnostic pop } // namespace spice::compiler \ No newline at end of file diff --git a/src/irgenerator/GenExpressions.cpp b/src/irgenerator/GenExpressions.cpp index 03cbf9d90..fe65f05f5 100644 --- a/src/irgenerator/GenExpressions.cpp +++ b/src/irgenerator/GenExpressions.cpp @@ -124,32 +124,31 @@ std::any IRGenerator::visitLogicalOrExpr(const LogicalOrExprNode *node) { llvm::Value *firstOperandValue = resolveValue(node->operands().front()); // Prepare an array for value-to-block-mapping - std::pair shortCircuitBlocks[node->operands().size()]; + std::vector> shortCircuitBlocks; + shortCircuitBlocks.reserve(node->operands().size()); // The first element is the first operand value with the original block - shortCircuitBlocks[0] = {builder.GetInsertBlock(), firstOperandValue}; + shortCircuitBlocks.emplace_back(builder.GetInsertBlock(), firstOperandValue); // Create a block for each additional operand and save it to the mapping - for (size_t i = 1; i < node->operands().size(); i++) { - llvm::BasicBlock *nextBlock = createBlock("lor." + std::to_string(i) + "." + codeLoc); - shortCircuitBlocks[i] = {nextBlock, nullptr}; - } + for (size_t i = 1; i < node->operands().size(); i++) + shortCircuitBlocks.emplace_back(createBlock("lor." + std::to_string(i) + "." + codeLoc), nullptr); // Create conditional jump to the exit block if the first operand was true, otherwise to the next block - insertCondJump(firstOperandValue, bExit, shortCircuitBlocks[1].first); + insertCondJump(firstOperandValue, bExit, shortCircuitBlocks.at(1).first); // Create block for each operand - for (int i = 1; i < node->operands().size(); i++) { + for (size_t i = 1; i < node->operands().size(); i++) { // Switch to the next block - switchToBlock(shortCircuitBlocks[i].first); + switchToBlock(shortCircuitBlocks.at(i).first); // Evaluate operand and save the result in the mapping - shortCircuitBlocks[i].second = resolveValue(node->operands()[i]); + shortCircuitBlocks.at(i).second = resolveValue(node->operands()[i]); // Replace the array entry with the current insert block, since the insert block could have changed in the meantime - shortCircuitBlocks[i].first = builder.GetInsertBlock(); + shortCircuitBlocks.at(i).first = builder.GetInsertBlock(); // Check if there are more blocks to process if (i == node->operands().size() - 1) { // Insert a simple jump to the exit block for the last block insertJump(bExit); } else { // Create conditional jump to the exit block if the first operand was true, otherwise to the next block - insertCondJump(shortCircuitBlocks[i].second, bExit, shortCircuitBlocks[i + 1].first); + insertCondJump(shortCircuitBlocks.at(i).second, bExit, shortCircuitBlocks.at(i + 1).first); } } @@ -179,32 +178,31 @@ std::any IRGenerator::visitLogicalAndExpr(const LogicalAndExprNode *node) { llvm::Value *firstOperandValue = resolveValue(node->operands().front()); // Prepare an array for value-to-block-mapping - std::pair shortCircuitBlocks[node->operands().size()]; + std::vector> shortCircuitBlocks; + shortCircuitBlocks.reserve(node->operands().size()); // The first element is the first operand value with the original block - shortCircuitBlocks[0] = {builder.GetInsertBlock(), firstOperandValue}; + shortCircuitBlocks.emplace_back(builder.GetInsertBlock(), firstOperandValue); // Create a block for each additional operand and save it to the mapping - for (size_t i = 1; i < node->operands().size(); i++) { - llvm::BasicBlock *nextBlock = createBlock("land." + std::to_string(i) + "." + codeLoc); - shortCircuitBlocks[i] = {nextBlock, nullptr}; - } + for (size_t i = 1; i < node->operands().size(); i++) + shortCircuitBlocks.emplace_back(createBlock("land." + std::to_string(i) + "." + codeLoc), nullptr); // Create conditional jump to the exit block if the first operand was true, otherwise to the next block - insertCondJump(firstOperandValue, shortCircuitBlocks[1].first, bExit); + insertCondJump(firstOperandValue, shortCircuitBlocks.at(1).first, bExit); // Create block for each operand - for (int i = 1; i < node->operands().size(); i++) { + for (size_t i = 1; i < node->operands().size(); i++) { // Switch to the next block - switchToBlock(shortCircuitBlocks[i].first); + switchToBlock(shortCircuitBlocks.at(i).first); // Evaluate operand and save the result in the mapping - shortCircuitBlocks[i].second = resolveValue(node->operands()[i]); + shortCircuitBlocks.at(i).second = resolveValue(node->operands()[i]); // Replace the array entry with the current insert block, since the insert block could have changed in the meantime - shortCircuitBlocks[i].first = builder.GetInsertBlock(); + shortCircuitBlocks.at(i).first = builder.GetInsertBlock(); // Check if there are more blocks to process if (i == node->operands().size() - 1) { // Insert a simple jump to the exit block for the last block insertJump(bExit); } else { // Create conditional jump to the exit block if the operand was true, otherwise to the next block - insertCondJump(shortCircuitBlocks[i].second, shortCircuitBlocks[i + 1].first, bExit); + insertCondJump(shortCircuitBlocks.at(i).second, shortCircuitBlocks.at(i + 1).first, bExit); } } diff --git a/src/irgenerator/GenImplicit.cpp b/src/irgenerator/GenImplicit.cpp index 67fafc74f..8441e737f 100644 --- a/src/irgenerator/GenImplicit.cpp +++ b/src/irgenerator/GenImplicit.cpp @@ -319,12 +319,12 @@ void IRGenerator::generateCtorBodyPreamble(Scope *bodyScope) { // Store VTable to first struct field if required Struct *spiceStruct = structSymbolType.getStruct(nullptr); assert(spiceStruct != nullptr); - if (spiceStruct->vtable != nullptr) { - assert(spiceStruct->vtableType != nullptr); + if (spiceStruct->vTableData.vtable != nullptr) { + assert(spiceStruct->vTableData.vtableType != nullptr); // Store VTable to field address at index 0 thisAddressLoaded = insertLoad(builder.getPtrTy(), thisAddress); llvm::Value *indices[3] = {builder.getInt32(0), builder.getInt32(0), builder.getInt32(2)}; - llvm::Value *gepResult = insertInBoundsGEP(spiceStruct->vtableType, spiceStruct->vtable, indices); + llvm::Value *gepResult = insertInBoundsGEP(spiceStruct->vTableData.vtableType, spiceStruct->vTableData.vtable, indices); insertStore(gepResult, thisAddressLoaded); } diff --git a/src/irgenerator/GenVTable.cpp b/src/irgenerator/GenVTable.cpp index 94e63d34d..df2fc2d1b 100644 --- a/src/irgenerator/GenVTable.cpp +++ b/src/irgenerator/GenVTable.cpp @@ -22,7 +22,7 @@ llvm::Constant *IRGenerator::generateTypeInfoName(StructBase *spiceStruct) { global->setLinkage(llvm::GlobalValue::ExternalLinkage); global->setComdat(module->getOrInsertComdat(globalName)); - return spiceStruct->typeInfoName = global; + return spiceStruct->vTableData.typeInfoName = global; } llvm::Constant *IRGenerator::generateTypeInfo(StructBase *spiceStruct) { @@ -43,7 +43,7 @@ llvm::Constant *IRGenerator::generateTypeInfo(StructBase *spiceStruct) { std::vector typeInfoFieldTypes = {ptrTy, ptrTy}; for (size_t i = 0; i < interfaceTypes.size(); i++) typeInfoFieldTypes.push_back(ptrTy); - spiceStruct->typeInfoType = llvm::StructType::get(context, typeInfoFieldTypes); + spiceStruct->vTableData.typeInfoType = llvm::StructType::get(context, typeInfoFieldTypes); // Generate type info values llvm::Constant *typeInfoVTable = llvm::Constant::getNullValue(ptrTy); @@ -59,15 +59,15 @@ llvm::Constant *IRGenerator::generateTypeInfo(StructBase *spiceStruct) { fieldValues.push_back(typeInfoName); for (const SymbolType &interfaceType : interfaceTypes) { Interface *interface = interfaceType.getInterface(nullptr); - assert(interface != nullptr && interface->typeInfo != nullptr); + assert(interface != nullptr && interface->vTableData.typeInfo != nullptr); const std::string interfaceMangledName = NameMangling::mangleTypeInfo(interface); llvm::Constant *global = module->getOrInsertGlobal(interfaceMangledName, builder.getPtrTy()); fieldValues.push_back(global); } - llvm::Constant *typeInfo = llvm::ConstantStruct::get(spiceStruct->typeInfoType, fieldValues); + llvm::Constant *typeInfo = llvm::ConstantStruct::get(spiceStruct->vTableData.typeInfoType, fieldValues); // Generate global variable - module->getOrInsertGlobal(mangledName, spiceStruct->typeInfoType); + module->getOrInsertGlobal(mangledName, spiceStruct->vTableData.typeInfoType); llvm::GlobalVariable *global = module->getNamedGlobal(mangledName); global->setInitializer(typeInfo); @@ -79,7 +79,7 @@ llvm::Constant *IRGenerator::generateTypeInfo(StructBase *spiceStruct) { global->setComdat(module->getOrInsertComdat(mangledName)); global->setAlignment(llvm::MaybeAlign(8)); - return spiceStruct->typeInfo = global; + return spiceStruct->vTableData.typeInfo = global; } llvm::Constant *IRGenerator::generateVTable(StructBase *spiceStruct) { @@ -94,10 +94,10 @@ llvm::Constant *IRGenerator::generateVTable(StructBase *spiceStruct) { // Generate VTable type llvm::PointerType *ptrTy = llvm::PointerType::get(context, 0); llvm::ArrayType *vtableArrayTy = llvm::ArrayType::get(ptrTy, arrayElementCount); - spiceStruct->vtableType = llvm::StructType::get(context, vtableArrayTy, false); + spiceStruct->vTableData.vtableType = llvm::StructType::get(context, vtableArrayTy, false); const std::string mangledName = NameMangling::mangleVTable(spiceStruct); - module->getOrInsertGlobal(mangledName, spiceStruct->vtableType); + module->getOrInsertGlobal(mangledName, spiceStruct->vTableData.vtableType); llvm::GlobalVariable *global = module->getNamedGlobal(mangledName); // Set global attributes @@ -108,7 +108,7 @@ llvm::Constant *IRGenerator::generateVTable(StructBase *spiceStruct) { global->setComdat(module->getOrInsertComdat(mangledName)); global->setAlignment(llvm::MaybeAlign(8)); - return spiceStruct->vtable = global; + return spiceStruct->vTableData.vtable = global; } void IRGenerator::generateVTableInitializer(StructBase *spiceStruct) { @@ -121,21 +121,21 @@ void IRGenerator::generateVTableInitializer(StructBase *spiceStruct) { // Generate VTable type llvm::PointerType *ptrTy = llvm::PointerType::get(context, 0); llvm::ArrayType *vtableArrayTy = llvm::ArrayType::get(ptrTy, arrayElementCount); - assert(spiceStruct->vtableType); + assert(spiceStruct->vTableData.vtableType); // Generate VTable values std::vector arrayValues; arrayValues.push_back(llvm::Constant::getNullValue(ptrTy)); // nullptr as safety guard - arrayValues.push_back(spiceStruct->typeInfo); // TypeInfo to identify the type for the VTable + arrayValues.push_back(spiceStruct->vTableData.typeInfo); // TypeInfo to identify the type for the VTable for (Function *virtualMethod : virtualMethods) { assert(spiceStruct->scope->type == ScopeType::INTERFACE || virtualMethod->llvmFunction != nullptr); - arrayValues.push_back(virtualMethod->llvmFunction ?: llvm::Constant::getNullValue(ptrTy)); + arrayValues.push_back(virtualMethod->llvmFunction ? virtualMethod->llvmFunction : llvm::Constant::getNullValue(ptrTy)); } // Generate VTable struct std::vector fieldValues; fieldValues.push_back(llvm::ConstantArray::get(vtableArrayTy, arrayValues)); - llvm::Constant *initializer = llvm::ConstantStruct::get(spiceStruct->vtableType, fieldValues); + llvm::Constant *initializer = llvm::ConstantStruct::get(spiceStruct->vTableData.vtableType, fieldValues); const std::string mangledName = NameMangling::mangleVTable(spiceStruct); llvm::GlobalVariable *global = module->getNamedGlobal(mangledName); diff --git a/src/irgenerator/OpRuleConversionManager.cpp b/src/irgenerator/OpRuleConversionManager.cpp index c711d1e16..891fdc038 100644 --- a/src/irgenerator/OpRuleConversionManager.cpp +++ b/src/irgenerator/OpRuleConversionManager.cpp @@ -1683,11 +1683,6 @@ LLVMExprResult OpRuleConversionManager::callOperatorOverloadFct(const ASTNode *n if constexpr (N == 2) argValues[1] = paramTypes[1].isRef() ? opV[3]() : opV[2](); - // Obtain information about the call - const bool isImported = accessScope->isImportedBy(irGenerator->rootScope); - const CodeLoc &callLoc = node->codeLoc; - const CodeLoc &defLoc = opFct->entry->getDeclCodeLoc(); - // Function is not defined in the current module -> declare it if (!irGenerator->module->getFunction(mangledName)) { // Get returnType diff --git a/src/linker/ExternalLinkerInterface.h b/src/linker/ExternalLinkerInterface.h index eb6297919..754125dd8 100644 --- a/src/linker/ExternalLinkerInterface.h +++ b/src/linker/ExternalLinkerInterface.h @@ -13,7 +13,7 @@ namespace spice::compiler { class ExternalLinkerInterface { public: // Constructors - explicit ExternalLinkerInterface(const CliOptions &cliOptions) : cliOptions(cliOptions), outputPath(cliOptions.outputPath){}; + explicit ExternalLinkerInterface(const CliOptions &cliOptions) : outputPath(cliOptions.outputPath), cliOptions(cliOptions){}; // Public methods void prepare(); diff --git a/src/model/Function.h b/src/model/Function.h index e96c4cafc..fb7b8139c 100644 --- a/src/model/Function.h +++ b/src/model/Function.h @@ -38,8 +38,8 @@ class Function { // Constructors Function(std::string name, SymbolTableEntry *entry, SymbolType thisType, SymbolType returnType, ParamList paramList, std::vector templateTypes, ASTNode *declNode) - : name(std::move(name)), entry(entry), thisType(std::move(thisType)), returnType(std::move(returnType)), - paramList(std::move(paramList)), templateTypes(std::move(templateTypes)), declNode(declNode) {} + : name(std::move(name)), thisType(std::move(thisType)), returnType(std::move(returnType)), paramList(std::move(paramList)), + templateTypes(std::move(templateTypes)), entry(entry), declNode(declNode) {} Function() = default; // Public methods diff --git a/src/model/StructBase.h b/src/model/StructBase.h index 1a61ccaf1..8462d9b64 100644 --- a/src/model/StructBase.h +++ b/src/model/StructBase.h @@ -23,7 +23,7 @@ class StructBase { public: // Constructors StructBase(std::string name, SymbolTableEntry *entry, Scope *scope, std::vector templateTypes, ASTNode *declNode) - : name(std::move(name)), entry(entry), scope(scope), templateTypes(std::move(templateTypes)), declNode(declNode) {} + : name(std::move(name)), templateTypes(std::move(templateTypes)), entry(entry), scope(scope), declNode(declNode) {} // Public methods [[nodiscard]] std::string getSignature() const; @@ -50,7 +50,7 @@ class StructBase { llvm::Constant *typeInfoName = nullptr; llvm::Constant *typeInfo = nullptr; llvm::Constant *vtable = nullptr; - }; + } vTableData; }; } // namespace spice::compiler \ No newline at end of file diff --git a/src/symboltablebuilder/SymbolTableEntry.h b/src/symboltablebuilder/SymbolTableEntry.h index 189c6b482..5ac0c8a41 100644 --- a/src/symboltablebuilder/SymbolTableEntry.h +++ b/src/symboltablebuilder/SymbolTableEntry.h @@ -29,7 +29,7 @@ class SymbolTableEntry { public: // Constructors SymbolTableEntry(std::string name, SymbolType type, Scope *scope, ASTNode *declNode, size_t orderIndex, const bool global) - : name(std::move(name)), type(std::move(type)), scope(scope), declNode(declNode), orderIndex(orderIndex), global(global){}; + : name(std::move(name)), scope(scope), declNode(declNode), orderIndex(orderIndex), global(global), type(std::move(type)){}; // Public methods [[nodiscard]] const SymbolType &getType() const; diff --git a/src/symboltablebuilder/SymbolType.h b/src/symboltablebuilder/SymbolType.h index c4c9d6a4d..8a410d763 100644 --- a/src/symboltablebuilder/SymbolType.h +++ b/src/symboltablebuilder/SymbolType.h @@ -74,7 +74,7 @@ class SymbolType { TypeChainElement(SymbolSuperType superType, std::string subType) : superType(superType), subType(std::move(subType)), typeId(superType){}; TypeChainElement(SymbolSuperType superType, TypeChainElementData data) - : superType(superType), data(data), typeId(superType){}; + : superType(superType), typeId(superType), data(data){}; TypeChainElement(SymbolSuperType superType, std::string subType, uint64_t typeId, TypeChainElementData data, const std::vector &templateTypes) : superType(superType), subType(std::move(subType)), typeId(typeId), data(data), templateTypes(templateTypes){}; diff --git a/src/util/CodeLoc.h b/src/util/CodeLoc.h index 7a903c9ba..28ff75bff 100644 --- a/src/util/CodeLoc.h +++ b/src/util/CodeLoc.h @@ -16,12 +16,12 @@ struct CodeLoc { public: // Constructors explicit CodeLoc(const antlr4::Token *token, SourceFile *sourceFile = nullptr) - : sourceInterval(token->getStartIndex(), token->getStopIndex()), line(token->getLine()), - col(token->getCharPositionInLine() + 1), sourceFile(sourceFile){}; + : sourceFile(sourceFile), sourceInterval(token->getStartIndex(), token->getStopIndex()), line(token->getLine()), + col(token->getCharPositionInLine() + 1){}; CodeLoc(const antlr4::Token *token, size_t startIdx, size_t stopIdx, SourceFile *sourceFile = nullptr) - : sourceInterval(startIdx, stopIdx), line(token->getLine()), col(token->getCharPositionInLine() + 1), - sourceFile(sourceFile){}; - CodeLoc(size_t line, size_t col, SourceFile *sourceFile = nullptr) : line(line), col(col), sourceFile(sourceFile) {} + : sourceFile(sourceFile), sourceInterval(startIdx, stopIdx), line(token->getLine()), + col(token->getCharPositionInLine() + 1){}; + CodeLoc(size_t line, size_t col, SourceFile *sourceFile = nullptr) : sourceFile(sourceFile), line(line), col(col) {} // Public members SourceFile *sourceFile = nullptr; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4666ee600..ddb1f54c5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,6 +13,9 @@ set(SOURCES add_executable(spicetest ${SOURCES} ${ANTLR_Spice_CXX_OUTPUTS}) +# Enable pedantic warnings +target_compile_options(spicetest PRIVATE -Wpedantic -Wall) + # Include Antlr components include_directories(${ANTLR_Spice_OUTPUT_DIR}) include_directories(../lib/antlr4/runtime/Cpp/runtime/src)