Index: trunk.switch/test/t-language/inc
===================================================================
--- trunk.switch/test/t-language/inc	(Revision 0)
+++ trunk.switch/test/t-language/inc	(Revision 0)
@@ -0,0 +1 @@
+link ../inc
\ Kein Zeilenvorschub am Ende der Datei

Eigenschaftsänderungen: trunk.switch/test/t-language/inc
___________________________________________________________________
Name: svn:special
   + *

Index: trunk.switch/test/t-language/tf-switch1.c
===================================================================
--- trunk.switch/test/t-language/tf-switch1.c	(Revision 0)
+++ trunk.switch/test/t-language/tf-switch1.c	(Revision 0)
@@ -0,0 +1,22 @@
+/* Switch test1 (Bug #584)
+ *
+ * The declaration of a variable within a switch block
+ * should not span over multiple case/default statements.
+ * (As it is in C++.)
+ */
+ 
+int fun()
+{
+    switch(1)
+    {
+	case 0:
+	    int i=1;
+	    return i;
+	
+	case 1:
+	    i=2;
+	    return i;
+    }
+    
+    return -1;
+}
Index: trunk.switch/test/t-language/tf-switch2.c
===================================================================
--- trunk.switch/test/t-language/tf-switch2.c	(Revision 0)
+++ trunk.switch/test/t-language/tf-switch2.c	(Revision 0)
@@ -0,0 +1,25 @@
+/* Switch test2
+ *
+ * Duff's Device should not work.
+ * case/default should appear immediately within
+ * a switch block and not in an inner block.
+ * (As it is in Java.)
+ */
+ 
+void fun()
+{
+    int count = 10;
+    int *src = allocate(10), *dest = allocate(10);
+    int n, pos;
+
+    n = (count + 3) / 4;
+ 
+    switch(count % 4)
+    {
+        case 0:	do { dest[pos] = src[pos]; pos++;
+        case 3:      dest[pos] = src[pos]; pos++;
+        case 2:      dest[pos] = src[pos]; pos++;
+        case 1:      dest[pos] = src[pos]; pos++;
+                   } while(--n > 0);
+    }
+}
Index: trunk.switch/test/t-language/master.c
===================================================================
--- trunk.switch/test/t-language/master.c	(Revision 0)
+++ trunk.switch/test/t-language/master.c	(Revision 0)
@@ -0,0 +1,66 @@
+/* LPC language tests.
+ *
+ * Tests, whether some files are compiled or not.
+ * Has a list tl-*.c of files that should load
+ * and a list tn-*.c of files that should not load.
+ * In the former run_test() is called and should
+ * return a non-zero value for success.
+ */
+
+#include "/inc/base.inc"
+
+void run_test()
+{
+    int errors;
+    
+    msg("\nRunning test for t-language:\n"
+          "----------------------------\n");
+
+    foreach(string file: get_dir("/tl-*.c"))
+    {
+	string err;
+	int res;
+	
+	msg("Running Test %s...", file[0..<3]);
+	
+	if((err = catch(res = load_object(file[0..<3])->run_test();nolog)))
+	{
+	    errors++;
+	    msg(" FAILURE! (%s)\n", err[1..]);
+	}
+        else if(!res)
+	{
+	    errors++;
+	    msg(" FAILURE! (Wrong result)\n");
+	}
+	else
+	{
+	    msg(" Success.\n");
+	}
+    }
+
+    foreach(string file: get_dir("/tf-*.c"))
+    {
+	string err;
+	
+	msg("Running Test %s...\n", file[0..<3]);
+	
+	if((err = catch(load_object(file[0..<3]);nolog)))
+	{
+	    msg("    Success.\n");
+	}
+        else
+	{
+	    errors++;
+	    msg("    FAILURE! (No error occurred.)\n");
+	}
+    }
+
+    shutdown(errors && 1); 
+}
+
+string *epilog(int eflag)
+{
+    run_test();
+    return 0;
+}
Index: trunk.switch/test/t-language/sys
===================================================================
--- trunk.switch/test/t-language/sys	(Revision 0)
+++ trunk.switch/test/t-language/sys	(Revision 0)
@@ -0,0 +1 @@
+link ../sys
\ Kein Zeilenvorschub am Ende der Datei

Eigenschaftsänderungen: trunk.switch/test/t-language/sys
___________________________________________________________________
Name: svn:special
   + *

Index: trunk.switch/src/version.sh
===================================================================
--- trunk.switch/src/version.sh	(Revision 2438)
+++ trunk.switch/src/version.sh	(Arbeitskopie)
@@ -17,7 +17,7 @@
 # A timestamp, to be used by bumpversion and other scripts.
 # It can be used, for example, to 'touch' this file on every build, thus
 # forcing revision control systems to add it on every checkin automatically.
-version_stamp="2008-08-10 19:19:46"
+version_stamp="Sa 6. Dez 18:32:40 CET 2008"
 
 # The version number information
 version_micro=717
Index: trunk.switch/src/prolang.y
===================================================================
--- trunk.switch/src/prolang.y	(Revision 2438)
+++ trunk.switch/src/prolang.y	(Arbeitskopie)
@@ -6910,9 +6910,11 @@
 /* Blocks and simple statements.
  */
 
-block:
-      '{'
+block: '{' statements_block '}'
 
+
+statements_block:
+
       { enter_block_scope(); }
 
       statements
@@ -6933,14 +6935,12 @@
                     = (char)(scope->num_locals - scope->num_cleared);
               }
           }
+     
+          leave_block_scope(MY_FALSE);
       }
+; /* block_statements */
 
-      '}'
 
-      { leave_block_scope(MY_FALSE); }
-; /* block */
-
-
 statements:
       /* empty */
     | statements local_name_list ';'
@@ -7034,7 +7034,7 @@
       }
 
     | error ';' /* Synchronisation point */
-    | cond | while | do | for | foreach | switch | case | default
+    | cond | while | do | for | foreach | switch
     | return ';'
     | block
     | /* empty */ ';'
@@ -8097,8 +8097,12 @@
         if (current_continue_address)
             current_continue_address += SWITCH_DEPTH_UNIT;
       }
+      
+      '{'
 
-      block
+      switch_block
+      
+      '}'
 
       {
 %line
@@ -8141,6 +8145,19 @@
       }
 ; /* switch */
 
+
+switch_block:
+      switch_block switch_statements
+    | switch_statements
+; /* switch_block */
+
+
+switch_statements: switch_label statements_block ;
+
+
+switch_label: case | default ;
+
+
 case: L_CASE case_label ':'
     {
 %line
