From d344e8a91bdbfedc28527c3fc7d6d243dff9e3e6 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Fri, 12 Aug 2022 20:56:42 +0000 Subject: Show equivalent warnings/errors only once (#2673) (#2675) (cherry picked from commit ae76ff4cb303a6646e48dc044be47051b67e7cbb) Co-authored-by: Zachary Yedidia --- src/test/scala/chiselTests/WarningSpec.scala | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/scala/chiselTests/WarningSpec.scala (limited to 'src/test/scala/chiselTests/WarningSpec.scala') diff --git a/src/test/scala/chiselTests/WarningSpec.scala b/src/test/scala/chiselTests/WarningSpec.scala new file mode 100644 index 00000000..bf3830d6 --- /dev/null +++ b/src/test/scala/chiselTests/WarningSpec.scala @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 + +package chiselTests + +import chisel3._ +import chisel3.util._ +import chisel3.stage.{ChiselGeneratorAnnotation, ChiselStage} +import chisel3.experimental.ChiselEnum +import chisel3.experimental.EnumType +import chiselTests.ChiselFlatSpec + +class WarningSpec extends ChiselFlatSpec with Utils { + behavior.of("Warnings") + + "Warnings" should "be de-duplicated" in { + object MyEnum extends ChiselEnum { + val e0, e1, e2 = Value + } + + class MyModule extends Module { + val in = IO(Input(UInt(2.W))) + val out1 = IO(Output(MyEnum())) + val out2 = IO(Output(MyEnum())) + def func(out: EnumType): Unit = { + out := MyEnum(in) + } + func(out1) + func(out2) + } + val (log, _) = grabLog(ChiselStage.elaborate(new MyModule)) + def countSubstring(s: String, sub: String) = + s.sliding(sub.length).count(_ == sub) + countSubstring(log, "Casting non-literal UInt") should be(1) + } +} -- cgit v1.2.3 From c4dec947d54a52c3092bd7855180d42afaae3776 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Sat, 13 Aug 2022 00:17:56 +0000 Subject: Add option to treat warnings as errors (backport #2676) (#2677) * Add option to treat warnings as errors (#2676) Add --warnings-as-errors option (cherry picked from commit 498946663726955c380a1e420f5d7b9630000aad) # Conflicts: # core/src/main/scala/chisel3/experimental/hierarchy/Definition.scala # core/src/main/scala/chisel3/internal/Builder.scala # src/main/scala/chisel3/aop/injecting/InjectingAspect.scala # src/main/scala/chisel3/stage/ChiselOptions.scala # src/main/scala/chisel3/stage/package.scala # src/main/scala/chisel3/stage/phases/Elaborate.scala * Resolve backport conflicts Co-authored-by: Zachary Yedidia Co-authored-by: Jack Koenig --- src/test/scala/chiselTests/WarningSpec.scala | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/test/scala/chiselTests/WarningSpec.scala') diff --git a/src/test/scala/chiselTests/WarningSpec.scala b/src/test/scala/chiselTests/WarningSpec.scala index bf3830d6..1cef1ffc 100644 --- a/src/test/scala/chiselTests/WarningSpec.scala +++ b/src/test/scala/chiselTests/WarningSpec.scala @@ -4,32 +4,39 @@ package chiselTests import chisel3._ import chisel3.util._ -import chisel3.stage.{ChiselGeneratorAnnotation, ChiselStage} +import chisel3.stage.ChiselStage import chisel3.experimental.ChiselEnum import chisel3.experimental.EnumType -import chiselTests.ChiselFlatSpec class WarningSpec extends ChiselFlatSpec with Utils { behavior.of("Warnings") - "Warnings" should "be de-duplicated" in { - object MyEnum extends ChiselEnum { - val e0, e1, e2 = Value - } + object MyEnum extends ChiselEnum { + val e0, e1, e2 = Value + } - class MyModule extends Module { - val in = IO(Input(UInt(2.W))) - val out1 = IO(Output(MyEnum())) - val out2 = IO(Output(MyEnum())) - def func(out: EnumType): Unit = { - out := MyEnum(in) - } - func(out1) - func(out2) + class MyModule extends Module { + val in = IO(Input(UInt(2.W))) + val out1 = IO(Output(MyEnum())) + val out2 = IO(Output(MyEnum())) + def func(out: EnumType): Unit = { + out := MyEnum(in) } + func(out1) + func(out2) + } + + "Warnings" should "be de-duplicated" in { val (log, _) = grabLog(ChiselStage.elaborate(new MyModule)) def countSubstring(s: String, sub: String) = s.sliding(sub.length).count(_ == sub) countSubstring(log, "Casting non-literal UInt") should be(1) } + + "Warnings" should "be treated as errors with warningsAsErrors" in { + a[ChiselException] should be thrownBy extractCause[ChiselException] { + val args = Array("--warnings-as-errors") + (new ChiselStage).emitChirrtl(new MyModule, args) + } + } } -- cgit v1.2.3