From 94661daf456043e6c178ef37da074487a1eb83c8 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Thu, 26 Sep 2019 16:26:29 +0200 Subject: [PATCH] Fixed coder function generation for base types with inherited 'encode' attributes (bug 550623) Change-Id: I9e0a7f54f6c4e70ef7cd046a751da7e1e06326a2 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/Type.cc | 18 ++++++- .../compileonly/Bug550623/.gitignore | 4 ++ .../compileonly/Bug550623/Bug550623.ttcn | 32 ++++++++++++ .../compileonly/Bug550623/Makefile | 50 +++++++++++++++++++ regression_test/compileonly/Makefile | 3 +- 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 regression_test/compileonly/Bug550623/.gitignore create mode 100644 regression_test/compileonly/Bug550623/Bug550623.ttcn create mode 100644 regression_test/compileonly/Bug550623/Makefile diff --git a/compiler2/Type.cc b/compiler2/Type.cc index 4602ccca5..6e8efcf1f 100644 --- a/compiler2/Type.cc +++ b/compiler2/Type.cc @@ -7580,7 +7580,23 @@ namespace Common { t = t->get_type_refd(); } else { - return string(); + switch (t->get_typetype_ttcn3()) { + case T_NULL: + case T_BOOL: + case T_INT: + case T_REAL: + case T_ENUM_T: + case T_BSTR: + case T_HSTR: + case T_OSTR: + case T_CSTR: + case T_USTR: + case T_OID: + // if the type is a base type, then it needs its own coder functions + return t->get_genname_own(p_scope); + default: + return string(); + } } } } diff --git a/regression_test/compileonly/Bug550623/.gitignore b/regression_test/compileonly/Bug550623/.gitignore new file mode 100644 index 000000000..d1453ab27 --- /dev/null +++ b/regression_test/compileonly/Bug550623/.gitignore @@ -0,0 +1,4 @@ +Bug550623 +Bug550623.exe +Bug550623*.cc +Bug550623*.hh diff --git a/regression_test/compileonly/Bug550623/Bug550623.ttcn b/regression_test/compileonly/Bug550623/Bug550623.ttcn new file mode 100644 index 000000000..2dffebf10 --- /dev/null +++ b/regression_test/compileonly/Bug550623/Bug550623.ttcn @@ -0,0 +1,32 @@ +/****************************************************************************** + * Copyright (c) 2000-2019 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + * + * Contributors: + * Baranyi, Botond + * + ******************************************************************************/ + +// the decoder functions for base types, that inherit 'encode' attributes from a higher scope +// (in this case the parent record), weren't generated, and their usages were generated incorrectly (bug 550623) +module Bug550623 { + +type record templateHexstr_rec { + hexstring x1, + hexstring x2, + hexstring x3 optional +} +with { + encode "RAW"; +} + +template templateHexstr_rec templateHexstr_tDecmatchSelfRef := { + x1 := '01A'H, + x2 := decmatch templateHexstr_tDecmatchSelfRef.x1, + x3 := decmatch templateHexstr_rec: { x1 := templateHexstr_tDecmatchSelfRef.x1, x2 := ?, x3 := * } +}; + +} diff --git a/regression_test/compileonly/Bug550623/Makefile b/regression_test/compileonly/Bug550623/Makefile new file mode 100644 index 000000000..2b2b02e35 --- /dev/null +++ b/regression_test/compileonly/Bug550623/Makefile @@ -0,0 +1,50 @@ +############################################################################## +# Copyright (c) 2000-2019 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html +# +# Contributors: +# Botond, Baranyi +# +############################################################################## +TOPDIR := ../.. +include $(TOPDIR)/Makefile.regression + +.PHONY: all clean dep + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = Bug550623.ttcn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) +ifdef CODE_SPLIT +GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) +else ifdef SPLIT_TO_SLICES +POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) +POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) +GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) +GENERATED_SOURCES += $(GENERATED_SOURCES2) +endif + +OBJECTS = $(GENERATED_SOURCES:.cc=.o) + +TARGET = Bug550623$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ + -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ + +clean distclean: + $(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) compile *.log + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) diff --git a/regression_test/compileonly/Makefile b/regression_test/compileonly/Makefile index 6be5170b4..37e209bf1 100644 --- a/regression_test/compileonly/Makefile +++ b/regression_test/compileonly/Makefile @@ -30,7 +30,8 @@ CODIRS := dynamicTemplate styleGuide topLevelPdu \ defaultParamUsageBeforeDecl deterministic readFromFile \ asn1_hyphen nameClash portTranslation UntaggedOnTopLevelUnionSwitch \ typeDescrGenWIthNoXER languageSpec asn1_opentype openTypeXER \ - asnStringSubtypes componentParameter realtimeKeywords Bug550526 + asnStringSubtypes componentParameter realtimeKeywords Bug550526 \ + Bug550623 ifdef DYN CODIRS += mfgen-xsd -- GitLab