From b14c6db4e546bf7291d67cb27c6326a8f8e29d9e Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Fri, 16 Nov 2018 10:38:17 +0100 Subject: [PATCH] Fixed importing of ASN.1 identifiers that match realtime keywords, when the feature is disabled (bug 539514) Change-Id: Iebb66c2b92db4fa6e75126166a7c62d3a437a66f Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/Identifier.cc | 19 +++++++++++--- .../compileonly/realtimeKeywords/.gitignore | 2 ++ .../compileonly/realtimeKeywords/Makefile | 6 +++-- .../realtimeKeywords/RealtimeKeywordsAsn.asn | 25 +++++++++++++++++++ .../realtimeKeywords/realtimeKeywords.ttcn | 7 ++++-- 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn diff --git a/compiler2/Identifier.cc b/compiler2/Identifier.cc index 2333ee8a1..e8196f39f 100644 --- a/compiler2/Identifier.cc +++ b/compiler2/Identifier.cc @@ -22,6 +22,7 @@ #include <ctype.h> #include "Setting.hh" #include "CompilerError.hh" +#include "main.hh" namespace Common { @@ -96,6 +97,7 @@ namespace Common { private: static internal_data_t *instance; static const char* const keywords[][3]; + static const char* const realtime_keywords[][3]; size_t identifier_counter; public: const string string_invalid; @@ -802,7 +804,6 @@ namespace Common { {"noblock__", "noblock", "noblock_"}, {"none__", "none", "none_"}, {"not4b__", "not4b", "not4b_"}, - {"now__", "now", "now_"}, {"nowait__", "nowait", "nowait_"}, {"null__", "null", "null_"}, {"objid__", "objid", "objid_"}, @@ -822,7 +823,6 @@ namespace Common { {"procedure__", "procedure", "procedure_"}, {"raise__", "raise", "raise_"}, {"read__", "read", "read_"}, - {"realtime__", "realtime", "realtime_"}, {"receive__", "receive", "receive_"}, {"record__", "record", "record_"}, {"recursive__", "recursive", "recursive_"}, @@ -846,7 +846,6 @@ namespace Common { {"testcase__", "testcase", "testcase_"}, {"timeout__", "timeout", "timeout_"}, {"timer__", "timer", "timer_"}, - {"timestamp__", "timestamp", "timestamp_"}, {"to__", "to", "to_"}, {"trigger__", "trigger", "trigger_"}, {"type__", "type", "type_"}, @@ -869,6 +868,15 @@ namespace Common { /* the last must be all zeros */ {0, 0, 0} }; // keywords + + // keywords for the real-time testing feature + // (can be switched on or off with a command line option) + const char* const internal_data_t::realtime_keywords[][3] = { + {"now__", "now", "now_"}, + {"realtime__", "realtime", "realtime_"}, + {"timestamp__", "timestamp", "timestamp_"}, + {0, 0, 0} + }; internal_data_t::internal_data_t() : identifier_counter(0), string_invalid("<invalid>"), id_map_name(), @@ -973,6 +981,11 @@ namespace Common { Error_Context cntx(&loc, "While adding keywords"); for(size_t i=0; keywords[i][0]; i++) add_keyword(keywords[i]); + if (realtime_features) { + for(size_t i=0; realtime_keywords[i][0] != 0; i++) { + add_keyword(realtime_keywords[i]); + } + } } /* Perhaps it were good to read a file which contains user-defined mappings :) */ diff --git a/regression_test/compileonly/realtimeKeywords/.gitignore b/regression_test/compileonly/realtimeKeywords/.gitignore index 311f6e289..d4a23b857 100644 --- a/regression_test/compileonly/realtimeKeywords/.gitignore +++ b/regression_test/compileonly/realtimeKeywords/.gitignore @@ -2,3 +2,5 @@ realtimeKeywords realtimeKeywords.exe realtimeKeywords*.cc realtimeKeywords*.hh +RealtimeKeywordsAsn*.cc +RealtimeKeywordsAsn*.hh diff --git a/regression_test/compileonly/realtimeKeywords/Makefile b/regression_test/compileonly/realtimeKeywords/Makefile index b8db0f70b..c09cd453e 100644 --- a/regression_test/compileonly/realtimeKeywords/Makefile +++ b/regression_test/compileonly/realtimeKeywords/Makefile @@ -18,7 +18,9 @@ TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) TTCN3_MODULES = realtimeKeywords.ttcn -GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +ASN1_MODULES = RealtimeKeywordsAsn.asn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.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)) @@ -39,7 +41,7 @@ $(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) +$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) $(ASN1_MODULES) $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ clean distclean: diff --git a/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn b/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn new file mode 100644 index 000000000..262a06346 --- /dev/null +++ b/regression_test/compileonly/realtimeKeywords/RealtimeKeywordsAsn.asn @@ -0,0 +1,25 @@ +--///////////////////////////////////////////////////////////////////////////// +-- Copyright (c) 2000-2018 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 +-- +--///////////////////////////////////////////////////////////////////////////// +RealtimeKeywordsAsn +DEFINITIONS ::= +BEGIN + +IMPORTS ; -- nothing + +Seq ::= SEQUENCE { + now REAL, + realtime BOOLEAN +} + +timestamp INTEGER ::= 5 + +END diff --git a/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn b/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn index df6ad4dfa..3a8b3bd13 100644 --- a/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn +++ b/regression_test/compileonly/realtimeKeywords/realtimeKeywords.ttcn @@ -14,12 +14,15 @@ // feature is disabled (for backward compatibility). module realtimeKeywords { +import from RealtimeKeywordsAsn all; + type record realtime {} template boolean now := true; -function timestamp() return float { - return -1.0; +function timestamp() return Seq { + var integer x := RealtimeKeywordsAsn.timestamp; + return { now := -1.0, realtime := false }; } } -- GitLab