Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-03

Disable Warning: (6060) Case statement does not handle all possible cases

10 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jonas Maebe
to fredvs
fredvs wrote 7 lines
So doing this: > unit myunit; > {$warn 6060 off} Still gives some "Warning: (6060) Case statement does not handle all possible cases"

It works for me:

$ cat tt.pp
{$warn 6060 off}
var
  b: 1..10;
begin
  case b of
    1: writeln('hello');
  end
end.

$ ppcx20 -l -vwq tt
Free Pascal Compiler version 3.3.1 [2020/02/15] for x86_64 Copyright (c) 1993-2020 by Florian Klaempfl and others (1002) Target OS: Darwin for x86_64
(3104) Compiling tt.pp
tt.pp(6,8) Warning: (5037) Variable "b" does not seem to be initialized (9009) Assembling program
(9015) Linking tt
(1008) 9 lines compiled, 0.1 sec
(1021) 1 warning(s) issued

Jonas

Reply by email

Jonas Maebe
to fredvs
fredvs wrote 8 lines
> It works for me: > $ cat tt.pp > {$warn 6060 off} Ha, on Linux too? By the way, what is "$ cat tt.pp", is it needed to disable the warning?

"cat" is a program that shows the contents of a file. It was to show you the source code that I was compiling.

And where did you place the code, just after "units" like explained in doc.

It was placed where you can see it in the program (it's a program, not a unit).

Will it disable all the warnings concerned for all the code of the unit?

Yes.

Jonas

Reply by email

Jonas Maebe
to fredvs
fredvs wrote
>> Will it disable all the warnings concerned for all the code of the unit? > Yes. Hum, here, adding {$warn 6060 off} after "unit", on Linux 64 bit, compiled with fpc 3.3.1 trunk of 7 days ago, the warnings are still there.

If you have a uses clause, try adding it after the uses clause.

Jonas

Reply by email

Jonas Maebe
to fredvs
fredvs wrote 5 lines
> It works for me: It seems that you did try to use {$warn 6060 off} in a program-file. But did you try with a unit-file?
$ cat tt.pp
unit tt;
{$warn 6060 off}
interface
uses
  sysutils;
implementation
procedure test;
var
  b: 1..10;
begin
  case b of
    1: writeln('hello');
  end
end;
end.

$ ../compiler/ppcx64 -l -vw tt
Free Pascal Compiler version 3.3.1 [2020/03/27] for x86_64 Copyright (c) 1993-2020 by Florian Klaempfl and others Target OS: Darwin for x86_64
Compiling tt.pp
tt.pp(16,8) Warning: Local variable "b" does not seem to be initialized Assembling tt
21 lines compiled, 0.1 sec
1 warning(s) issued

Jonas

Reply by email

fredvs
to Jonas Maebe: If you have a uses clause, try adding it after the uses clause. Jonas
If you have a uses clause, try adding it after the uses clause.

Yep, indeed that did the trick.
But note also that it must be after the "uses" clause after "implementation" (otherwise after first "uses" it does not work).

Also, to make earlier fpc versions happy, this must be added:

{$if fpc_fullversion >= 030300}
  {$warn 6060 off}
{$endif}

OK, thanks Jonas.

Fre;D

-----
Many thanks ;-)

Reply by email