Files
swift-mirror/test/ConstValues/SectionOnError.swift
Artem Chikin 5945030af1 [Section] Do not diagnose static-initialization failure on an already-erroneous context
If we encounter an error prior to 'initialize-static-globals', this pass will not run, and will not convert globals to be statically-initialized at all, regardless of whether or not it would have been possible. This means that diagnostics on failure to do so would then always be emitted, likely as false-positives.

Avoid emitting these diagnostics in a context that contains a prior error.
As a future alternative, we could refine the conditions that make `initialize-static-globals` give up on a given function/value, but for now we need to ensure we do not emit spurious diagnostics.

Resolves rdar://172195372
2026-03-12 10:03:42 +00:00

4 lines
392 B
Swift

// RUN: %target-swift-frontend -emit-ir %s -verify
// Ensure that we do not diagnose an inability to statically-initialize globals when they contain a prior (in the compilation pipeline) error
@section("__TEXT,__mysection") var tooBig: Int = 10000000000000000000000000000000000000 //expected-error {{integer literal '10000000000000000000000000000000000000' overflows when stored into 'Int'}}