]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Report error on missing or duplicate entry point
authorJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 14:11:11 +0000 (16:11 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 14:11:11 +0000 (16:11 +0200)
Fixes bug 591819.

compiler/valacompiler.vala
vala/valacodecontext.vala
vala/valamethod.vala

index 06c8bf6d38b36329740d10e4a122947b5eebac33..cc74b5cc03233db7b48d96c0ec888c093b7d1e41 100644 (file)
@@ -313,6 +313,13 @@ class Vala.Compiler {
                var analyzer = new SemanticAnalyzer ();
                analyzer.analyze (context);
 
+               if (!ccode_only && !compile_only) {
+                       // building program, require entry point
+                       if (context.entry_point == null) {
+                               Report.error (null, "program does not contain a static `main' method");
+                       }
+               }
+
                if (dump_tree != null) {
                        var code_writer = new CodeWriter (true);
                        code_writer.write_file (context, dump_tree);
index 62a6ac670dbab377aa4a9d9fc2393b697628d2e6..a6d783c485eb6aeb2ede64bc8a432d19a3232283 100644 (file)
@@ -145,6 +145,8 @@ public class Vala.CodeContext {
 
        public Report report { get; set; default = new Report ();}
 
+       public Method? entry_point { get; set; }
+
        private Gee.List<SourceFile> source_files = new ArrayList<SourceFile> ();
        private Gee.List<string> c_source_files = new ArrayList<string> ();
        private Namespace _root = new Namespace (null);
index b575c8fcbe7f24f56e8ece6c84e3c23bda5b4a47..7b280424241f83d96e00de6b3606b6a5c6d08e59 100644 (file)
@@ -850,7 +850,13 @@ public class Vala.Method : Member {
                }
 
                if (is_possible_entry_point (analyzer)) {
+                       if (analyzer.context.entry_point != null) {
+                               error = true;
+                               Report.error (source_reference, "program already has an entry point `%s'".printf (analyzer.context.entry_point.get_full_name ()));
+                               return false;
+                       }
                        entry_point = true;
+                       analyzer.context.entry_point = this;
                }
 
                return !error;