parent
bb5cad42cd
commit
8774e97f26
|
@ -9667,7 +9667,7 @@ void Tokenizer::findGarbageCode() const
|
|||
}
|
||||
if (Token::Match(tok, "[!|+-/%^~] )|]"))
|
||||
syntaxError(tok);
|
||||
if (Token::Match(tok, "==|!=|<=|>= %comp%"))
|
||||
if (Token::Match(tok, "==|!=|<=|>= %comp%") && tok->strAt(-1) != "operator")
|
||||
syntaxError(tok, tok->str() + " " + tok->strAt(1));
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ private:
|
|||
TEST_CASE(tokenize36); // #8436
|
||||
TEST_CASE(tokenize37); // #8550
|
||||
TEST_CASE(tokenize38); // #9569
|
||||
TEST_CASE(tokenize39); // #9771
|
||||
|
||||
TEST_CASE(validate);
|
||||
|
||||
|
@ -899,6 +900,16 @@ private:
|
|||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void tokenize39() { // #9771
|
||||
const char code[] = "template <typename T> class Foo;"
|
||||
"template <typename T> bool operator!=(const Foo<T> &, const Foo<T> &);"
|
||||
"template <typename T> class Foo { friend bool operator!= <> (const Foo<T> &, const Foo<T> &); };";
|
||||
const char exp[] = "template < typename T > class Foo ; "
|
||||
"template < typename T > bool operator!= ( const Foo < T > & , const Foo < T > & ) ; "
|
||||
"template < typename T > class Foo { friend bool operator!= < > ( const Foo < T > & , const Foo < T > & ) ; } ;";
|
||||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void validate() {
|
||||
// C++ code in C file
|
||||
ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);
|
||||
|
|
Loading…
Reference in New Issue