Recent

Author Topic: Showing all compiler notes  (Read 572 times)

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Showing all compiler notes
« on: December 02, 2020, 03:35:30 pm »
I have a project that has some problems with inlining some lines. I liked to know the reason and added an issue that FPC can report the issue. As written by the developers, FPC already says the reason, but Lazarus does not show it.

Code: Pascal  [Select][+][-]
  1. program InlineHint;
  2.  
  3. uses unit1;
  4.  
  5.   function Test1(A: PChar): PChar; inline;
  6.   begin
  7.     Result := A + 1;
  8.   end;
  9.  
  10. var
  11.   S: String;
  12.   P: PChar;
  13. begin
  14.   S := 'Test';
  15.   P := Pointer(S); //Inlined
  16.   P := Test1(P);
  17.   P := Test1(Pointer(S)); //Not inlined
  18. end.
  19.  

When compiled by Lazarus, there is only a message about it can not inline the code, like the attached screenshot.
I tried to compile directly with FPC, and here is the result:

Code: [Select]
ppcx64 -l -Mobjfpc -B -Sh -vhd InlineHint.lpr
Code: Text  [Select][+][-]
  1. Found source file name "InlineHint.lpr"
  2. Free Pascal Compiler version 3.3.1-r47323 [2020/11/05] for x86_64
  3. Copyright (c) 1993-2020 by Florian Klaempfl and others
  4. Compiler OS: Win64 for x64
  5. Target OS: Win64 for x64
  6. Compiling InlineHint.lpr
  7. Compiling Unit1.pas
  8. Unit1.pas(3,2) Handling switch "$MODE"
  9. Unit1.pas(3,16) Handling switch "$H+"
  10. Unit1.pas(13,1) procedure/function Test2(const PChar):^Char;
  11. Unit1.pas(14,13) Note: Call to subroutine "function Test1(const A:PChar):^Char;" marked as inline is not inlined
  12. Unit1.pas(18,1) procedure/function Test1(const PChar):^Char;
  13. InlineHint.lpr(6,3) procedure/function Test1(PChar):^Char;
  14. InlineHint.lpr(17,8) Not inlining "Test1", invocation parameter contains an unsafe/unsupported construct
  15. InlineHint.lpr(17,8) Note: Call to subroutine "function Test1(A:PChar):^Char;" marked as inline is not inlined
  16. InlineHint.lpr(3,6) Hint: Unit "Unit1" not used in InlineHint

As you can see, there are two messages, including the reason for not inlining for (17,8), and Lazarus only shows one. Maybe because the second one is not "Note: " or because there are two for one line, or perhaps I missed an option.

Can anyone check this and let me know if I am missing something or it is an issue? The project is attached.
« Last Edit: December 02, 2020, 04:01:01 pm by OkobaPatino »

Peter H

  • Full Member
  • ***
  • Posts: 195
Re: Showing all compiler notes
« Reply #1 on: December 02, 2020, 06:50:40 pm »
Hello, I am interested for this myself, therefore I tried it.

Lazarus did not load the project, so I had to recreate it. (I use trunk on windows)
In the message window you can right click the messages and then set or unset various filters for the messages.
This changes the amount of messages, I dont know if this will satisfy your needs.
You can also display help for individual messages.
And adjust "verbosity" in project options.
« Last Edit: December 02, 2020, 07:14:32 pm by Peter H »

howardpc

  • Hero Member
  • *****
  • Posts: 3646
Re: Showing all compiler notes
« Reply #2 on: December 02, 2020, 07:31:55 pm »
What OkabaPatino writes is true: Lazarus, whatever level of verbosity is chosen, continues to filter out certain compiler messages. In this case a Note.
I suspect, like OkabaPatino, it is because there are two messages relating to a single line of code.

Thaddy

  • Hero Member
  • *****
  • Posts: 10707
Re: Showing all compiler notes
« Reply #3 on: December 02, 2020, 07:38:35 pm »
You can manually add -vn to the options. Lazarus should never ignore that. If it does, that's a bug.

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: Showing all compiler notes
« Reply #4 on: December 02, 2020, 07:51:38 pm »
I checked all -v flags and no luck.

Thaddy

  • Hero Member
  • *****
  • Posts: 10707
Re: Showing all compiler notes
« Reply #5 on: December 02, 2020, 08:48:21 pm »
-vn should show all notes and it does so when compiled from the command line with FPC. If it doesn't when adding it to Lazarus options it is a bug, so file a report. It should not filter out notes with -vn added. I can't use Lazarus atm. I tested FPC. I remember that Lazarus DOES support it through a specific dialog setting. That should also not filter notes when you explicitly told Lazarus to show them.
« Last Edit: December 02, 2020, 08:51:50 pm by Thaddy »

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: Showing all compiler notes
« Reply #6 on: December 03, 2020, 07:56:36 am »

 

TinyPortal © 2005-2018