validateForeignRefs walks the merged tree (libraries + named c units, nested namespaces included) and diagnoses any #foreign whose ref names neither — a typo'd ref previously compiled and resolved silently through whatever image carried the symbol. Decls synthesized from #include headers carry no ref and are exempt. Flips the C0.2b pin; zero collateral across the 608 other examples.
18 lines
573 B
Plaintext
18 lines
573 B
Plaintext
// A `#foreign` ref must name something real (PLAN-C C3.1): `nosuchunit`
|
|
// names neither a #library constant nor a named `#import c` unit, so
|
|
// this is a compile-time diagnostic — a typo'd ref previously compiled
|
|
// and resolved silently through whatever image carried the symbol.
|
|
// Regression (PLAN-C C0.2b xfail, flipped by C3.1).
|
|
#import "modules/std.sx";
|
|
|
|
refs :: #import c {
|
|
#source "1620-cimport-foreign-ref-unvalidated/ref.c";
|
|
};
|
|
|
|
ref_answer :: () -> i32 #foreign nosuchunit "ref_answer";
|
|
|
|
main :: () -> i32 {
|
|
print("ref = {}\n", ref_answer());
|
|
0
|
|
}
|