Index: src/fortranscanner.l
===================================================================
--- src/fortranscanner.l	(revision 757)
+++ src/fortranscanner.l	(working copy)
@@ -166,6 +166,8 @@
 static int               initializerScope;  // number if nested function calls in initializer
 static QCString          useModuleName;  // name of module in the use statement
 static Protection        defaultProtection;
+static Protection        typeProtection;
+static int               typeMode = false;
 static InterfaceType     ifType = IF_NONE;
 
 static char              stringStartSymbol; // single or double quote
@@ -507,8 +509,12 @@
 
   /*------- access specification --------------------------------------------------------------------------*/
 
-<ModuleBody>private/{BS}(\n|"!")         { defaultProtection = Private; }
-<ModuleBody>public/{BS}(\n|"!")          { defaultProtection = Public; }
+<ModuleBody>private/{BS}(\n|"!")         { defaultProtection = Private;
+                                           current->protection = defaultProtection ;
+                                         }
+<ModuleBody>public/{BS}(\n|"!")          { defaultProtection = Public;
+                                           current->protection = defaultProtection ;
+                                         }
 
  /*------- type definition  -------------------------------------------------------------------------------*/
 
@@ -521,6 +527,8 @@
 
                                           yy_push_state(Typedef);
                                           current->protection = defaultProtection;
+                                          typeProtection = defaultProtection;
+                                          typeMode = true;
                                         }
 <Typedef>{
 {COMMA}                                 {}
@@ -536,9 +544,11 @@
                                         }
 public                                  {
                                           current->protection = Public;
+                                          typeProtection = Public;
                                         }
 private                                 {
                                           current->protection = Private;
+                                          typeProtection = Private;
                                         }
 {LANGUAGE_BIND_SPEC}                    {
                                           /* ignored for now */
@@ -606,6 +616,7 @@
 ^{BS}"end"{BS}"type"({BS_}{ID})?{BS}/(\n|!) { /* end type definition */
                                           if (!endScope(current_root))
                                             yyterminate();
+                                          typeMode = false;
                                           yy_pop_state();
                                         }
 }
@@ -1662,7 +1673,14 @@
 
 static void initEntry()
 {
-  current->protection = defaultProtection ;
+  if (typeMode)
+  {
+    current->protection = typeProtection;
+  }
+  else
+  {
+    current->protection = defaultProtection;
+  }
   current->mtype      = mtype;
   current->virt       = virt;
   current->stat       = gstat;
@@ -1689,7 +1707,7 @@
   //fprintf(stderr, "0=========> got module %s\n", name);
 
   if (isModule)
-    current->section = Entry::NAMESPACE_SEC;
+    current->section = Entry::CLASS_SEC;
   else
     current->section = Entry::FUNCTION_SEC;
 
