@@ -96,6 +96,8 @@ static const simplecpp::TokenString IFNDEF("ifndef");
9696static const simplecpp::TokenString DEFINED (" defined" );
9797static const simplecpp::TokenString ELSE (" else" );
9898static const simplecpp::TokenString ELIF (" elif" );
99+ static const simplecpp::TokenString ELIFDEF (" elifdef" );
100+ static const simplecpp::TokenString ELIFNDEF (" elifndef" );
99101static const simplecpp::TokenString ENDIF (" endif" );
100102
101103static const simplecpp::TokenString PRAGMA (" pragma" );
@@ -3637,7 +3639,9 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36373639 continue ;
36383640 }
36393641
3640- if (ifstates.size () <= 1U && (rawtok->str () == ELIF || rawtok->str () == ELSE || rawtok->str () == ENDIF )) {
3642+ if (ifstates.size () <= 1U && (rawtok->str () == ELIF || rawtok->str () == ELIFDEF ||
3643+ rawtok->str () == ELIFNDEF || rawtok->str () == ELSE ||
3644+ rawtok->str () == ENDIF )) {
36413645 if (outputList) {
36423646 simplecpp::Output err{
36433647 Output::SYNTAX_ERROR ,
@@ -3778,7 +3782,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37783782 rawtok = filedata->tokens .cfront ();
37793783 continue ;
37803784 }
3781- } else if (rawtok->str () == IF || rawtok->str () == IFDEF || rawtok->str () == IFNDEF || rawtok->str () == ELIF ) {
3785+ } else if (rawtok->str () == IF || rawtok->str () == IFDEF || rawtok->str () == IFNDEF || rawtok->str () == ELIF ||
3786+ rawtok->str () == ELIFDEF || rawtok->str () == ELIFNDEF ) {
37823787 if (!sameline (rawtok,rawtok->next )) {
37833788 if (outputList) {
37843789 simplecpp::Output out{
@@ -3793,10 +3798,11 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37933798 }
37943799
37953800 bool conditionIsTrue;
3796- if (ifstates.top () == AlwaysFalse || (ifstates.top () == ElseIsTrue && rawtok->str () != ELIF )) {
3801+ if (ifstates.top () == AlwaysFalse || (ifstates.top () == ElseIsTrue && rawtok->str () != ELIF &&
3802+ rawtok->str () != ELIFDEF && rawtok->str () != ELIFNDEF )) {
37973803 conditionIsTrue = false ;
37983804 }
3799- else if (rawtok->str () == IFDEF ) {
3805+ else if (rawtok->str () == IFDEF || rawtok-> str () == ELIFDEF ) {
38003806 const std::string &name = rawtok->next ->str ();
38013807 conditionIsTrue = (macros.find (name) != macros.end () || (hasInclude && name == HAS_INCLUDE ));
38023808 maybeUsedMacros[name].emplace_back (rawtok->next ->location );
@@ -3805,7 +3811,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38053811 const long long result = conditionIsTrue ? 1 : 0 ;
38063812 ifCond->emplace_back (rawtok->location , E, result);
38073813 }
3808- } else if (rawtok->str () == IFNDEF ) {
3814+ } else if (rawtok->str () == IFNDEF || rawtok-> str () == ELIFNDEF ) {
38093815 const std::string &name = rawtok->next ->str ();
38103816 conditionIsTrue = (macros.find (name) == macros.end () && !(hasInclude && name == HAS_INCLUDE ));
38113817 maybeUsedMacros[name].emplace_back (rawtok->next ->location );
@@ -3936,7 +3942,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
39363942 }
39373943 }
39383944
3939- if (rawtok->str () != ELIF ) {
3945+ if (rawtok->str () != ELIF && rawtok-> str () != ELIFDEF && rawtok-> str () != ELIFNDEF ) {
39403946 // push a new ifstate..
39413947 if (ifstates.top () != True)
39423948 ifstates.push (AlwaysFalse);
0 commit comments