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

Ada: Handle call to C++ constructor in generic instantiation

This commit adds missing support for C++ constructor calls passed as generic formal subprogram parameters in Ada.

This commit introduces support for passing C++ constructor calls as generic formal subprogram parameters in Ada. The change ensures that subtypes inherit the CPP_Class attribute, which is required for successful instantiation of generics that involve C++ constructors. This allows Ada code to more seamlessly interact with C++ code through generics.

In Details

The fix involves a modification to sem_ch3.adb where subtypes are now explicitly made to inherit the CPP_Class attribute. This attribute is crucial when dealing with instantiations involving C++ types, specifically when a C++ constructor is passed as a generic formal subprogram parameter.

For Context

Generics in Ada allow you to write code that can work with different types. This commit allows Ada generics to accept C++ constructors as parameters, allowing for more flexible interactions between Ada and C++ code. By ensuring that the necessary attributes are inherited, the compiler can properly instantiate generics that use C++ constructors.

Filed Under: adac++genericsinteroperability