From ead16adfc8dc387a59057717521976cbe7ae9067 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Tue, 20 Nov 2018 14:07:03 -0500
Subject: Fortran: Fix module dependency scanning with upper-case SUBMODULE

The lexical token expression added by commit v3.7.0-rc1~73^2~1 (Fortran:
Add support for submodule syntax in dependency scanning, 2016-09-05)
has a typo and does not match upper-case `B` in `SUBMODULE`.  Fix it.

Fixes: #18595
---
 Source/LexerParser/cmFortranLexer.cxx     | 226 +++++++++++++++---------------
 Source/LexerParser/cmFortranLexer.in.l    |   2 +-
 Tests/FortranModules/Submodules/child.f90 |   6 +-
 3 files changed, 117 insertions(+), 117 deletions(-)

diff --git a/Source/LexerParser/cmFortranLexer.cxx b/Source/LexerParser/cmFortranLexer.cxx
index dec0f5e..82048df 100644
--- a/Source/LexerParser/cmFortranLexer.cxx
+++ b/Source/LexerParser/cmFortranLexer.cxx
@@ -593,13 +593,13 @@ static const YY_CHAR yy_ec[256] =
        13,   14,    1,   15,    1,    1,    1,   16,   16,   16,
        16,   16,   16,   16,   16,   16,   16,   17,   18,   19,
        20,   21,   22,    1,   23,   24,   25,   26,   27,   28,
-       24,   24,   29,   24,   24,   30,   31,   32,   33,   24,
-       24,   34,   35,   36,   37,   24,   24,   24,   24,   24,
-        1,   38,    1,    1,   39,    1,   23,   40,   41,   42,
+       29,   29,   30,   29,   29,   31,   32,   33,   34,   29,
+       29,   35,   36,   37,   38,   29,   29,   29,   29,   29,
+        1,   39,    1,    1,   40,    1,   23,   24,   41,   42,
 
-       43,   44,   24,   24,   45,   24,   24,   46,   31,   47,
-       33,   24,   24,   34,   48,   36,   49,   24,   24,   24,
-       24,   24,    1,    1,    1,    1,    1,    1,    1,    1,
+       43,   44,   29,   29,   45,   29,   29,   46,   32,   47,
+       34,   29,   29,   35,   48,   37,   49,   29,   29,   29,
+       29,   29,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -621,7 +621,7 @@ static const YY_CHAR yy_meta[50] =
         1,    2,    2,    3,    4,    3,    3,    1,    1,    3,
         3,    3,    3,    1,    3,    5,    3,    3,    1,    3,
         6,    1,    7,    7,    7,    7,    7,    7,    7,    7,
-        7,    7,    7,    7,    7,    7,    7,    1,    5,    7,
+        7,    7,    7,    7,    7,    7,    7,    7,    1,    5,
         7,    7,    7,    7,    7,    7,    7,    7,    7
     } ;
 
@@ -629,28 +629,28 @@ static const flex_int16_t yy_base[219] =
     {   0,
         0,   48,    0,   49,  464,   56,   52,   57,   62,   68,
       466,    0,  468,  468,  462,  468,   74,   81,  468,  468,
-      468,  468,  447,  468,  442,  440,    0,   41,   42,  428,
-       43,   42,   91,  119,   97,  157,  455,  206,  245,  468,
-      454,  101,  468,  468,    0,  455,  468,  105,  430,  424,
-       62,   68,  119,  141,  468,  468,  468,  111,    0,   59,
-       98,   88,  415,  109,  158,  468,    0,  162,  293,    0,
-      163,  411,  107,  122,  408,  405,  446,  342,  447,  468,
-        0,  444,  169,  173,  420,  421,  132,  404,   90,  404,
-      179,  185,  191,  227,  295,  397,    0,  146,  178,  149,
-
-      412,    0,  208,  206,  398,  171,  399,  170,  399,  391,
-      387,  422,  417,  221,  468,  374,  365,  347,  347,  334,
-      335,  335,  330,  334,  259,  340,  188,  340,  327,  327,
-      327,  324,  325,  325,  320,  322,  319,  355,  354,  325,
-      327,  468,  468,  310,  309,  309,  300,  301,  273,  273,
-      275,  277,  297,  468,  468,  293,  289,  283,  275,  305,
-      261,  238,  237,  214,  468,  468,  468,  196,  197,  189,
-      277,  181,    0,  274,  112,  468,  468,  105,  103,  311,
-      468,  233,    0,  468,  468,   83,   76,    0,  281,  282,
-      468,  468,   52,  468,  468,  468,  468,   23,  287,  298,
-
-      327,  468,    0,    0,  329,    0,   31,  468,  468,  381,
-      388,  394,  397,  404,  411,  418,  425,  432
+      468,  468,  447,  468,  442,  440,    0,   19,   41,  427,
+       47,   41,   90,  119,   97,  158,  455,  207,  247,  468,
+      454,  101,  468,  468,    0,  455,  468,  105,  430,  423,
+       62,   67,  119,  151,  468,  468,  468,  121,    0,   90,
+       93,  110,  431,  112,  142,  468,    0,  160,  295,    0,
+      162,  411,  123,  102,  408,  405,  446,  344,  447,  468,
+        0,  444,  170,  174,  420,  421,  132,  404,   95,  404,
+      180,  186,  192,  228,  297,  397,    0,  168,  144,   52,
+
+      411,    0,  204,  217,  397,  179,  390,  170,  389,  378,
+      364,  390,  389,  230,  468,  363,  355,  337,  337,  334,
+      335,  335,  330,  334,  187,  339,  267,  339,  327,  327,
+      327,  324,  325,  325,  318,  319,  318,  354,  352,  323,
+      327,  468,  468,  310,  307,  305,  297,  297,  275,  275,
+      277,  279,  287,  468,  468,  286,  283,  273,  196,  307,
+      200,  238,  234,  210,  468,  468,  468,  174,  171,  162,
+      279,  182,    0,  269,  150,  468,  468,  137,  109,  323,
+      468,  239,    0,  468,  468,   72,   71,    0,  283,  283,
+      468,  468,   51,  468,  468,  468,  468,   37,  283,  288,
+
+      330,  468,    0,    0,  331,    0,   52,  468,  468,  384,
+      391,  397,  400,  407,  414,  421,  428,  435
     } ;
 
 static const flex_int16_t yy_def[219] =
@@ -685,53 +685,53 @@ static const flex_int16_t yy_nxt[518] =
     {   0,
        12,   13,   14,   13,   13,   15,   16,   12,   17,   18,
        19,   20,   21,   12,   22,   12,   23,   24,   12,   25,
-       12,   26,   27,   27,   27,   27,   28,   27,   29,   27,
-       30,   27,   27,   27,   31,   27,   32,   33,   34,   27,
+       12,   26,   27,   27,   27,   27,   28,   27,   27,   29,
+       27,   30,   27,   27,   27,   31,   27,   32,   33,   34,
        27,   27,   28,   27,   29,   27,   27,   31,   32,   35,
-       35,  208,   35,   35,   41,   36,   36,   35,   37,   41,
-       35,   42,   43,   36,   41,  202,   42,   43,   44,   38,
-       41,   42,   60,   61,   44,   48,   64,   42,   48,   63,
-       39,   39,   53,   53,   97,   53,   54,   60,   61,   64,
-       55,   63,   65,   66,  201,   65,   39,   39,   68,   49,
-
-       97,   68,   83,   84,   69,   83,   48,   87,   88,   48,
-       50,   89,   95,  100,   90,   95,   51,  198,   52,   45,
-       53,   53,   98,   53,   54,  197,   45,   45,   55,  100,
-       49,  121,   45,   99,   67,  102,  122,   45,   98,   45,
-       45,   50,   92,   53,  193,   92,   93,   51,  192,   52,
-       94,  102,  106,  107,  191,   96,   45,   67,   70,   65,
-       66,   70,   65,   68,  104,  108,   68,  104,  109,   69,
-       83,   84,   71,   83,  114,  125,  118,  114,   71,  119,
-       92,   53,  115,   92,   93,  127,   92,   53,   94,   92,
-       93,  125,   92,   53,   94,   92,   93,  127,   72,   73,
-
-       94,   74,   75,  189,  126,   76,   78,  104,   80,  104,
-      104,  133,  104,   78,   78,  130,  134,  151,  131,   78,
-      126,   78,  114,  103,   78,  114,   78,   78,   92,   53,
-      115,   92,   93,  151,  195,  195,   94,  187,  186,  185,
-      184,  183,  182,   78,   78,   79,   79,   80,   79,   79,
+       35,   60,   35,   35,   41,   36,   36,   35,   37,   41,
+       35,   42,   43,   36,   41,   60,   42,   43,   44,   38,
+       41,   42,  208,   61,   44,   48,   64,   42,   48,  202,
+       39,   39,   53,   53,   63,   53,   54,   61,   64,  127,
+       55,   65,   66,  201,   65,   63,   39,   39,   68,   49,
+
+      127,   68,   83,   84,   69,   83,   48,   87,   88,   48,
+       89,   50,  198,   90,  197,   97,   51,   98,   52,   45,
+       53,   53,   95,   53,   54,   95,   45,   45,   55,   99,
+       49,   97,   45,   98,   67,  100,  121,   45,  102,   45,
+       45,  122,   50,   65,   66,  108,   65,   51,  109,   52,
+      193,  100,   92,   53,  102,   92,   93,   45,   67,   70,
+       94,   68,   70,  104,   68,   96,  104,   69,  106,  107,
+      126,   83,   84,   71,   83,  114,  118,   71,  114,  119,
+      192,   92,   53,  115,   92,   93,  126,   92,   53,   94,
+       92,   93,  191,   92,   53,   94,   92,   93,  125,   72,
+
+       73,   94,   74,   75,  189,  104,   76,   78,  104,   80,
+      187,  133,  186,  125,   78,   78,  134,  185,  104,  103,
+       78,  104,   78,  130,  149,   78,  131,   78,   78,   92,
+       53,  114,   92,   93,  114,  149,  184,   94,  183,  115,
+      195,  195,  182,  181,  179,   78,   78,   79,   79,   80,
        79,   79,   79,   79,   79,   79,   79,   79,   79,   79,
-       81,   79,   79,   79,   79,   79,   79,   81,   81,   81,
+       79,   79,   81,   79,   79,   79,   79,   79,   79,   81,
        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
-       81,   81,   79,   81,   81,   81,   81,   81,   81,   81,
-       81,   81,   81,   81,   70,  149,   95,   70,  171,   95,
-
-      172,  173,  174,  188,  181,  199,  180,  149,  103,  180,
-      190,  200,  180,  203,  171,  180,  172,  173,  174,  188,
-      103,  199,  190,  179,  204,  178,  103,  200,  205,  203,
-      205,  205,  177,  205,   72,   73,  176,   74,   75,   96,
-      204,   76,   78,  175,   80,  206,  170,  206,  169,   78,
-       78,  168,  167,  166,  165,   78,  164,   78,  163,  162,
-       78,  161,   78,   78,  160,  159,  158,  157,  156,  155,
-      154,  153,  152,  150,  148,  147,  146,  145,  144,   78,
-       78,   40,   40,   40,   40,   40,   40,   40,   45,  143,
-      142,  141,   45,   45,   46,   46,   46,   46,   46,   46,
-
-       46,   59,  140,   59,   79,   79,   79,   79,   79,   79,
-       79,   91,   91,   91,   91,   91,   91,   91,  194,  194,
-      194,  139,  194,  194,  194,  196,  138,  196,  137,  196,
-      196,  196,  207,  207,  207,  207,  207,  136,  207,  135,
-      132,  129,  128,  124,  123,  120,  117,  116,  113,   80,
+       81,   81,   81,   81,   81,   79,   81,   81,   81,   81,
+       81,   81,   81,   81,   81,   81,   70,  151,   95,   70,
+
+      171,   95,  172,  173,  174,  188,  190,  199,  180,  203,
+      103,  180,  151,  200,  204,  178,  171,  190,  172,  173,
+      174,  188,  103,  199,  180,  203,  177,  180,  200,  176,
+      204,  205,  205,  175,  205,  205,   72,   73,  103,   74,
+       75,   96,  170,   76,   78,  169,   80,  168,  206,  206,
+      167,   78,   78,  166,  165,  164,  163,   78,  162,   78,
+      161,  160,   78,  159,   78,   78,  158,  157,  156,  155,
+      154,  153,  152,  150,  148,  147,  146,  145,  144,  143,
+      142,  141,   78,   78,   40,   40,   40,   40,   40,   40,
+       40,   45,  140,  139,  138,   45,   45,   46,   46,   46,
+
+       46,   46,   46,   46,   59,  137,   59,   79,   79,   79,
+       79,   79,   79,   79,   91,   91,   91,   91,   91,   91,
+       91,  194,  194,  194,  136,  194,  194,  194,  196,  135,
+      196,  132,  196,  196,  196,  207,  207,  207,  207,  207,
+      129,  207,  128,  124,  123,  120,  117,  116,  113,   80,
       112,  111,  110,  105,  101,   86,   85,   47,   82,   77,
        62,   58,   57,   56,   47,  209,   37,   11,  209,  209,
       209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
@@ -749,50 +749,50 @@ static const flex_int16_t yy_chk[518] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
-        4,  207,    2,    4,    7,    2,    4,    6,    6,    8,
-        6,    7,    7,    6,    9,  198,    8,    8,    9,    6,
-       10,    9,   28,   29,   10,   17,   32,   10,   17,   31,
-        6,    6,   18,   18,   60,   18,   18,   28,   29,   32,
-       18,   31,   33,   33,  193,   33,    6,    6,   35,   17,
-
-       60,   35,   42,   42,   35,   42,   48,   51,   51,   48,
-       17,   52,   58,   62,   52,   58,   17,  187,   17,   34,
-       53,   53,   61,   53,   53,  186,   34,   34,   53,   62,
-       48,   89,   34,   61,   34,   64,   89,   34,   61,   34,
-       34,   48,   54,   54,  179,   54,   54,   48,  178,   48,
-       54,   64,   73,   73,  175,   58,   34,   34,   36,   65,
-       65,   36,   65,   68,   71,   74,   68,   71,   74,   68,
-       83,   83,   36,   83,   84,   98,   87,   84,   71,   87,
-       91,   91,   84,   91,   91,  100,   92,   92,   91,   92,
-       92,   98,   93,   93,   92,   93,   93,  100,   36,   36,
-
-       93,   36,   36,  172,   99,   36,   38,  104,   38,  103,
-      104,  108,  103,   38,   38,  106,  108,  127,  106,   38,
-       99,   38,  114,  103,   38,  114,   38,   38,   94,   94,
-      114,   94,   94,  127,  182,  182,   94,  170,  169,  168,
-      164,  163,  162,   38,   38,   39,   39,   39,   39,   39,
+        4,   28,    2,    4,    7,    2,    4,    6,    6,    8,
+        6,    7,    7,    6,    9,   28,    8,    8,    9,    6,
+       10,    9,  207,   29,   10,   17,   32,   10,   17,  198,
+        6,    6,   18,   18,   31,   18,   18,   29,   32,  100,
+       18,   33,   33,  193,   33,   31,    6,    6,   35,   17,
+
+      100,   35,   42,   42,   35,   42,   48,   51,   51,   48,
+       52,   17,  187,   52,  186,   60,   17,   61,   17,   34,
+       53,   53,   58,   53,   53,   58,   34,   34,   53,   61,
+       48,   60,   34,   61,   34,   62,   89,   34,   64,   34,
+       34,   89,   48,   65,   65,   74,   65,   48,   74,   48,
+      179,   62,   54,   54,   64,   54,   54,   34,   34,   36,
+       54,   68,   36,   71,   68,   58,   71,   68,   73,   73,
+       99,   83,   83,   36,   83,   84,   87,   71,   84,   87,
+      178,   91,   91,   84,   91,   91,   99,   92,   92,   91,
+       92,   92,  175,   93,   93,   92,   93,   93,   98,   36,
+
+       36,   93,   36,   36,  172,  103,   36,   38,  103,   38,
+      170,  108,  169,   98,   38,   38,  108,  168,  104,  103,
+       38,  104,   38,  106,  125,   38,  106,   38,   38,   94,
+       94,  114,   94,   94,  114,  125,  164,   94,  163,  114,
+      182,  182,  162,  161,  159,   38,   38,   39,   39,   39,
        39,   39,   39,   39,   39,   39,   39,   39,   39,   39,
        39,   39,   39,   39,   39,   39,   39,   39,   39,   39,
        39,   39,   39,   39,   39,   39,   39,   39,   39,   39,
        39,   39,   39,   39,   39,   39,   39,   39,   39,   39,
-       39,   39,   39,   39,   69,  125,   95,   69,  149,   95,
-
-      150,  151,  152,  171,  161,  189,  160,  125,   69,  160,
-      174,  190,  180,  199,  149,  180,  150,  151,  152,  171,
-      160,  189,  174,  159,  200,  158,  180,  190,  201,  199,
-      205,  201,  157,  205,   69,   69,  156,   69,   69,   95,
-      200,   69,   78,  153,   78,  201,  148,  205,  147,   78,
-       78,  146,  145,  144,  141,   78,  140,   78,  139,  138,
-       78,  137,   78,   78,  136,  135,  134,  133,  132,  131,
-      130,  129,  128,  126,  124,  123,  122,  121,  120,   78,
-       78,  210,  210,  210,  210,  210,  210,  210,  211,  119,
-      118,  117,  211,  211,  212,  212,  212,  212,  212,  212,
-
-      212,  213,  116,  213,  214,  214,  214,  214,  214,  214,
-      214,  215,  215,  215,  215,  215,  215,  215,  216,  216,
-      216,  113,  216,  216,  216,  217,  112,  217,  111,  217,
-      217,  217,  218,  218,  218,  218,  218,  110,  218,  109,
-      107,  105,  101,   96,   90,   88,   86,   85,   82,   79,
+       39,   39,   39,   39,   39,   39,   69,  127,   95,   69,
+
+      149,   95,  150,  151,  152,  171,  174,  189,  160,  199,
+       69,  160,  127,  190,  200,  158,  149,  174,  150,  151,
+      152,  171,  160,  189,  180,  199,  157,  180,  190,  156,
+      200,  201,  205,  153,  201,  205,   69,   69,  180,   69,
+       69,   95,  148,   69,   78,  147,   78,  146,  201,  205,
+      145,   78,   78,  144,  141,  140,  139,   78,  138,   78,
+      137,  136,   78,  135,   78,   78,  134,  133,  132,  131,
+      130,  129,  128,  126,  124,  123,  122,  121,  120,  119,
+      118,  117,   78,   78,  210,  210,  210,  210,  210,  210,
+      210,  211,  116,  113,  112,  211,  211,  212,  212,  212,
+
+      212,  212,  212,  212,  213,  111,  213,  214,  214,  214,
+      214,  214,  214,  214,  215,  215,  215,  215,  215,  215,
+      215,  216,  216,  216,  110,  216,  216,  216,  217,  109,
+      217,  107,  217,  217,  217,  218,  218,  218,  218,  218,
+      105,  218,  101,   96,   90,   88,   86,   85,   82,   79,
        77,   76,   75,   72,   63,   50,   49,   46,   41,   37,
        30,   26,   25,   23,   15,   11,    5,  209,  209,  209,
       209,  209,  209,  209,  209,  209,  209,  209,  209,  209,
diff --git a/Source/LexerParser/cmFortranLexer.in.l b/Source/LexerParser/cmFortranLexer.in.l
index 9acba4c..b7e837b 100644
--- a/Source/LexerParser/cmFortranLexer.in.l
+++ b/Source/LexerParser/cmFortranLexer.in.l
@@ -146,7 +146,7 @@ $[ \t]*endif    { return F90PPR_ENDIF; }
 [Ii][Nn][Cc][Ll][Uu][Dd][Ee] { return INCLUDE; }
 [Ii][Nn][Tt][Ee][Rr][Ff][Aa][Cc][Ee] { return INTERFACE; }
 [Mm][Oo][Dd][Uu][Ll][Ee] { return MODULE; }
-[Ss][Uu][bb][Mm][Oo][Dd][Uu][Ll][Ee] { return SUBMODULE; }
+[Ss][Uu][Bb][Mm][Oo][Dd][Uu][Ll][Ee] { return SUBMODULE; }
 [Uu][Ss][Ee] { return USE; }
 
 [a-zA-Z_][a-zA-Z_0-9]* {
diff --git a/Tests/FortranModules/Submodules/child.f90 b/Tests/FortranModules/Submodules/child.f90
index 838ab61..c314835 100644
--- a/Tests/FortranModules/Submodules/child.f90
+++ b/Tests/FortranModules/Submodules/child.f90
@@ -1,10 +1,10 @@
 ! Test the notation for a 1st-generation direct
 ! descendant of a parent module
-submodule ( parent ) child
+SUBMODULE ( parent ) child
   implicit none
-contains
+CONTAINS
   module function child_function() result(child_stuff)
     logical :: child_stuff
     child_stuff=.true.
   end function
-end submodule child
+END SUBMODULE child
-- 
cgit v0.12