GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada removes conversion of ignored pragmas to if-statements

The Ada front end no longer transforms ignored pragmas into if-statements, simplifying their handling.

The Ada front end now directly handles ignored pragmas rather than converting them into if statements with statically false conditions and null bodies. This change streamlines the compiler’s internal representation, making the code for detecting and removing these pragmas simpler and more consistent with other ghost code removals. This refactoring contributes to clearer code within the Ada compiler components.

In Details

In the GCC Ada front end, pragmas are directives that provide information to the compiler. Previously, ignored pragmas, particularly assertion pragmas lacking active checks, were transformed into if-statements with a false condition and empty body as a way to discard them during expansion. This commit removes that conversion, leveraging subsequent ghost-node removal passes to eliminate such ignored code directly. Key files impacted include expander.adb, sem_ch6.adb, sem_prag.adb, sem_res.adb, sem_util.adb, and tbuild.adb, which now handle pragmas more directly.

For Context

Compilers have a complex workflow: they take your source code (like Ada), transform it into an internal representation, optimize it, and then generate machine code. Pragmas in Ada are special instructions to the compiler, not part of the program's logic. Sometimes, these pragmas are ignored because they're not relevant to the current compilation settings. Historically, the Ada part of GCC would convert these ignored pragmas into a kind of placeholder if statement that would never execute. This change simplifies that process; instead of generating unnecessary if statements, the compiler now directly removes ignored pragmas from its internal representation, making the compiler's code cleaner and more efficient.

Filed Under: adarefactoringcompiler internals