Regression tests for same-named functions across translation units#9106
Open
tautschnig wants to merge 1 commit into
Open
Regression tests for same-named functions across translation units#9106tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
Static (internal-linkage) functions may share a name across translation units, and may coexist with a global (external-linkage) function of the same name. Extend the existing Static_Functions1 directory with two further test descriptors confirming CBMC's behaviour here: * test-resolve.desc checks that calls resolve to the definition mandated by the C standard when two translation units each define a file-local f and a third defines a global f: each file-local call stays within its unit, and the call from the unit defining the global reaches it. * test-unwind.desc checks loop unwinding in this context. Linking renames the second same-named static function, so the two loops carry distinct identifiers count.0 and count$link1.0. The test uses --unwindset with those identifiers to bound the loops independently, demonstrating that the linker-renamed identifier selects the intended loop. The pre-existing test.desc already covers a static function shadowing a global of the same name. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for C linkage edge-cases where multiple translation units define same-named static functions, including verifying correct call resolution and demonstrating --unwindset targeting of linker-renamed loop identifiers.
Changes:
- Add a new multi-translation-unit regression test (
test-resolve.desc) covering resolution between per-TUstatic fand a globalf. - Add a new multi-translation-unit unwinding regression test (
test-unwind.desc) demonstrating independent loop bounding viacount.0vscount$link1.0. - Introduce supporting C sources for both scenarios under
regression/cbmc/Static_Functions1/.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| regression/cbmc/Static_Functions1/resolve_main.c | Defines global f and asserts correct resolution across TUs. |
| regression/cbmc/Static_Functions1/resolve_a.c | Provides a TU-local static f and wrapper fa(). |
| regression/cbmc/Static_Functions1/resolve_b.c | Provides a TU-local static f and wrapper fb(). |
| regression/cbmc/Static_Functions1/test-resolve.desc | Checks CBMC resolves each call to the correct linkage target. |
| regression/cbmc/Static_Functions1/unwind_main.c | Drives both entrypoints and asserts expected results. |
| regression/cbmc/Static_Functions1/unwind_a.c | Provides first TU-local static count loop (expected loop id count.0). |
| regression/cbmc/Static_Functions1/unwind_b.c | Provides second TU-local static count loop (expected loop id count$link1.0). |
| regression/cbmc/Static_Functions1/test-unwind.desc | Validates --unwindset can independently bound the two loops. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| CORE | ||
| unwind_main.c | ||
| unwind_a.c unwind_b.c --unwinding-assertions --unwindset 'count.0:4,count$link1.0:2' | ||
| ^\[count\.unwind\.0\] file unwind_b\.c line 6 unwinding assertion loop 0: FAILURE$ |
| ^SIGNAL=0$ | ||
| -- | ||
| ^warning: ignoring | ||
| file unwind_a\.c line 5 unwinding assertion loop 0: FAILURE |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9106 +/- ##
========================================
Coverage 80.77% 80.78%
========================================
Files 1712 1712
Lines 189814 189814
Branches 73 73
========================================
+ Hits 153328 153332 +4
+ Misses 36486 36482 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static (internal-linkage) functions may share a name across translation units, and may coexist with a global (external-linkage) function of the same name. Extend the existing Static_Functions1 directory with two further test descriptors confirming CBMC's behaviour here:
test-resolve.desc checks that calls resolve to the definition mandated by the C standard when two translation units each define a file-local f and a third defines a global f: each file-local call stays within its unit, and the call from the unit defining the global reaches it.
test-unwind.desc checks loop unwinding in this context. Linking renames the second same-named static function, so the two loops carry distinct identifiers count.0 and count$link1.0. The test uses --unwindset with those identifiers to bound the loops independently, demonstrating that the linker-renamed identifier selects the intended loop.
The pre-existing test.desc already covers a static function shadowing a global of the same name.