From ad4ad8290876d7d2fb15a7f3e8fa7319c7371fcb Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 17 Feb 2018 19:57:50 +0000 Subject: [PATCH] * prevent crash on not yet supported attribute declarations, resolves #32075 git-svn-id: trunk@38272 - --- .gitattributes | 1 + compiler/pdecvar.pas | 2 +- tests/webtbf/tw32075.pp | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/webtbf/tw32075.pp diff --git a/.gitattributes b/.gitattributes index c0ee2f7920..a67e3b2ee6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14349,6 +14349,7 @@ tests/webtbf/tw3186.pp svneol=native#text/plain tests/webtbf/tw31973.pp svneol=native#text/pascal tests/webtbf/tw32043b.pp svneol=native#text/pascal tests/webtbf/tw32043c.pp svneol=native#text/pascal +tests/webtbf/tw32075.pp svneol=native#text/pascal tests/webtbf/tw3218.pp svneol=native#text/plain tests/webtbf/tw3241.pp svneol=native#text/plain tests/webtbf/tw32412a.pp svneol=native#text/pascal diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas index 5e74efa72a..7a079aedec 100644 --- a/compiler/pdecvar.pas +++ b/compiler/pdecvar.pas @@ -175,7 +175,7 @@ implementation begin consume(_LECKKLAMMER); repeat - if def.typ=arraydef then + if assigned(def) and (def.typ=arraydef) then begin idx:=0; p:=comp_expr([ef_accept_equal]); diff --git a/tests/webtbf/tw32075.pp b/tests/webtbf/tw32075.pp new file mode 100644 index 0000000000..1622d1082e --- /dev/null +++ b/tests/webtbf/tw32075.pp @@ -0,0 +1,20 @@ +{ %fail } +program compilercrash; +// This code is nonsense a.t.m. but it crashes the compiler. +{$mode objfpc} +uses classes; +type +{$M+} +Tmyclass = class(Tpersistent) +private + FDetachable:Boolean; + procedure setdetachable(const aValue:Boolean); +public + property Detachable: Boolean read FDetachable write SetDetachable + ['widgetsets:qt,gtk,win32', 'implementor:Vasya Pupkin', 'creation-date:01.01.2007']; +end; + +begin +{ the initial purpose of this test was that the compiler shouldn't crash on the attribute above, + however, as soon as attributes are implemented, it will succeed, so cause always an error at the end } +end;