Fixed wrong parsing of ^{}
This commit is contained in:
parent
4f565ba90f
commit
b049050792
|
@ -9294,9 +9294,7 @@ void Tokenizer::simplifyAsm2()
|
|||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "^ {")) {
|
||||
Token * start = tok;
|
||||
while (start && !Token::Match(start, "[;{}]")) {
|
||||
if (start->link() && Token::Match(start, ")|]"))
|
||||
start = start->link();
|
||||
while (start && !Token::Match(start, "[;{})]")) {
|
||||
start = start->previous();
|
||||
}
|
||||
if (start)
|
||||
|
@ -9304,8 +9302,9 @@ void Tokenizer::simplifyAsm2()
|
|||
const Token *last = tok->next()->link();
|
||||
if (start != tok) {
|
||||
last = last->next();
|
||||
while (last && !Token::Match(last->next(), "[;{}()]"))
|
||||
while (last && !Token::Match(last->next(), "[;{})]"))
|
||||
last = last->next();
|
||||
last = last->next();
|
||||
}
|
||||
if (start && last) {
|
||||
std::string asmcode(start->str());
|
||||
|
|
|
@ -657,8 +657,8 @@ private:
|
|||
}
|
||||
|
||||
void garbageCode58() { // #6732, #6762
|
||||
ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError);
|
||||
ASSERT_THROW(checkCode("{= ~A()^{} }P { } { }> is"), InternalError);
|
||||
checkCode("{ }> {= ~A()^{} }P { }");
|
||||
checkCode("{= ~A()^{} }P { } { }> is");
|
||||
}
|
||||
|
||||
void garbageCode59() { // #6735
|
||||
|
@ -782,7 +782,7 @@ private:
|
|||
}
|
||||
|
||||
void garbageCode89() { // #6772
|
||||
ASSERT_THROW(checkCode("{ { ( ) } P ( ) ^ { } { } { } ( ) } 0"), InternalError); // do not crash
|
||||
checkCode("{ { ( ) } P ( ) ^ { } { } { } ( ) } 0"); // do not crash
|
||||
}
|
||||
|
||||
void garbageCode90() { // #6790
|
||||
|
@ -1164,6 +1164,8 @@ private:
|
|||
" for (int ui = 0; ui < 1z; ui++)\n"
|
||||
" ;\n"
|
||||
"}");
|
||||
|
||||
checkCode("; void f ^ { return } int main ( ) { }"); // #4941
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
|
|
|
@ -810,7 +810,7 @@ private:
|
|||
" return sizeof...(args);\n"
|
||||
" }();\n"
|
||||
"}";
|
||||
ASSERT_THROW(tok(code), InternalError);
|
||||
tok(code);
|
||||
}
|
||||
|
||||
void template43() { // #5097 - Assert due to '>>' in 'B<A<C>>' not being treated as end of template instantation
|
||||
|
|
|
@ -775,8 +775,20 @@ private:
|
|||
// #4725 - ^{}
|
||||
void tokenize28() {
|
||||
ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }"));
|
||||
ASSERT_EQUALS("void f ( ) { asm ( \"x(^{})\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }"));
|
||||
ASSERT_EQUALS("; asm ( \"voidf^{return}intmain\" ) ; ( ) { }", tokenizeAndStringify("; void f ^ { return } int main ( ) { }"));
|
||||
ASSERT_EQUALS("void f ( ) { asm ( \"x(^{});\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }"));
|
||||
ASSERT_EQUALS("int f0 ( Args args ) {\n"
|
||||
"asm ( \"return^{returnsizeof...(Args);}()\" ) ;\n"
|
||||
"\n"
|
||||
"asm ( \"+^{returnsizeof...(args);}()\" ) ;\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"} ;", tokenizeAndStringify("int f0(Args args) {\n"
|
||||
" return ^{\n"
|
||||
" return sizeof...(Args);\n"
|
||||
" }() + ^ {\n"
|
||||
" return sizeof...(args);\n"
|
||||
" }();\n"
|
||||
"};"));
|
||||
}
|
||||
|
||||
// #3503 - don't "simplify" SetFunction member function to a variable
|
||||
|
|
Loading…
Reference in New Issue