GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc

objective-c,c++: Make declarations language-aware [PR124260].

Objective-C++ declarations now correctly use language-specific data during creation.

This change ensures that declarations in Objective-C++ are built with language-specific data. This is crucial because Objective-C metadata requires extern “C” linkage, and the language-specific data is necessary to record this correctly. The modification involves updating various Objective-C functions to use a new objc_build_decl helper function, which properly handles Objective-C++ specific requirements.

In Details

This commit refactors Objective-C++ declaration building by introducing objc_build_decl and ensuring it's used for various declaration types within objc-act.cc, objc-gnu-runtime-abi-01.cc, and objc-next-runtime-abi-*.cc. The motivation is to associate lang_decl_data correctly, which is necessary for Objective-C's runtime metadata, particularly for extern "C" contexts. This resolves an issue related to PR124260 where language-specific properties of declarations were not being preserved.

For Context
Declaration
In programming, a declaration introduces a name (like a variable, function, or type) and its properties into a scope, without necessarily defining its full implementation or initial value.
Objective-C++
A hybrid programming language that combines Objective-C with C++. It allows developers to use both Objective-C's object-oriented features and C++'s capabilities within the same project.
extern "C"
A linkage specification in C++ that instructs the compiler to use C calling conventions and name mangling for functions or variables. This is essential for interoperability between C++ and C code, or when interfacing with C-based runtimes.
Metadata
Data that describes other data. In the context of programming languages and runtimes, metadata often includes information about types, classes, methods, and other program structures, used for dynamic features like reflection or runtime introspection.
Filed Under: objective-cc++language