[fpc-devel] extend unreachable code warning for more cases?

2014-02-26 Thread Sven Barth

Hello together!

In context of Apple's recent security bug where a goto fail; at the 
wrong place disabled certificate checking or something along that lines 
I've thought whether it would 1) be worthwhile to extend FPC with the 
capability to detect such cases as well and 2) to see whether it would 
be currently feasible at all.


So, how hard would it be to let the compiler detect cases like these:

=== code begin ===

procedure Test1;
begin
  Writeln('Test1');
  Exit;
  Writeln('Test1');
end;

procedure Test2;
label
  stop;
begin
  Writeln('Test2');
  goto stop;
  Writeln('Test2');
stop:
end;

=== code end ===

and of course potentially more complex ones...

Also would you think it would be worthwhile to spend time on this?

Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] extend unreachable code warning for more cases?

2014-02-26 Thread Sergei Gorelkin

26.02.2014 12:09, Sven Barth пишет:

Hello together!

In context of Apple's recent security bug where a goto fail; at the wrong 
place disabled
certificate checking or something along that lines I've thought whether it 
would 1) be worthwhile to
extend FPC with the capability to detect such cases as well and 2) to see 
whether it would be
currently feasible at all.

So, how hard would it be to let the compiler detect cases like these:

=== code begin ===

procedure Test1;
begin
   Writeln('Test1');
   Exit;
   Writeln('Test1');
end;

procedure Test2;
label
   stop;
begin
   Writeln('Test2');
   goto stop;
   Writeln('Test2');
stop:
end;

=== code end ===

and of course potentially more complex ones...

Also would you think it would be worthwhile to spend time on this?



The definite assignment analysis ported by me four years ago 
(http://bugs.freepascal.org/view.php?id=15523) detects all cases of unreachable code, except 
backward goto's. Everything but backward goto's is almost trivial, backward goto's are more 
complicated because they require multiple iterations over code tree, but are certainly feasible.


Regards,
Sergei


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] extend unreachable code warning for more cases?

2014-02-26 Thread Sven Barth

Am 26.02.2014 09:41, schrieb Sergei Gorelkin:

26.02.2014 12:09, Sven Barth пишет:

Hello together!

In context of Apple's recent security bug where a goto fail; at the 
wrong place disabled
certificate checking or something along that lines I've thought 
whether it would 1) be worthwhile to
extend FPC with the capability to detect such cases as well and 2) to 
see whether it would be

currently feasible at all.

So, how hard would it be to let the compiler detect cases like these:

=== code begin ===

procedure Test1;
begin
   Writeln('Test1');
   Exit;
   Writeln('Test1');
end;

procedure Test2;
label
   stop;
begin
   Writeln('Test2');
   goto stop;
   Writeln('Test2');
stop:
end;

=== code end ===

and of course potentially more complex ones...

Also would you think it would be worthwhile to spend time on this?



The definite assignment analysis ported by me four years ago 
(http://bugs.freepascal.org/view.php?id=15523) detects all cases of 
unreachable code, except backward goto's. Everything but backward 
goto's is almost trivial, backward goto's are more complicated because 
they require multiple iterations over code tree, but are certainly 
feasible.
Nice... does that code still work with current trunk? How does it look 
in light of Florian's recent work on SSA? (though it's not yet fully in 
trunk AFAIK) Could your DFA be combined combined with the current DFA so 
that we would have both definite assignment analysis and live variable 
analysis? [ok, after reading your first comment it should be possible] 
Since you now have write access to SVN you could finally use a branch 
for this. :)


Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] extend unreachable code warning for more cases?

2014-02-26 Thread Sergei Gorelkin

26.02.2014 13:28, Sven Barth пишет:

Am 26.02.2014 09:41, schrieb Sergei Gorelkin:

26.02.2014 12:09, Sven Barth пишет:

Hello together!

In context of Apple's recent security bug where a goto fail; at the wrong 
place disabled
certificate checking or something along that lines I've thought whether it 
would 1) be worthwhile to
extend FPC with the capability to detect such cases as well and 2) to see 
whether it would be
currently feasible at all.

So, how hard would it be to let the compiler detect cases like these:

=== code begin ===

procedure Test1;
begin
   Writeln('Test1');
   Exit;
   Writeln('Test1');
end;

procedure Test2;
label
   stop;
begin
   Writeln('Test2');
   goto stop;
   Writeln('Test2');
stop:
end;

=== code end ===

and of course potentially more complex ones...

Also would you think it would be worthwhile to spend time on this?



The definite assignment analysis ported by me four years ago
(http://bugs.freepascal.org/view.php?id=15523) detects all cases of unreachable 
code, except
backward goto's. Everything but backward goto's is almost trivial, backward 
goto's are more
complicated because they require multiple iterations over code tree, but are 
certainly feasible.

Nice... does that code still work with current trunk?

Didn't test it, but should not be difficult to fix anyway.


How does it look in light of Florian's recent work on SSA? (though it's not yet 
fully in trunk AFAIK)
They are probably two independent things. I've abandoned experiments with trying to use definite 
assignment analysis to determine variable lifetime.



Regards,
Sergei


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Class property and virtual getter

2014-02-26 Thread luiz americo pereira camara
TSimpleModel = class(TPersistent)
  protected
class function GetResourceClient: IResourceClient; virtual;
class property ResourceClient: IResourceClient read GetResourceClient;
  public
  end;

Trying to compile the above code i get the following error:
Error: Illegal symbol for property access

Changing the GetResourceClient method from virtual to static works

Is this a bug or by design?

Luiz
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel