From c0791b46d94e1500237ab6ae8d51f3f846db8a2d Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Fri, 5 Feb 2021 19:32:36 -0600 Subject: [PATCH] icg default constructor is deleted (#1109) * check if default constructor is deleted #1094 * unit test icg deleted default constructor #1094 * Update centos 7 swig version to 3.0 to support deleted function in SIM_deleted_default_constructor test Co-authored-by: Fennell, Scott P 263712616 closes #1094 --- .github/workflows/test_32.yml | 2 +- .github/workflows/test_linux.yml | 5 +++- .../install_guide/Install-Guide.md | 28 +++++++++---------- .../RUN_test/input.py | 3 ++ test/SIM_delete_default_constructor/S_define | 22 +++++++++++++++ .../S_overrides.mk | 3 ++ .../models/empty.cpp | 1 + .../models/empty.h | 12 ++++++++ .../models/starter.cpp | 6 ++++ .../models/starter.h | 14 ++++++++++ test/makefile | 1 + .../Interface_Code_Gen/ClassVisitor.cpp | 2 +- 12 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 test/SIM_delete_default_constructor/RUN_test/input.py create mode 100644 test/SIM_delete_default_constructor/S_define create mode 100644 test/SIM_delete_default_constructor/S_overrides.mk create mode 100644 test/SIM_delete_default_constructor/models/empty.cpp create mode 100644 test/SIM_delete_default_constructor/models/empty.h create mode 100644 test/SIM_delete_default_constructor/models/starter.cpp create mode 100644 test/SIM_delete_default_constructor/models/starter.h diff --git a/.github/workflows/test_32.yml b/.github/workflows/test_32.yml index cabe16c0..2a0433a5 100644 --- a/.github/workflows/test_32.yml +++ b/.github/workflows/test_32.yml @@ -20,7 +20,7 @@ jobs: run: yum -y groupinstall "Development tools" && yum -y update - name: Install other dependencies run: > - yum install -y llvm llvm-devel llvm-static clang clang-devel + yum remove -y swig && yum install -y llvm llvm-devel llvm-static clang clang-devel bison flex gcc gcc-c++ libxml2-devel make cmake wget ncurses-devel openmotif openmotif-devel python-devel perl perl-Digest-MD5 swig3 zlib-devel glibc.x86_64 libxml2-devel.i686 diff --git a/.github/workflows/test_linux.yml b/.github/workflows/test_linux.yml index f5639d9c..47300822 100644 --- a/.github/workflows/test_linux.yml +++ b/.github/workflows/test_linux.yml @@ -34,7 +34,6 @@ jobs: llvm make maven - swig cmake install_gtest: echo gtest already installed conf_pkg: echo package manager already configured @@ -44,6 +43,7 @@ jobs: pkg_mgr: apt-get conf_pkg: apt-get update arch_deps: >- + swig curl g++ libx11-dev @@ -97,6 +97,7 @@ jobs: - cfg: { os: fedora } pkg_mgr: dnf os_deps: >- + swig perl-Text-Balanced python-devel diffutils @@ -108,6 +109,7 @@ jobs: python3.8-dev - cfg: { os: centos, tag: 7 } tag_deps: >- + swig3 python-devel - cfg: { os: centos, tag: latest } pkg_mgr: dnf @@ -117,6 +119,7 @@ jobs: dnf install -y 'dnf-command(config-manager)' && dnf config-manager --enable powertools tag_deps: >- + swig python3-devel diffutils #-------- Job definition ---------------- runs-on: ubuntu-18.04 diff --git a/docs/documentation/install_guide/Install-Guide.md b/docs/documentation/install_guide/Install-Guide.md index b9f52691..fc27d15b 100644 --- a/docs/documentation/install_guide/Install-Guide.md +++ b/docs/documentation/install_guide/Install-Guide.md @@ -5,20 +5,20 @@ This document will walk you through the process of installing Trick on your computer. Please read each section carefully. # Package Dependencies -Trick requires various free third party utilities in order to function. All the following products are used by Trick and may already be installed as part of your OS distribution. **Install any missing dependencies with your operating system's [package manager](https://en.wikipedia.org/wiki/Package_manager).** For most operating systems, the default version of a dependency will be compatitable with Trick. Please check the specific OS instructions below for your operating system for more details. +Trick requires various free third party utilities in order to function. All the following products are used by Trick and may already be installed as part of your OS distribution. **Install any missing dependencies with your operating system's [package manager](https://en.wikipedia.org/wiki/Package_manager).** For most operating systems, the default version of a dependency will be compatitable with Trick. **We strongly recommend that you use your package manager's default versions if they meet Trick's requirements.** Please check the specific OS instructions below for your operating system for more details. -| Utility | Version | Description | Usage | -|----------------:|:---------:|:-------------------------:|:--------------------------------------------------------------| -| [gcc] and g++ | 4.8+ | C/C++ Compiler | Compiles Trick and Trick simulations. | -| [clang]/[llvm] | 3.4.2+ | C/C++ Compiler | Utilized by the interface code generator. | -| [python] | 2.7+ | Programming Language | Lets the user interact with a simulation. | -| [perl] | 5.6+ | Programming Language | Allows executable scripts in the bin directory to run. | -| [java] | 11+ | Programming Language | Necessary for Trick GUIs. | -| [swig] | 2.0+ | Language Interfacing | Connects the python input processor with Trick's C code. | -| [make] | 3.78+ | Build Automation | Automates the building and cleaning of Trick. | -| [openmotif] | 2.2.0+ | GUI Toolkit | Covers Trick GUIs not made with Java. | -| [udunits] | 2.x+ | C Unit Library/Database | Provides support for units of physical quantities. | -| [maven] | x.x | Java package manager | Downloads Java dependencies and builds trick GUIs | +| Utility | Version | Description | Usage | Notes | +|---------------:|:-------:|:-----------------------:|:---------------------------------------------------------:|:------------------------------------------------------| +| [gcc] and g++ | 4.8+ | C/C++ Compiler | Compiles Trick and Trick simulations. | | +| [clang]/[llvm] | 3.4.2+ | C/C++ Compiler | Utilized by the interface code generator. | | +| [python] | 2.7+ | Programming Language | Lets the user interact with a simulation. | Trick has been tested up to python 3.9 as of 02/21 | +| [perl] | 5.6+ | Programming Language | Allows executable scripts in the bin directory to run. | | +| [java] | 11+ | Programming Language | Necessary for Trick GUIs. | | +| [swig] | 2.0+ | Language Interfacing | Connects the python input processor with Trick's C code. | 3.0+ required for some unit tests in make test target | +| [make] | 3.78+ | Build Automation | Automates the building and cleaning of Trick. | | +| [openmotif] | 2.2.0+ | GUI Toolkit | Covers Trick GUIs not made with Java. | | +| [udunits] | 2.x+ | C Unit Library/Database | Provides support for units of physical quantities. | | +| [maven] | x.x | Java package manager | Downloads Java dependencies and builds trick GUIs | | [gcc]: https://gcc.gnu.org/ [clang]: https://clang.llvm.org/ @@ -109,7 +109,7 @@ Run yum -y install epel-release && yum -y update Trick also requires development packages from the base and epel repositories ```bash -yum install -y bison clang flex git llvm make maven swig cmake clang-devel \ +yum install -y bison clang flex git llvm make maven swig3 cmake clang-devel \ gcc gcc-c++ java-11-openjdk-devel libxml2-devel llvm-devel llvm-static \ ncurses-devel openmotif openmotif-devel perl perl-Digest-MD5 udunits2 \ udunits2-devel which zlib-devel gtest-devel libX11-devel libXt-devel python-devel diff --git a/test/SIM_delete_default_constructor/RUN_test/input.py b/test/SIM_delete_default_constructor/RUN_test/input.py new file mode 100644 index 00000000..4cde5c68 --- /dev/null +++ b/test/SIM_delete_default_constructor/RUN_test/input.py @@ -0,0 +1,3 @@ + + +trick.stop(0.5); diff --git a/test/SIM_delete_default_constructor/S_define b/test/SIM_delete_default_constructor/S_define new file mode 100644 index 00000000..57b2f7d0 --- /dev/null +++ b/test/SIM_delete_default_constructor/S_define @@ -0,0 +1,22 @@ +/************************TRICK HEADER************************* +PURPOSE: + () +LIBRARY DEPENDENCIES: +*************************************************************/ + +#include "sim_objects/default_trick_sys.sm" + +##include "starter.h" +##include "empty.h" + +class StarterSimObject : public Trick::SimObject { + + public: + Starter starter; + + StarterSimObject() : starter(5){ + + } +}; + +StarterSimObject starterSimObject; diff --git a/test/SIM_delete_default_constructor/S_overrides.mk b/test/SIM_delete_default_constructor/S_overrides.mk new file mode 100644 index 00000000..016cadcd --- /dev/null +++ b/test/SIM_delete_default_constructor/S_overrides.mk @@ -0,0 +1,3 @@ + +TRICK_CFLAGS += -I./models +TRICK_CXXFLAGS += -I./models -std=c++11 diff --git a/test/SIM_delete_default_constructor/models/empty.cpp b/test/SIM_delete_default_constructor/models/empty.cpp new file mode 100644 index 00000000..6d9fb2d3 --- /dev/null +++ b/test/SIM_delete_default_constructor/models/empty.cpp @@ -0,0 +1 @@ +#include "empty.h" diff --git a/test/SIM_delete_default_constructor/models/empty.h b/test/SIM_delete_default_constructor/models/empty.h new file mode 100644 index 00000000..06ed4a68 --- /dev/null +++ b/test/SIM_delete_default_constructor/models/empty.h @@ -0,0 +1,12 @@ +/************************************************************************* +PURPOSE: (Empty class) +LIBRARY DEPENDENCY: + ( + (empty.cpp) + ) +**************************************************************************/ + +class Empty { +public: + Empty() = delete; +}; diff --git a/test/SIM_delete_default_constructor/models/starter.cpp b/test/SIM_delete_default_constructor/models/starter.cpp new file mode 100644 index 00000000..b8761d13 --- /dev/null +++ b/test/SIM_delete_default_constructor/models/starter.cpp @@ -0,0 +1,6 @@ +#include "starter.h" + +Starter::Starter(int foo) { + +} + diff --git a/test/SIM_delete_default_constructor/models/starter.h b/test/SIM_delete_default_constructor/models/starter.h new file mode 100644 index 00000000..4f11337a --- /dev/null +++ b/test/SIM_delete_default_constructor/models/starter.h @@ -0,0 +1,14 @@ +/************************************************************************* +PURPOSE: (Starter class) +LIBRARY DEPENDENCY: + ( + (starter.cpp) + ) +**************************************************************************/ + +class Starter { +public: + Starter() = delete; + Starter(int foo); + +}; diff --git a/test/makefile b/test/makefile index 510faabe..36fb2b0c 100644 --- a/test/makefile +++ b/test/makefile @@ -5,6 +5,7 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common SIMS_TO_COMPILE_ONLY = \ SIM_alloc_test \ SIM_default_member_initializer \ + SIM_delete_default_constructor \ SIM_demo_inputfile \ SIM_exclusion_mechanisms \ SIM_isystem \ diff --git a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp index 84336300..277e736d 100644 --- a/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/ClassVisitor.cpp @@ -172,7 +172,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) { // Test all constructors to see if any of those are the default and public clang::CXXRecordDecl::ctor_iterator cit ; for ( cit = rec->ctor_begin() ; cit != rec->ctor_end() ; cit++ ) { - if ( (*cit)->isDefaultConstructor() and (*cit)->getAccess() == clang::AS_public ) { + if ( ( !(*cit)->isDeleted() ) and (*cit)->isDefaultConstructor() and (*cit)->getAccess() == clang::AS_public ) { cval.setHasDefaultConstructor(true) ; } }