Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • T titan.core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 112
    • Issues 112
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Eclipse ProjectsEclipse Projects
  • Eclipse Titan
  • titan.core
  • Issues
  • #604
Closed
Open
Issue created May 12, 2022 by Botond Baranyi@bbaranyiDeveloper

OOP: issues with parameter default values and inheritance

Summary

The code generated for the following TTCN-3 module produces several C++ compilation errors (details below).

Steps and/or TTCN-3 code to reproduce

type component CT { }

type class @trait CommonInterface {
  public function @abstract f_do_common(charstring p_test/* := "test"*/);
}

type class @abstract Base extends CommonInterface {
 public function f_do_common(charstring p_test:="test") {
    log("called from Base: "&p_test)
  } 
}

type class @final Sub extends Base {
  public function f_do_common(charstring p_test:="test") {
    log("called from Sub: "&p_test);
  } 
}

testcase tc() runs on CT {
  var Sub sub := Sub.create();
  sub.f_do_common();
  sub.f_do_common("test2");
}

control {
  execute(tc())
}

What is the current bug behavior?

There are 3 issues in the generated code:

  1. The parameter default values generated for functions 'Base.f_do_common' and 'Sub.f_do_common' have the same name: 'f__do__common_p__test_defval'.
  2. The type of the parameter in the 3 'f_do_common' functions are different (wrapper types are generated for parameters with default values in class methods, so they can contain references to class members). Because of this, the 3 'f_do_common' functions are interpreted as different functions by the C++ compiler, which results in 'Sub' being interpreted as an abstract class.
  3. Class 'Base' inherits both 'CommonInterface' and the built-in class 'object'. Both of these inherit a separate version of 'CLASS_BASE' in C++. The compiler can't decide which of the reference counter functions ('add_ref' and 'remove_ref') inherited from 'CLASS_BASE' it should call.

What is the expected correct behavior?

The generated code should compile successfully.

Relevant logs and/or screenshots

Possible fixes

Titan version

8.2.0

Platform details (OS type and version)

Ubuntu 20.04.1

/cc @aknappqwt

Edited May 13, 2022 by Miklos Magyari
Assignee
Assign to
Time tracking

Copyright © Eclipse Foundation, Inc. All Rights Reserved.     Privacy Policy | Terms of Use | Copyright Agent