@@ -1617,6 +1617,48 @@ static void has_include_6()
16171617 ASSERT_EQUALS (" " , preprocess (code));
16181618}
16191619
1620+ static void strict_ansi_1 ()
1621+ {
1622+ const char code[] = " #if __STRICT_ANSI__\n "
1623+ " A\n "
1624+ " #endif" ;
1625+ simplecpp::DUI dui;
1626+ dui.std = " gnu99" ;
1627+ ASSERT_EQUALS (" " , preprocess (code, dui));
1628+ }
1629+
1630+ static void strict_ansi_2 ()
1631+ {
1632+ const char code[] = " #if __STRICT_ANSI__\n "
1633+ " A\n "
1634+ " #endif" ;
1635+ simplecpp::DUI dui;
1636+ dui.std = " c99" ;
1637+ ASSERT_EQUALS (" \n A" , preprocess (code, dui));
1638+ }
1639+
1640+ static void strict_ansi_3 ()
1641+ {
1642+ const char code[] = " #if __STRICT_ANSI__\n "
1643+ " A\n "
1644+ " #endif" ;
1645+ simplecpp::DUI dui;
1646+ dui.std = " c99" ;
1647+ dui.undefined .insert (" __STRICT_ANSI__" );
1648+ ASSERT_EQUALS (" " , preprocess (code, dui));
1649+ }
1650+
1651+ static void strict_ansi_4 ()
1652+ {
1653+ const char code[] = " #if __STRICT_ANSI__\n "
1654+ " A\n "
1655+ " #endif" ;
1656+ simplecpp::DUI dui;
1657+ dui.std = " gnu99" ;
1658+ dui.defines .push_back (" __STRICT_ANSI__" );
1659+ ASSERT_EQUALS (" \n A" , preprocess (code, dui));
1660+ }
1661+
16201662static void ifdef1 ()
16211663{
16221664 const char code[] = " #ifdef A\n "
@@ -3181,6 +3223,11 @@ int main(int argc, char **argv)
31813223 TEST_CASE (has_include_5);
31823224 TEST_CASE (has_include_6);
31833225
3226+ TEST_CASE (strict_ansi_1);
3227+ TEST_CASE (strict_ansi_2);
3228+ TEST_CASE (strict_ansi_3);
3229+ TEST_CASE (strict_ansi_4);
3230+
31843231 TEST_CASE (ifdef1);
31853232 TEST_CASE (ifdef2);
31863233 TEST_CASE (ifndef);
0 commit comments