C6509
warning C6509: invalid annotation: 'return' cannot be referenced from a precondition
This warning indicates that the return [expression] statement cannot be used in a precondition. The return statement is used to terminate the execution of a function and return control to the calling function. The value of expression, if the expression is present, is returned to the calling function.
Because a function might use the return statement to return values, you are allowed to specify it as a property value for use in a post condition.
Example
The following code generates this warning because 'return' is used in a precondition:
// C
#include <CodeAnalysis\SourceAnnotations.h>
int f([SA_Pre(ValidElements="return")] char *pc);
// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
int f([Pre(ValidElements="return")] char *pc);
To correct this warning, use 'return' in a post condition, as shown in the following sample code:
// C
#include <CodeAnalysis\SourceAnnotations.h>
[returnvalue:SA_Post(MustCheck=SA_Yes)]int f(
[SA_Post(ValidElements="return")] char *pc
);
// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
[returnvalue:Post(MustCheck=Yes)]int f(
[Post(ValidElements="return")] char *pc
);