]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix source reference of switch sections
authorJürg Billeter <j@bitron.ch>
Tue, 13 Nov 2012 20:10:07 +0000 (21:10 +0100)
committerJürg Billeter <j@bitron.ch>
Tue, 13 Nov 2012 20:10:07 +0000 (21:10 +0100)
vala/valaparser.vala
vala/valaswitchsection.vala

index c2e62807c8987b30c481dfe855108c77b3fc1036..9f090f3ed92b187263e92a6c43044a6f30016e05 100644 (file)
@@ -1811,6 +1811,7 @@ public class Vala.Parser : CodeVisitor {
                var stmt = new SwitchStatement (condition, get_src (begin));
                expect (TokenType.OPEN_BRACE);
                while (current () != TokenType.CLOSE_BRACE) {
+                       begin = get_location ();
                        var section = new SwitchSection (get_src (begin));
                        do {
                                if (accept (TokenType.CASE)) {
index ce8180507d887eeff61523249f8140f2603c5918..bf9932f04a1a3f78400d09f282e37b76ac259893 100644 (file)
@@ -44,6 +44,10 @@ public class Vala.SwitchSection : Block {
         * @param label a switch label
         */
        public void add_label (SwitchLabel label) {
+               if (labels.size == 0) {
+                       this.source_reference = label.source_reference;
+               }
+
                labels.add (label);
                label.section = this;
        }