aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-12-26 14:26:59 +0100
committerTristan Gingold <tgingold@free.fr>2020-12-26 17:35:10 +0100
commitb9788c0bb2fabdcdd70029cd2ffbdd12706aea1d (patch)
treeeb903a286fca01f9c039f6c69a92e1399a90c84e /src/vhdl
parentf60887e70ac8f2b24637b4710f5cb9a18acef6aa (diff)
downloadghdl-b9788c0bb2fabdcdd70029cd2ffbdd12706aea1d.tar.gz
ghdl-b9788c0bb2fabdcdd70029cd2ffbdd12706aea1d.tar.bz2
ghdl-b9788c0bb2fabdcdd70029cd2ffbdd12706aea1d.zip
libraries: Load_Std_Library: now return a status.
Propagate this change to libghdl and python binding to avoid abort. For #1551
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/libghdl/libghdl.adb33
-rw-r--r--src/vhdl/libghdl/libghdl.ads3
-rw-r--r--src/vhdl/translate/ortho_front.adb4
3 files changed, 34 insertions, 6 deletions
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;