diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index a3f1dfe1f62f3c8e963c27bf384e2d7ac38e447c..ac9645efadc2c015eacea70e58165a36155fb2a9 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -4318,14 +4318,13 @@ declaratives:   %empty
                 ;
 
 sentences:      sentence {
-		  static bool first = true;
-		  if( first ) {
-		    parser_first_statement(@1.first_line);
-		    first = false;
-		  }
+		  ast_first_statement(@1.first_line);
 		  symbol_temporaries_free();
 		}
-	|	section_name
+	|	section_name {
+                  location_set(@1);
+		  ast_first_statement(@1.first_line);
+		}
         |       paragraph_name[para] '.'
                 {
                   location_set(@para);
@@ -4333,6 +4332,7 @@ sentences:      sentence {
                   if( !label ) {
                     YYERROR;
                   }
+		  ast_first_statement(@1.first_line);
                   ast_enter_paragraph(label);
                   current.new_paragraph(label);
                   apply_declaratives();
diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h
index 2fa885b4ba7de860fe3cbc2dbf821e312ebd9b7d..351fac44810e1f27655c9a8bda9b304441aab013 100644
--- a/gcc/cobol/parse_ante.h
+++ b/gcc/cobol/parse_ante.h
@@ -3595,3 +3595,11 @@ location_set( const YYLTYPE& loc ) {
 static int prior_statement;
 
 static size_t statement_begin( const YYLTYPE& loc, int token );
+
+static void ast_first_statement( int first_line ) {
+  static bool first = true;
+  if( first ) {
+    parser_first_statement(first_line);
+    first = false;
+  }
+}