@@ -238,6 +238,9 @@ class TestPreprocessor : public TestFixture {
238238 TEST_CASE (predefine5); // automatically define __cplusplus
239239 TEST_CASE (predefine6); // automatically define __STDC_VERSION__
240240
241+
242+ TEST_CASE (strictAnsi);
243+
241244 TEST_CASE (invalidElIf); // #2942 segfault
242245
243246 // Preprocessor::getConfigs
@@ -2036,6 +2039,23 @@ class TestPreprocessor : public TestFixture {
20362039 ASSERT_EQUALS (" " , PreprocessorHelper::getcode (settings0, *this , code, " " , " test.cpp" ));
20372040 }
20382041
2042+ void strictAnsi () {
2043+ const char code[] = " #ifdef __STRICT_ANSI__\n 123\n #endif" ;
2044+ Settings settings;
2045+
2046+ settings.standards .setStd (" gnu99" );
2047+ ASSERT_EQUALS (" " , PreprocessorHelper::getcode (settings, *this , code, " " , " test.c" ));
2048+
2049+ settings.standards .setStd (" c99" );
2050+ ASSERT_EQUALS (" \n 123" , PreprocessorHelper::getcode (settings, *this , code, " " , " test.c" ));
2051+
2052+ settings.standards .setStd (" gnu++11" );
2053+ ASSERT_EQUALS (" " , PreprocessorHelper::getcode (settings, *this , code, " " , " test.cpp" ));
2054+
2055+ settings.standards .setStd (" c++11" );
2056+ ASSERT_EQUALS (" \n 123" , PreprocessorHelper::getcode (settings, *this , code, " " , " test.cpp" ));
2057+ }
2058+
20392059 void invalidElIf () {
20402060 // #2942 - segfault
20412061 const char code[] = " #elif (){\n " ;
0 commit comments