Fix error transforming an empty switch (#346)

* Fix error transforming an empty switch

The parser would crash on that line for `switch(1) {}`
because NoneType is not iterable.

Fixes #345

* Add a test of empty switch statements

* Address review comments
diff --git a/pycparser/ast_transforms.py b/pycparser/ast_transforms.py
index ba50966..0aeb88f 100644
--- a/pycparser/ast_transforms.py
+++ b/pycparser/ast_transforms.py
@@ -74,7 +74,8 @@
 
     # Goes over the children of the Compound below the Switch, adding them
     # either directly below new_compound or below the last Case as appropriate
-    for child in switch_node.stmt.block_items:
+    # (for `switch(cond) {}`, block_items would have been None)
+    for child in (switch_node.stmt.block_items or []):
         if isinstance(child, (c_ast.Case, c_ast.Default)):
             # If it's a Case/Default:
             # 1. Add it to the Compound and mark as "last case"
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
index ad9a218..49cada3 100755
--- a/tests/test_c_parser.py
+++ b/tests/test_c_parser.py
@@ -1792,6 +1792,7 @@
         switch = ps1.ext[0].body.block_items[0]
 
         block = switch.stmt.block_items
+        self.assertEqual(len(block), 4)
         assert_case_node(block[0], '10')
         self.assertEqual(len(block[0].stmts), 3)
         assert_case_node(block[1], '20')
@@ -1819,6 +1820,7 @@
         switch = ps2.ext[0].body.block_items[0]
 
         block = switch.stmt.block_items
+        self.assertEqual(len(block), 5)
         assert_default_node(block[0])
         self.assertEqual(len(block[0].stmts), 2)
         assert_case_node(block[1], '10')
@@ -1830,6 +1832,18 @@
         assert_case_node(block[4], '40')
         self.assertEqual(len(block[4].stmts), 1)
 
+        s3 = r'''
+        int foo(void) {
+            switch (myvar) {
+            }
+            return 0;
+        }
+        '''
+        ps3 = self.parse(s3)
+        switch = ps3.ext[0].body.block_items[0]
+
+        self.assertEqual(switch.stmt.block_items, [])
+
     def test_for_statement(self):
         s2 = r'''
         void x(void)