From b9b95a8f736208b4796e2510b88d2e2029e5ee72 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 8 Dec 2009 17:15:31 +0000 Subject: [PATCH] * fixed compiler crash when putting non-constant string in a set expression (mantis #15288) git-svn-id: trunk@14367 - --- .gitattributes | 1 + compiler/ncnv.pas | 4 +++- tests/webtbf/tw15288.pp | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/webtbf/tw15288.pp diff --git a/.gitattributes b/.gitattributes index 29c7e4eaef..1e8cbc7380 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9493,6 +9493,7 @@ tests/webtbf/tw14849.pp svneol=native#text/plain tests/webtbf/tw14929a.pp svneol=native#text/plain tests/webtbf/tw14929b.pp svneol=native#text/plain tests/webtbf/tw14946.pp svneol=native#text/plain +tests/webtbf/tw15288.pp svneol=native#text/plain tests/webtbf/tw1599.pp svneol=native#text/plain tests/webtbf/tw1599b.pp svneol=native#text/plain tests/webtbf/tw1633.pp svneol=native#text/plain diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index a8c1dcc12f..6968d91c8f 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -515,9 +515,11 @@ implementation stringdef : begin + if (p2.nodetype<>stringconstn) then + Message(parser_e_illegal_expression) { if we've already set elements which are constants } { throw an error } - if ((hdef=nil) and assigned(buildp)) or + else if ((hdef=nil) and assigned(buildp)) or not(is_char(hdef)) then CGMessage(type_e_typeconflict_in_set) else diff --git a/tests/webtbf/tw15288.pp b/tests/webtbf/tw15288.pp new file mode 100644 index 0000000000..ec5271a22b --- /dev/null +++ b/tests/webtbf/tw15288.pp @@ -0,0 +1,26 @@ +{ %fail } + +program setcrash; + +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +var + AString: String='blabla'; + +procedure GetKey(var Key: Char); +begin + if Key in ['c', AString] then + writeln('OK'); +end; + +var + AKey: Char; +begin + AKey := 'c'; + GetKey(AKey); +end. + +