From d8eb2f83ae52e6a9e1383e132b8fe7ebeee95a73 Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Mon, 7 Jun 2021 18:31:14 -0700 Subject: [PATCH] Added treating warnings as errors --- src/Qir/Runtime/lib/QIR/QubitManager.cpp | 2 +- src/Qir/qir-utils.ps1 | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Qir/Runtime/lib/QIR/QubitManager.cpp b/src/Qir/Runtime/lib/QIR/QubitManager.cpp index 7e200aa5c44..0fed18c9d91 100644 --- a/src/Qir/Runtime/lib/QIR/QubitManager.cpp +++ b/src/Qir/Runtime/lib/QIR/QubitManager.cpp @@ -392,7 +392,7 @@ CQubitManager::QubitIdType CQubitManager::GetQubitId(Qubit qubit) const Qubit CQubitManager::CreateQubitObject(QubitIdType id) { // Make sure the static_cast won't overflow: - FailIf(id < 0 || id > std::numeric_limits::max(), "Qubit id is out of range."); + FailIf(id < 0 || id >= MaximumQubitCapacity, "Qubit id is out of range."); intptr_t pointerSizedId = static_cast(id); return reinterpret_cast(pointerSizedId); } diff --git a/src/Qir/qir-utils.ps1 b/src/Qir/qir-utils.ps1 index cfd0c31cc2f..d5b577a26e3 100644 --- a/src/Qir/qir-utils.ps1 +++ b/src/Qir/qir-utils.ps1 @@ -35,9 +35,15 @@ function Build-CMakeProject { $oldCC = $env:CC $oldCXX = $env:CXX $oldRC = $env:RC + $oldCCFLAGS = $env:CCFLAGS + $oldCXXFLAGS = $env:CXXFLAGS $clangTidy = "" + $warningFlags = "-Werror" + $env:CFLAGS += $warningFlags + $env:CXXFLAGS += $warningFlags + if (($IsMacOS) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Darwin")))) { Write-Host "On MacOS build $Name using the default C/C++ compiler (should be AppleClang)" @@ -100,6 +106,9 @@ function Build-CMakeProject { Pop-Location + $env:CXXFLAGS = $oldCXXFLAGS + $env:CCFLAGS = $oldCCFLAGS + $env:CC = $oldCC $env:CXX = $oldCXX $env:RC = $oldRC