Commit 5f971c5d authored by Jürg Billeter's avatar Jürg Billeter

Fix check for missing return statements in non-void methods

parent 676f74cd
/* valaconstructor.vala
*
* Copyright (C) 2006-2009 Jürg Billeter
* Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -35,7 +35,11 @@ public class Vala.Constructor : Subroutine {
* Specifies whether this is an instance or a class constructor.
*/
public MemberBinding binding { get; set; default = MemberBinding.INSTANCE; }
public override bool has_result {
get { return false; }
}
/**
* Creates a new constructor.
*
......
/* valadestructor.vala
*
* Copyright (C) 2006-2008 Jürg Billeter
* Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -36,6 +36,10 @@ public class Vala.Destructor : Subroutine {
*/
public MemberBinding binding { get; set; default = MemberBinding.INSTANCE; }
public override bool has_result {
get { return false; }
}
/**
* Creates a new destructor.
*
......
......@@ -208,7 +208,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
if (current_block != null) {
// end of method body reachable
if (context.profile != Profile.DOVA && m.result_var != null) {
if (context.profile != Profile.DOVA && m.has_result) {
Report.error (m.source_reference, "missing return statement at end of subroutine body");
m.error = true;
}
......
......@@ -43,6 +43,10 @@ public class Vala.Method : Subroutine {
}
}
public override bool has_result {
get { return !(return_type is VoidType); }
}
/**
* Specifies whether this method may only be called with an instance of
* the contained type.
......
......@@ -67,6 +67,10 @@ public class Vala.PropertyAccessor : Subroutine {
*/
public bool automatic_body { get; set; }
public override bool has_result {
get { return readable; }
}
/**
* Represents the generated value parameter in a set accessor.
*/
......
......@@ -34,6 +34,8 @@ public abstract class Vala.Subroutine : Symbol {
*/
public LocalVariable result_var { get; set; }
public abstract bool has_result { get; }
protected Subroutine (string? name, SourceReference? source_reference, Comment? comment = null) {
base (name, source_reference, comment);
}
......
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