diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc index 37f30769cb077a4196c9ec52434590c2dfb25ef1..66328c6cc73159caebad4f1ab8a78285125607e6 100644 --- a/compiler2/subtype.cc +++ b/compiler2/subtype.cc @@ -1825,7 +1825,9 @@ void SubType::chk_this_value(Value *value) case Value::V_CSTR: case Value::V_ISO2022STR: if (subtype!=ST_CHARSTRING) FATAL_ERROR("SubType::chk_this_value()"); - is_invalid = (charstring_st!=NULL) && !charstring_st->is_element(val->get_val_str()); + is_invalid = (charstring_st!=NULL) && (val->get_valuetype() == Value::V_CSTR ? + !charstring_st->is_element(val->get_val_str()) : + !charstring_st->is_element(val->get_val_iso2022str())); break; case Value::V_USTR: case Value::V_CHARSYMS: diff --git a/regression_test/compileonly/Makefile b/regression_test/compileonly/Makefile index 7ec82dcf2e70ddc19a1545f476978009a46ec7f1..b072ec44cd368c457682f8b69ed62258ae83c1b5 100644 --- a/regression_test/compileonly/Makefile +++ b/regression_test/compileonly/Makefile @@ -29,7 +29,8 @@ CODIRS := dynamicTemplate styleGuide topLevelPdu \ attribQualif HT48786 selectCase openTypeNames \ defaultParamUsageBeforeDecl deterministic readFromFile \ asn1_hyphen nameClash portTranslation UntaggedOnTopLevelUnionSwitch \ - typeDescrGenWIthNoXER languageSpec asn1_opentype openTypeXER + typeDescrGenWIthNoXER languageSpec asn1_opentype openTypeXER \ + asnStringSubtypes ifdef DYN CODIRS += mfgen-xsd diff --git a/regression_test/compileonly/asnStringSubtypes/.gitignore b/regression_test/compileonly/asnStringSubtypes/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4b256b5380f3b17dfaa6916c481648a3160fc4fe --- /dev/null +++ b/regression_test/compileonly/asnStringSubtypes/.gitignore @@ -0,0 +1,7 @@ +stringSubtypes +stringSubtypes.exe +StringSubtypes*.cc +StringSubtypes*.hh +Values*.cc +Values*.hh +stringSubtypes*.log diff --git a/regression_test/compileonly/asnStringSubtypes/Makefile b/regression_test/compileonly/asnStringSubtypes/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a3bfc6b9a9a09ce1371146807d6cab13c00d8fb3 --- /dev/null +++ b/regression_test/compileonly/asnStringSubtypes/Makefile @@ -0,0 +1,54 @@ +############################################################################## +# 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 – initial implementation +# +############################################################################## +TOPDIR := ../.. +include $(TOPDIR)/Makefile.regression + +.SUFFIXES: .ttcn .asn .hh +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = Values.ttcn + +ASN1_MODULES = StringSubtypes.asn + +GENERATED_SOURCES = $(ASN1_MODULES:.asn=.cc) $(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 = stringSubtypes$(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): compile + +compile: $(TTCN3_MODULES) $(ASN1_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ + +clean distclean: + $(RM) $(TARGET) $(GENERATED_HEADERS) $(GENERATED_SOURCES) $(OBJECTS) *.log Makefile.bak + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) diff --git a/regression_test/compileonly/asnStringSubtypes/StringSubtypes.asn b/regression_test/compileonly/asnStringSubtypes/StringSubtypes.asn new file mode 100644 index 0000000000000000000000000000000000000000..c624603d954f911ecbd7fcac6092bb487c638ae5 --- /dev/null +++ b/regression_test/compileonly/asnStringSubtypes/StringSubtypes.asn @@ -0,0 +1,43 @@ +--///////////////////////////////////////////////////////////////////////////// +-- 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 +-- +--///////////////////////////////////////////////////////////////////////////// + +StringSubtypes +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + + +-- Types + +TeletexStringRestricted ::= TeletexString (SIZE(4)) + +VideotexStringRestricted ::= VideotexString (SIZE(1..10)) + +GraphicStringRestricted ::= GraphicString (SIZE(0..3)) + +T61StringRestricted ::= T61String (SIZE(5)) + +GeneralStringRestricted ::= GeneralString (SIZE(1)) + +ObjectDescriptorRestricted ::= ObjectDescriptor (SIZE(2..4)) + +-- Values + +val T61StringRestricted ::= "abcde" + +END diff --git a/regression_test/compileonly/asnStringSubtypes/Values.ttcn b/regression_test/compileonly/asnStringSubtypes/Values.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..db2d20f8182326cdae18f8f0add052bb6cb0dca6 --- /dev/null +++ b/regression_test/compileonly/asnStringSubtypes/Values.ttcn @@ -0,0 +1,32 @@ +/****************************************************************************** + * 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 Values { + +import from StringSubtypes all; + +function f() { + var TeletexStringRestricted x; + x := "ttxx"; +} + +const VideotexStringRestricted c := "aaaaa"; + +template GraphicStringRestricted t := "gr"; + +modulepar ObjectDescriptorRestricted mp := "xyz"; + +control { + var template GeneralStringRestricted vt := "Q"; +} + +}