Commit 361aa17c authored by Guido Günther's avatar Guido Günther

maintransformer: Don't warn on (optional) annotations on (inout)

This makes the scanner consistent with the docs.
parent 329b71b7
Pipeline #50993 passed with stages
in 6 minutes and 21 seconds
......@@ -657,11 +657,12 @@ class MainTransformer(object):
if ANN_OPTIONAL in annotations:
if (not isinstance(node, ast.Return) and
node.direction == ast.PARAM_DIRECTION_OUT):
node.direction in [ast.PARAM_DIRECTION_OUT,
ast.PARAM_DIRECTION_INOUT]):
node.optional = True
else:
message.warn('invalid "optional" annotation: '
'only valid for out parameters',
'only valid for out and inout parameters',
annotations.position)
if ANN_ALLOW_NONE in annotations:
......
......@@ -4,13 +4,13 @@
* test_invalid_optional:
* @param: (optional):
* @param2: (optional):
* @param3: (optional) (inout):
* @param3: (optional) (in):
*
* Returns: (optional):
*/
int *test_invalid_optional(int param, GObject *param2, int *param3);
// EXPECT:5: Warning: Test: invalid "optional" annotation: only valid for out parameters
// EXPECT:6: Warning: Test: invalid "optional" annotation: only valid for out parameters
// EXPECT:7: Warning: Test: invalid "optional" annotation: only valid for out parameters
// EXPECT:9: Warning: Test: invalid "optional" annotation: only valid for out parameters
// EXPECT:5: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
// EXPECT:6: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
// EXPECT:7: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
// EXPECT:9: Warning: Test: invalid "optional" annotation: only valid for out and inout parameters
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment