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.)

drh 2018-11-02 15:21 trunk
Commit 8cecc544ce1dd191e1dc43efe04ba19c0402aba872ec8aff94061cc3ea332c4e
1 file changed +14
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1903,10 +1903,22 @@
19031903
pFirst = pFirst->pNext;
19041904
}
19051905
return 1;
19061906
}
19071907
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
+}
19081920
19091921
/*
19101922
** This routine is called whenever we encounter a ";" or "=". The stuff
19111923
** between pFirst and pLast constitutes either a typedef or a global
19121924
** variable definition. Do the right thing.
@@ -1961,10 +1973,12 @@
19611973
return nErr;
19621974
}
19631975
}else if( flags & PS_Method ){
19641976
/* Methods are declared by their class. Don't declare separately. */
19651977
return nErr;
1978
+ }else if( isStaticAssert(pFirst) ){
1979
+ return 0;
19661980
}
19671981
isVar = (flags & (PS_Typedef|PS_Method))==0 && isVariableDef(pFirst,pEnd);
19681982
if( isVar && (flags & (PS_Interface|PS_Export|PS_Local))!=0
19691983
&& (flags & PS_Extern)==0 ){
19701984
fprintf(stderr,"%s:%d: Can't define a variable in this context\n",
19711985
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button