From 6a7a3cbcf61cb5c2882265a21a8c4b130614786e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 24 Apr 2023 19:29:44 +0200 Subject: libraries(Get_Library): add parameter Force. --- src/libraries.adb | 8 ++++++-- src/libraries.ads | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libraries.adb b/src/libraries.adb index 3c10dad97..3a1ba7e1c 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -758,7 +758,9 @@ package body Libraries is end Get_Library_No_Create; -- Get or create a library from an identifier. - function Get_Library (Ident: Name_Id; Loc : Location_Type) + function Get_Library (Ident: Name_Id; + Loc : Location_Type; + Force : Boolean := False) return Iir_Library_Declaration is Library: Iir_Library_Declaration; @@ -777,7 +779,9 @@ package body Libraries is Set_Library_Directory (Library, Null_Identifier); Set_Identifier (Library, Ident); if Load_Library (Library) = False then - Error_Msg_Sem (+Loc, "cannot find resource library %i", +Ident); + if not Force then + Error_Msg_Sem (+Loc, "cannot find resource library %i", +Ident); + end if; end if; Set_Visible_Flag (Library, True); diff --git a/src/libraries.ads b/src/libraries.ads index 1684afaf0..7e6469691 100644 --- a/src/libraries.ads +++ b/src/libraries.ads @@ -114,7 +114,10 @@ package Libraries is -- Get or create a library from an identifier. -- LOC is used only to report errors. - function Get_Library (Ident : Name_Id; Loc : Location_Type) + -- If FORCE is true, then the library is created even if it doesn't exist. + function Get_Library (Ident: Name_Id; + Loc : Location_Type; + Force : Boolean := False) return Iir_Library_Declaration; -- Add or replace an design unit in the work library. -- cgit v1.2.3