Fossil SCM
Enhance makeheaders so that it is able to deal with static_assert() statements. (These do not come up in Fossil itself. This check-in is in response to use of Makeheaders by external projects.)
Commit
8cecc544ce1dd191e1dc43efe04ba19c0402aba872ec8aff94061cc3ea332c4e
Parent
cdea59dc5c83283…
1 file changed
+14
+14
| --- src/makeheaders.c | ||
| +++ src/makeheaders.c | ||
| @@ -1903,10 +1903,22 @@ | ||
| 1903 | 1903 | pFirst = pFirst->pNext; |
| 1904 | 1904 | } |
| 1905 | 1905 | return 1; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
| 1908 | +/* | |
| 1909 | +** Return TRUE if pFirst is the first token of a static assert. | |
| 1910 | +*/ | |
| 1911 | +static int isStaticAssert(Token *pFirst){ | |
| 1912 | + if( (pFirst->nText==13 && strncmp(pFirst->zText, "static_assert", 13)==0) | |
| 1913 | + || (pFirst->nText==14 && strncmp(pFirst->zText, "_Static_assert", 14)==0) | |
| 1914 | + ){ | |
| 1915 | + return 1; | |
| 1916 | + }else{ | |
| 1917 | + return 0; | |
| 1918 | + } | |
| 1919 | +} | |
| 1908 | 1920 | |
| 1909 | 1921 | /* |
| 1910 | 1922 | ** This routine is called whenever we encounter a ";" or "=". The stuff |
| 1911 | 1923 | ** between pFirst and pLast constitutes either a typedef or a global |
| 1912 | 1924 | ** variable definition. Do the right thing. |
| @@ -1961,10 +1973,12 @@ | ||
| 1961 | 1973 | return nErr; |
| 1962 | 1974 | } |
| 1963 | 1975 | }else if( flags & PS_Method ){ |
| 1964 | 1976 | /* Methods are declared by their class. Don't declare separately. */ |
| 1965 | 1977 | return nErr; |
| 1978 | + }else if( isStaticAssert(pFirst) ){ | |
| 1979 | + return 0; | |
| 1966 | 1980 | } |
| 1967 | 1981 | isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd); |
| 1968 | 1982 | if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0 |
| 1969 | 1983 | && (flags & PS_Extern)==0 ){ |
| 1970 | 1984 | fprintf(stderr,"%s:%d: Can't define a variable in this context\n", |
| 1971 | 1985 |
| --- src/makeheaders.c | |
| +++ src/makeheaders.c | |
| @@ -1903,10 +1903,22 @@ | |
| 1903 | pFirst = pFirst->pNext; |
| 1904 | } |
| 1905 | return 1; |
| 1906 | } |
| 1907 | |
| 1908 | |
| 1909 | /* |
| 1910 | ** This routine is called whenever we encounter a ";" or "=". The stuff |
| 1911 | ** between pFirst and pLast constitutes either a typedef or a global |
| 1912 | ** variable definition. Do the right thing. |
| @@ -1961,10 +1973,12 @@ | |
| 1961 | return nErr; |
| 1962 | } |
| 1963 | }else if( flags & PS_Method ){ |
| 1964 | /* Methods are declared by their class. Don't declare separately. */ |
| 1965 | return nErr; |
| 1966 | } |
| 1967 | isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd); |
| 1968 | if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0 |
| 1969 | && (flags & PS_Extern)==0 ){ |
| 1970 | fprintf(stderr,"%s:%d: Can't define a variable in this context\n", |
| 1971 |
| --- src/makeheaders.c | |
| +++ src/makeheaders.c | |
| @@ -1903,10 +1903,22 @@ | |
| 1903 | pFirst = pFirst->pNext; |
| 1904 | } |
| 1905 | return 1; |
| 1906 | } |
| 1907 | |
| 1908 | /* |
| 1909 | ** Return TRUE if pFirst is the first token of a static assert. |
| 1910 | */ |
| 1911 | static int isStaticAssert(Token *pFirst){ |
| 1912 | if( (pFirst->nText==13 && strncmp(pFirst->zText, "static_assert", 13)==0) |
| 1913 | || (pFirst->nText==14 && strncmp(pFirst->zText, "_Static_assert", 14)==0) |
| 1914 | ){ |
| 1915 | return 1; |
| 1916 | }else{ |
| 1917 | return 0; |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | /* |
| 1922 | ** This routine is called whenever we encounter a ";" or "=". The stuff |
| 1923 | ** between pFirst and pLast constitutes either a typedef or a global |
| 1924 | ** variable definition. Do the right thing. |
| @@ -1961,10 +1973,12 @@ | |
| 1973 | return nErr; |
| 1974 | } |
| 1975 | }else if( flags & PS_Method ){ |
| 1976 | /* Methods are declared by their class. Don't declare separately. */ |
| 1977 | return nErr; |
| 1978 | }else if( isStaticAssert(pFirst) ){ |
| 1979 | return 0; |
| 1980 | } |
| 1981 | isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd); |
| 1982 | if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0 |
| 1983 | && (flags & PS_Extern)==0 ){ |
| 1984 | fprintf(stderr,"%s:%d: Can't define a variable in this context\n", |
| 1985 |