From b9788c0bb2fabdcdd70029cd2ffbdd12706aea1d Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 26 Dec 2020 14:26:59 +0100 Subject: libraries: Load_Std_Library: now return a status. Propagate this change to libghdl and python binding to avoid abort. For #1551 --- src/vhdl/libghdl/libghdl.adb | 33 ++++++++++++++++++++++++++++----- src/vhdl/libghdl/libghdl.ads | 3 +++ src/vhdl/translate/ortho_front.adb | 4 +++- 3 files changed, 34 insertions(+), 6 deletions(-) (limited to 'src/vhdl') diff --git a/src/vhdl/libghdl/libghdl.adb b/src/vhdl/libghdl/libghdl.adb index 67de461cf..bd6d83c5a 100644 --- a/src/vhdl/libghdl/libghdl.adb +++ b/src/vhdl/libghdl/libghdl.adb @@ -39,13 +39,24 @@ package body Libghdl is end if; end Set_Option; - procedure Compile_Init (Analyze_Only : Boolean) is + function Compile_Init_Status (Analyze_Only : Boolean) return Integer is begin if Analyze_Only then - return; + return 0; + end if; + + if not Ghdllocal.Setup_Libraries (True) then + return -1; end if; - Ghdllocal.Setup_Libraries (True); + return 0; + end Compile_Init_Status; + + procedure Compile_Init (Analyze_Only : Boolean) is + begin + if Compile_Init_Status (Analyze_Only) /= 0 then + raise Option_Error; + end if; end Compile_Init; procedure Compile_Elab @@ -87,10 +98,22 @@ package body Libghdl is Disp_Long_Help'Access); end Set_Hooks; - procedure Analyze_Init is + function Analyze_Init_Status return Integer is begin -- Load libraries... - Compile_Init (False); + if Compile_Init_Status (False) /= 0 then + return -1; + end if; + + return 0; + end Analyze_Init_Status; + + procedure Analyze_Init is + begin + -- Deprecated + if Analyze_Init_Status /= 0 then + raise Option_Error; + end if; end Analyze_Init; function Analyze_File (File : Thin_String_Ptr; Len : Natural) return Iir is diff --git a/src/vhdl/libghdl/libghdl.ads b/src/vhdl/libghdl/libghdl.ads index 7d69cde23..5326666b8 100644 --- a/src/vhdl/libghdl/libghdl.ads +++ b/src/vhdl/libghdl/libghdl.ads @@ -34,6 +34,9 @@ package Libghdl is procedure Set_Exec_Prefix (Prefix : Thin_String_Ptr; Len : Natural); -- To be called before Analyze_File to initialize analysis. + function Analyze_Init_Status return Integer; + + -- Deprecated. Raise an exception in case of error. procedure Analyze_Init; -- Analyze one file. diff --git a/src/vhdl/translate/ortho_front.adb b/src/vhdl/translate/ortho_front.adb index 6d75e2826..d681157d9 100644 --- a/src/vhdl/translate/ortho_front.adb +++ b/src/vhdl/translate/ortho_front.adb @@ -540,7 +540,9 @@ package body Ortho_Front is begin if Nbr_Parse = 0 then -- Initialize only once... - Libraries.Load_Std_Library; + if not Libraries.Load_Std_Library then + raise Option_Error; + end if; -- Here, time_base can be set. Translation.Initialize; -- cgit v1.2.3