Skip to content
Snippets Groups Projects
Commit 76cf0424 authored by Allan Blanchard's avatar Allan Blanchard
Browse files

Merge branch 'doc/wp/calls' into 'stable/titanium'

Improves WP `@calls` doc

See merge request frama-c/frama-c!2925
parents 1c1b355b d069cd2d
No related branches found
No related tags found
No related merge requests found
...@@ -874,14 +874,37 @@ weakest precondition calculus. ...@@ -874,14 +874,37 @@ weakest precondition calculus.
and it can generates a large number of verifications for structures and it can generates a large number of verifications for structures
with many (nested) fields (defaults to \texttt{no}). with many (nested) fields (defaults to \texttt{no}).
\item[\tt -wp-(no)-dynamic] handles calls \textit{via} function pointers \item[\tt -wp-(no)-dynamic] handles calls \textit{via} function pointers
thanks to the dedicated \verb+@calls f1,...,fn+ code annotation. thanks to the dedicated \verb+@calls f1,...,fn+ code annotation (default is: \texttt{yes}).
For each call to a function pointer \texttt{fp}
in the instruction or block under the annotation,
\texttt{fp} is required to belongs to the set \texttt{f1,\ldots,fn} and
a case analysis is performed with the contract of each provided function
(default is: \texttt{yes}).
\end{description} \end{description}
\subsubsection{ACSL extension \texttt{@calls}}
The handling of functions pointers is done via the ACSL code annotation
extension \verb+@calls+. For each call to a function pointer \verb+fp+
in the instruction or block under the annotation \verb+calls f1,\ldots,fn+,
\verb+fp+ is required to belongs to the set \verb+f1,\ldots,fn+ and
a case analysis is performed with the contract of each provided function.
For example:
\begin{lstlisting}[language=c, alsolanguage=acsl]
/*@ ensures \result == x ; */
int f1(int x);
/*@ ensures \result == x+1 ; */
int f2(int x);
/*@ requires fp == &f1 || fp == &f2 ;
ensures POST: \result == 4 || \result == 5; */
int caller(int (*fp)(int)){
//@ calls f1, f2 ;
return (*fp)(4);
}
\end{lstlisting}
These annotations split post-conditions to the dynamic call into two sub-goals: one for call to \verb+f1+ and
a second for the call to \verb+f2+. A last goal is generated at the call
site: one must prove that \verb+fp+ is either \verb+f1+ or \verb+f2+.
\subsection{Smoke Tests} \subsection{Smoke Tests}
During modular deductive verification, inconsistencies in function requirements During modular deductive verification, inconsistencies in function requirements
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment