C++17: Support "if constexpr" (by simplifying it to plain if() statement)
This might lead to complaints about constant expressions as if() statement, but should fix syntax errors.
This commit is contained in:
parent
49a3f32f80
commit
17b4721bd2
|
@ -3532,6 +3532,8 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
// 'for each ( )' -> 'asm ( )'
|
||||
tok->str("asm");
|
||||
tok->deleteNext();
|
||||
} else if (tok->strAt(1) == "constexpr") {
|
||||
tok->deleteNext();
|
||||
} else {
|
||||
syntaxError(tok);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ private:
|
|||
TEST_CASE(syntax_case_default);
|
||||
|
||||
TEST_CASE(foreach); // #3690
|
||||
TEST_CASE(ifconstexpr);
|
||||
|
||||
TEST_CASE(combineOperators);
|
||||
|
||||
|
@ -905,6 +906,10 @@ private:
|
|||
ASSERT_EQUALS("void f ( ) { asm ( \"char c in MyString\" ) { Console :: Write ( c ) ; } }", tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void ifconstexpr() {
|
||||
ASSERT_EQUALS("void f ( ) { if ( FOO ) { bar ( c ) ; } }", tokenizeAndStringify("void f() { if constexpr ( FOO ) { bar(c); } }"));
|
||||
}
|
||||
|
||||
void combineOperators() {
|
||||
ASSERT_EQUALS("; private: ;", tokenizeAndStringify(";private:;", false));
|
||||
ASSERT_EQUALS("; protected: ;", tokenizeAndStringify(";protected:;", false));
|
||||
|
|
Loading…
Reference in New Issue