Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions conformance/sv-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ command-line defines apply to each file.
| `skip` | the official runner skipped an incompatible test or unsupported mode |

All 90 preprocessing cases at the pinned revision now execute in both state
modes, leaving no skipped expectation rows. Each mode reports 89 passes and
one failure: `chapter-22/22.11--pragma-invalid.sv` expects a bare `` `pragma ``
to be rejected, but the preprocessor currently accepts it. This failure remains
visible in the baseline. Upstream preprocessing verdicts check process success
and expected failure; they do not compare the emitted text against a golden file.
modes, leaving no skipped expectation rows. Each mode reports 90 passes,
including `chapter-22/22.11--pragma-invalid.sv`: a bare `` `pragma `` is rejected
because its name is required by IEEE 1800-2023 22.11. Upstream preprocessing
verdicts check process success and expected failure; they do not compare the
emitted text against a golden file.

The official runner’s process exit code is separate from the case verdict.
The wrapper reads its `PASS`/`FAIL` log messages; it does not reconstruct their
Expand Down
4 changes: 2 additions & 2 deletions conformance/sv-tests/expected.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ chapter-22/22.11--pragma-basic.sv 2state pass
chapter-22/22.11--pragma-basic.sv 4state pass
chapter-22/22.11--pragma-complex.sv 2state pass
chapter-22/22.11--pragma-complex.sv 4state pass
chapter-22/22.11--pragma-invalid.sv 2state fail
chapter-22/22.11--pragma-invalid.sv 4state fail
chapter-22/22.11--pragma-invalid.sv 2state pass
chapter-22/22.11--pragma-invalid.sv 4state pass
chapter-22/22.11--pragma-nested.sv 2state pass
chapter-22/22.11--pragma-nested.sv 4state pass
chapter-22/22.11--pragma-number-multi.sv 2state pass
Expand Down
9 changes: 9 additions & 0 deletions crates/celox-sv-analyzer/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ mod tests {
}
}

#[test]
fn public_preprocessing_and_parsing_reject_nameless_pragmas() {
let code = "`pragma\nmodule M; endmodule";
let path = Path::new("pragma.sv");
assert!(preprocess_source(code, path, &[], &[]).is_err());
assert!(parse_source(code, path).is_err());
assert!(crate::ParsedSource::parse(code, path).is_err());
}

#[test]
fn command_macros_have_values_without_leaking_source_definitions() {
let path = Path::new("macros.sv");
Expand Down
35 changes: 35 additions & 0 deletions crates/celox-sv-syntax/src/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ impl Preprocessor {
}
name if passthrough(name) => {
if active {
// IEEE 1800-2023 22.11 requires a pragma name, even
// when the implementation does not recognize it.
if name == "pragma"
&& tokens
.iter()
.take_while(|token| token.kind != TokenKind::Newline)
.all(Token::is_trivia)
{
return Err(self.error(origin, "expected a name after `pragma"));
}
output.extend([token, name_token]);
}
}
Expand Down Expand Up @@ -1117,6 +1127,31 @@ mod tests {
.join(" ")
}

#[test]
fn pragmas_require_a_name_on_the_directive_line() {
for code in [
"`pragma",
"`pragma \t",
"`pragma // comment\nmodule M; endmodule",
"`pragma /* comment */\nmodule M; endmodule",
"`pragma\nmodule M; endmodule",
] {
let error = Preprocessor::default()
.preprocess(code, "pragma.sv")
.unwrap_err();
assert!(error.to_string().contains("expected a name after `pragma"));
}
for code in [
"`pragma unknown",
"`pragma /* comment */ unknown value=1\nmodule M; endmodule",
"`ifdef UNDEFINED\n`pragma\n`endif\nmodule M; endmodule",
] {
Preprocessor::default()
.preprocess(code, "pragma.sv")
.unwrap();
}
}

#[test]
fn macro_generated_includes_end_at_each_invocation() {
let mut pp = Preprocessor::new(Options {
Expand Down
Loading