:switch:`-gnatwp`
*Activate warnings on ineffective pragma Inlines.*
- This switch activates warnings for failure of front end inlining
- (activated by :switch:`-gnatN`) to inline a particular call. There are
- many reasons for not being able to inline a call, including most
- commonly that the call is too complex to inline. The default is
- that such warnings are not given.
- Warnings on ineffective inlining by the gcc back end can be activated
- separately, using the gcc switch -Winline.
+ This switch activates warnings for failure of cross-unit inlining
+ (activated by :switch:`-gnatn`) to inline calls to a subprogram.
+ There are many reasons for not being able to inline these calls,
+ including most commonly that the subprogram body is too complex
+ to inline. The default is that such warnings are not given.
+ Warnings on ineffective inlining (within units) by the back end
+ can be activated separately, using the -Winline switch.
.. index:: -gnatwP (gcc)
@copying
@quotation
-GNAT User's Guide for Native Platforms , Nov 18, 2025
+GNAT User's Guide for Native Platforms , Nov 27, 2025
AdaCore
`Activate warnings on ineffective pragma Inlines.'
-This switch activates warnings for failure of front end inlining
-(activated by @code{-gnatN}) to inline a particular call. There are
-many reasons for not being able to inline a call, including most
-commonly that the call is too complex to inline. The default is
-that such warnings are not given.
-Warnings on ineffective inlining by the gcc back end can be activated
-separately, using the gcc switch -Winline.
+This switch activates warnings for failure of cross-unit inlining
+(activated by @code{-gnatn}) to inline calls to a subprogram.
+There are many reasons for not being able to inline these calls,
+including most commonly that the subprogram body is too complex
+to inline. The default is that such warnings are not given.
+Warnings on ineffective inlining (within units) by the back end
+can be activated separately, using the -Winline switch.
@end table
@geindex -gnatwP (gcc)
with Errout; use Errout;
with Exp_Ch6; use Exp_Ch6;
with Exp_Ch7; use Exp_Ch7;
-with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Fname; use Fname;
with Fname.UF; use Fname.UF;
-- Return the entity node for the unit containing E. Always return the spec
-- for a package.
- function Has_Initialized_Type (E : Entity_Id) return Boolean;
- -- If a candidate for inlining contains type declarations for types with
- -- nontrivial initialization procedures, they are not worth inlining.
-
function Has_Single_Return (N : Node_Id) return Boolean;
-- In general we cannot inline functions that return unconstrained type.
-- However, we can handle such functions if all return statements return
-- an instance whose body will be analyzed anyway or the subprogram was
-- generated as a body by the compiler (for example an initialization
-- procedure) or its declaration was provided along with the body (for
- -- example an expression function) and it does not declare types with
- -- nontrivial initialization procedures.
+ -- example an expression function). Note that we need to test again the
+ -- Is_Inlined flag because Analyze_Subprogram_Body_Helper may have reset
+ -- it if the body contains excluded declarations or statements.
if (Is_Inlined (Pack)
or else Is_Generic_Instance (Pack)
or else Nkind (Decl) = N_Subprogram_Body
or else Present (Corresponding_Body (Decl)))
- and then not Has_Initialized_Type (E)
+ and then Is_Inlined (E)
then
Register_Backend_Inlined_Subprogram (E);
return False;
end Has_Excluded_Statement;
- --------------------------
- -- Has_Initialized_Type --
- --------------------------
-
- function Has_Initialized_Type (E : Entity_Id) return Boolean is
- E_Body : constant Node_Id := Subprogram_Body (E);
- Decl : Node_Id;
-
- begin
- if No (E_Body) then -- imported subprogram
- return False;
-
- else
- Decl := First (Declarations (E_Body));
- while Present (Decl) loop
- if Nkind (Decl) = N_Full_Type_Declaration
- and then Comes_From_Source (Decl)
- and then Present (Init_Proc (Defining_Identifier (Decl)))
- then
- return True;
- end if;
-
- Next (Decl);
- end loop;
- end if;
-
- return False;
- end Has_Initialized_Type;
-
-----------------------
-- Has_Single_Return --
-----------------------
Write_Line (" .O* turn off warnings for out parameters assigned " &
"but not read");
Write_Line (" p+ turn on warnings for ineffective pragma " &
- "Inline in frontend");
+ "Inline");
Write_Line (" P* turn off warnings for ineffective pragma " &
- "Inline in frontend");
+ "Inline");
Write_Line (" .p+ turn on warnings for suspicious parameter " &
"order");
Write_Line (" .P* turn off warnings for suspicious parameter " &