comp.lang.ada
 help / color / mirror / Atom feed
* Odd Behaviour
@ 2022-01-18 11:05 Mark Wilson
  2022-01-18 11:16 ` Marius Amado-Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mark Wilson @ 2022-01-18 11:05 UTC (permalink / raw)


If I use,

   procedure SQLAllocHandle
     (Result          : out    SQLRETURN;
      HandleType      : in     SQL_HANDLE_TYPE;
      InputHandle     : in     SQLHANDLE;
      OutputHandlePtr : in out SQLHANDLE)
     with
       Import        => True,
       Convention    => C,
       External_Name => "SQLAllocHandle";
   pragma Import_Valued_Procedure (SQLAllocHandle);

then everything works as expected. However, if I add the following Pre and Post conditions (it's definitely not the Global or Depends)

   procedure SQLAllocHandle
     (Result          : out    SQLRETURN;
      HandleType      : in     SQL_HANDLE_TYPE;
      InputHandle     : in     SQLHANDLE;
      OutputHandlePtr : in out SQLHANDLE)
     with
       Import        => True,
       Convention    => C,
       External_Name => "SQLAllocHandle",
       Global        => null,
       Depends       => ((Result, OutputHandlePtr) =>
                           (HandleType, InputHandle, OutputHandlePtr)),
       Pre           => (if HandleType = SQL_HANDLE_ENV then
                            InputHandle = SQL_NULL_HANDLE
                         else
                            InputHandle /= SQL_NULL_HANDLE),
       Post          => (if SQL_OK (Result) then
                            OutputHandlePtr /= SQL_NULL_HANDLE
                         else
                            OutputHandlePtr = SQL_NULL_HANDLE);

   pragma Import_Valued_Procedure (SQLAllocHandle);

then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]' If I ignore the error, using

 pragma Warnings (Off, "*convention Ada*");

 then it doesn't work at all, as one would expect, raising storage_error.

So, is it the case that, even if you suppress all checks, using an 'if' in a pre or post condition forces a import function stub to only be convention Ada? 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-01-18 13:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 11:05 Odd Behaviour Mark Wilson
2022-01-18 11:16 ` Marius Amado-Alves
2022-01-18 11:21   ` Mark Wilson
2022-01-18 11:24     ` Mark Wilson
2022-01-18 11:28 ` Jeffrey R.Carter
2022-01-18 11:35   ` Mark Wilson
2022-01-18 11:48 ` Jeffrey R.Carter
2022-01-18 11:51   ` Mark Wilson
2022-01-18 12:08     ` Mark Wilson
2022-01-18 12:18       ` Mark Wilson
2022-01-18 12:27         ` Mark Wilson
2022-01-18 13:50           ` Mark Wilson
2022-01-18 12:25       ` Jeffrey R.Carter
2022-01-18 12:30         ` Mark Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox