diff --git a/CHANGES b/CHANGES index 826a6a8b61..ca197661c0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +5.2.0-dev.35 | 2022-09-30 16:40:22 -0700 + + * fixes for compiling "standalone" C++ scripts (Vern Paxson, Corelight) + 5.2.0-dev.33 | 2022-09-30 12:36:34 -0700 * fix for deprecated when's where the inner frame is larger than the outer frame (Vern Paxson, Corelight) diff --git a/VERSION b/VERSION index e20968e6f1..6302466dcd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.2.0-dev.33 +5.2.0-dev.35 diff --git a/src/Type.cc b/src/Type.cc index 60eedfe24f..910453792a 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -278,6 +278,15 @@ detail::TraversalCode Type::Traverse(detail::TraversalCallback* cb) const HANDLE_TC_TYPE_POST(tc); } +void TypeList::CheckPure() + { + if ( pure_type ) + return; + + if ( ! types.empty() && AllMatch(types[0], false) ) + pure_type = types[0]; + } + bool TypeList::AllMatch(const Type* t, bool is_init) const { for ( const auto& type : types ) diff --git a/src/Type.h b/src/Type.h index 2b7f4d3a29..0e34e83c48 100644 --- a/src/Type.h +++ b/src/Type.h @@ -339,6 +339,10 @@ public: // is not pure or is empty. const TypePtr& GetPureType() const { return pure_type; } + // Retrospectively instantiates an underlying pure type, if in + // fact each element has the same type. + void CheckPure(); + // True if all of the types match t, false otherwise. If // is_init is true, then the matching is done in the context // of an initialization. diff --git a/src/script_opt/CPP/RuntimeInits.cc b/src/script_opt/CPP/RuntimeInits.cc index 2aa68670bc..cebfccd373 100644 --- a/src/script_opt/CPP/RuntimeInits.cc +++ b/src/script_opt/CPP/RuntimeInits.cc @@ -377,6 +377,8 @@ TypePtr CPP_TypeInits::BuildTypeList(InitsManager* im, ValElemVec& init_vals, in while ( iv_it != iv_end ) tl->Append(im->Types(*(iv_it++))); + tl->CheckPure(); + return tl; } diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index d020dfa631..966dd13ff8 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -412,7 +412,7 @@ static void use_CPP() } } - if ( num_used == 0 ) + if ( num_used == 0 && standalone_activations.empty() ) reporter->FatalError("no C++ functions found to use"); // Now that we've loaded all of the compiled scripts