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);
On Tuesday, January 18, 2022 at 11:16:57 AM UTC, amado...@gmail.com wrote:
To find the culprit I would:It's not SQL_OK,
Test Pre vs. Post (Pre only vs. Post only).
Unit test function SQL_OK for storage error just in case.
function SQL_OK
(rc : in SQLRETURN)
return Boolean
is
(rc = SQL_SUCCESS or else rc = SQL_SUCCESS_WITH_INFO);
And it fails with either Pre or Post, sadly - the only common factor seems to be the 'if'
On 2022-01-18 12:05, Mark Wilson wrote:
Pre => (if HandleType = SQL_HANDLE_ENV thenWhat happens with
InputHandle = SQL_NULL_HANDLE
else
InputHandle /= SQL_NULL_HANDLE),
Post => (if SQL_OK (Result) then
OutputHandlePtr /= SQL_NULL_HANDLE
else
OutputHandlePtr = SQL_NULL_HANDLE);
Pre => (Handletype = SQL_Handle_Env) = (Inputhandle = SQL_Null_Handle)
and
Post => SQL_OK (Result) = (Outputhandleptr /= SQL_Null_Handle)
which seem to be equivalent?
--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09
then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]'
On 2022-01-18 12:05, Mark Wilson wrote:
then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]'The GNAT RM says of pragma Import_Valued_Procedure
"Note that it is important to use this pragma in conjunction with a separate pragma Import that specifies the desired convention, since otherwise the default
convention is Ada, which is almost certainly not what is required."
What happens if you replace the import aspects with pragma Import?
--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09
On Tuesday, January 18, 2022 at 11:48:23 AM UTC, Jeffrey R.Carter wrote:
On 2022-01-18 12:05, Mark Wilson wrote:
then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]'The GNAT RM says of pragma Import_Valued_Procedure
"Note that it is important to use this pragma in conjunction with a separate
pragma Import that specifies the desired convention, since otherwise the default
convention is Ada, which is almost certainly not what is required."
What happens if you replace the import aspects with pragma Import?Tried pragma Import, and even pragma Convention, so, for instance,
--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09
procedure SQLAllocHandle
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE)
with
Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle, "SQLAllocHandle");
pragma Import_Valued_Procedure (SQLAllocHandle);
Fails with the same warning. Take the 'pre' out and it works fine.
To find the culprit I would:
Test Pre vs. Post (Pre only vs. Post only).
Unit test function SQL_OK for storage error just in case.
On Tuesday, January 18, 2022 at 11:51:36 AM UTC, Mark Wilson wrote:
On Tuesday, January 18, 2022 at 11:48:23 AM UTC, Jeffrey R.Carter wrote:
On 2022-01-18 12:05, Mark Wilson wrote:
then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]'The GNAT RM says of pragma Import_Valued_Procedure
"Note that it is important to use this pragma in conjunction with a separate
pragma Import that specifies the desired convention, since otherwise the default
convention is Ada, which is almost certainly not what is required."
What happens if you replace the import aspects with pragma Import?Tried pragma Import, and even pragma Convention, so, for instance, procedure SQLAllocHandle
--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE)
with
Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle, "SQLAllocHandle");
pragma Import_Valued_Procedure (SQLAllocHandle);
Fails with the same warning. Take the 'pre' out and it works fine.Even tried (which to be fair is a bit of a long shot),
procedure SQLAllocHandle
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE);
-- with
-- Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle);
pragma Import_Valued_Procedure
(SQLAllocHandle, "SQLAllocHandle",
(SQLRETURN, SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE),
(Reference, Value, Value, Reference));
Do you think I should file a bug report?
You should be able to work around this by making your procedure a wrapper around
an imported function with an in out parameter, with SPARK checking turned off in
the procedure body.
--
Even tried (which to be fair is a bit of a long shot),
procedure SQLAllocHandle
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE);
-- with
-- Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle);
pragma Import_Valued_Procedure
(SQLAllocHandle, "SQLAllocHandle",
(SQLRETURN, SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE),
(Reference, Value, Value, Reference));
Do you think I should file a bug report?
On Tuesday, January 18, 2022 at 12:08:16 PM UTC, Mark Wilson wrote:
On Tuesday, January 18, 2022 at 11:51:36 AM UTC, Mark Wilson wrote:
On Tuesday, January 18, 2022 at 11:48:23 AM UTC, Jeffrey R.Carter wrote:
On 2022-01-18 12:05, Mark Wilson wrote:
then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]'The GNAT RM says of pragma Import_Valued_Procedure
"Note that it is important to use this pragma in conjunction with a separate
pragma Import that specifies the desired convention, since otherwise the default
convention is Ada, which is almost certainly not what is required."
What happens if you replace the import aspects with pragma Import?Tried pragma Import, and even pragma Convention, so, for instance, procedure SQLAllocHandle
--
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE)
with
Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle, "SQLAllocHandle");
pragma Import_Valued_Procedure (SQLAllocHandle);
Fails with the same warning. Take the 'pre' out and it works fine.Even tried (which to be fair is a bit of a long shot),
procedure SQLAllocHandle
(Result : out SQLRETURN;
HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in out SQLHANDLE);
-- with
-- Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle);
pragma Import_Valued_Procedure
(SQLAllocHandle, "SQLAllocHandle",
(SQLRETURN, SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE),
(Reference, Value, Value, Reference));
Do you think I should file a bug report?Well, this works - but feels very naughty,
function SQLAllocHandle
(HandleType : in SQL_HANDLE_TYPE;
InputHandle : in SQLHANDLE;
OutputHandlePtr : in SQLHANDLE)
return SQLRETURN;
-- with
-- Pre => (Handletype = SQL_Handle_Env);
pragma Import (C, SQLAllocHandle);
pragma Import_Function
(SQLAllocHandle, "SQLAllocHandle",
(SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE), SQLRETURN,
(Value, Value, Reference));
However, adding the precondition in results in '<artificial>:(.text+0xb7): undefined reference to `sqlallochandle'''
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 355 |
Nodes: | 16 (2 / 14) |
Uptime: | 47:45:15 |
Calls: | 7,658 |
Files: | 12,819 |
Messages: | 5,702,666 |