From 88dba5f9df81efd6921a2135590e73ec940926e0 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Thu, 15 Feb 2018 10:14:43 +0100 Subject: [PATCH] Fixed segmentation fault caused by name reuse (TR# 902064) Change-Id: I94fe211439f312aa9fa24564b381f8b312e49c7f Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/ttcn3/AST_ttcn3.cc | 2 +- .../template/TempImp_OK.ttcn | 17 +++++++++++++++++ .../template/TempNameReuse_SE.ttcn | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 function_test/Semantic_Analyser/template/TempImp_OK.ttcn create mode 100644 function_test/Semantic_Analyser/template/TempNameReuse_SE.ttcn diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index c1d1fa353..acbbab69a 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -4311,6 +4311,7 @@ namespace Ttcn { void Def_Template::chk() { if (checked) return; + checked = true; Error_Context cntxt(this, "In template definition `%s'", id->get_dispname().c_str()); const string& t_genname = get_genname(); @@ -4350,7 +4351,6 @@ namespace Ttcn { } type->chk_this_template_ref(body); - checked = true; Type *t = type->get_type_refd_last(); if (t->get_typetype() == Type::T_PORT) { error("Template cannot be defined for port type `%s'", diff --git a/function_test/Semantic_Analyser/template/TempImp_OK.ttcn b/function_test/Semantic_Analyser/template/TempImp_OK.ttcn new file mode 100644 index 000000000..f29bdeb63 --- /dev/null +++ b/function_test/Semantic_Analyser/template/TempImp_OK.ttcn @@ -0,0 +1,17 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Baranyi, Botond + * + ******************************************************************************/ + +module TempImp_OK { + +type integer T; + +} diff --git a/function_test/Semantic_Analyser/template/TempNameReuse_SE.ttcn b/function_test/Semantic_Analyser/template/TempNameReuse_SE.ttcn new file mode 100644 index 000000000..03831f159 --- /dev/null +++ b/function_test/Semantic_Analyser/template/TempNameReuse_SE.ttcn @@ -0,0 +1,19 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Baranyi, Botond + * + ******************************************************************************/ + +module TempNameReuse_SE { //^In TTCN-3 module// + +import from TempImp_OK all; + +template T T := 1; //^In template definition// //is not a reference to a type// + +} -- GitLab