Skip to content

Commit 294fbc3

Browse files
committed
Address review: test parent-sink warning-level inheritance; document -Wpedantic staging in help string
1 parent fd14e7b commit 294fbc3

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

docs/command-line-slangc-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Disable specific warning ids.
263263

264264
**-Wall | -Wextra | -Wpedantic**
265265

266-
Enable the corresponding group of opt-in warnings (additive).
266+
Enable the corresponding group of opt-in warnings (additive). Staging: the pedantic group is currently enabled by default, so [-Wpedantic](#wall-1) is a no-op today; a future release will make it opt-in.
267267

268268

269269
<a id="w"></a>

source/slang/slang-options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ void initCommandOptions(CommandOptions& options)
588588
{OptionKind::WarningLevel,
589589
"-Wall,-Wextra,-Wpedantic",
590590
"-Wall | -Wextra | -Wpedantic",
591-
"Enable the corresponding group of opt-in warnings (additive)."},
591+
"Enable the corresponding group of opt-in warnings (additive). Staging: the pedantic "
592+
"group is currently enabled by default, so -Wpedantic is a no-op today; a future release "
593+
"will make it opt-in."},
592594
{OptionKind::EnableWarning, "-W...", "-W<id>", "Enable a warning with the specified id."},
593595
{OptionKind::DisableWarning, "-Wno-...", "-Wno-<id>", "Disable warning with <id>"},
594596
{OptionKind::DumpWarningDiagnostics,

tools/slang-unit-test/unit-test-diagnostic-warning-level.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ SLANG_UNIT_TEST(warningLevelWarningsAsErrorsInteraction)
102102
SLANG_CHECK(sink.getErrorCount() == 2);
103103
}
104104

105+
// A child sink built from a parent inherits the parent's enabled warning groups. Sinks are
106+
// spun up per-translation-unit / per-module from a parent sink via the parent-copying ctor,
107+
// so an opt-in group enabled on the parent must carry over to nested/downstream compilations.
108+
SLANG_UNIT_TEST(warningLevelInheritedFromParentSink)
109+
{
110+
DiagnosticSink parent;
111+
parent.enableWarningLevel(WarningLevel::All);
112+
113+
// The parent-copying ctor forwards the enabled-group bitmask alongside flags/color/unicode.
114+
DiagnosticSink child(nullptr, nullptr, &parent);
115+
116+
SLANG_CHECK(child.isWarningLevelEnabled(WarningLevel::All) == true);
117+
SLANG_CHECK(emitted(child, makeWarning(3, WarningLevel::All)) == true);
118+
// A group the parent did not enable is not inherited either.
119+
SLANG_CHECK(child.isWarningLevelEnabled(WarningLevel::Extra) == false);
120+
SLANG_CHECK(emitted(child, makeWarning(4, WarningLevel::Extra)) == false);
121+
}
122+
105123
// Out-of-range group values (only reachable via a bogus int cast through the public
106124
// WarningLevel option) must not trigger an out-of-range shift / undefined behavior.
107125
SLANG_UNIT_TEST(warningLevelOutOfRangeIsSafe)

0 commit comments

Comments
 (0)