Hi all.
there's a new syntax error occurring with cppcheck head. With 7406dd8c941a60ba111dd4857dce0b99c54eef79 it appeared. With 12abf85d1d63e87edfeab8533e025ee7aec45a89 it wasn't there.
Example code is:
auto createArgv(const std::vector<std::string> &arguments) -> std::unique_ptr<const char *[]> { auto argv = cpp14::make_unique<const char *[]>(arguments.size() + 1); for (decltype(arguments.size()) i = 0; i < arguments.size(); ++i) { argv[i] = arguments[i].c_str(); } }
cppcheck output is:
/foo.cpp:4:18: error: Syntax Error: AST broken, 'arguments' doesn't have a parent. [internalAstError] for (decltype(arguments.size()) i = 0; i < arguments.size(); ++i) ^
Could you please check?
Thanks, Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10739
Same goes for:
void foo(Bar& bar) { const auto baz = [](const decltype(bar.p1)::value_type& p2) { return 0; }; }
cppcheck says:
/foo.cpp:3:39: error: Syntax Error: AST broken, 'bar' doesn't have a parent. [internalAstError] const auto baz = [](const decltype(bar.p1)::value_type& p2) { ^
Ran probably into same issue with cppcheck 2.7 and uthash.h
#include "uthash.h" struct a { UT_hash_handle hh; }; struct b { struct a *hash; }; void test() { struct b *c = calloc(1, sizeof(struct b)); struct a *xx = calloc(1, sizeof(struct a)); // Works HASH_DEL(xx, xx); // internalAstError HASH_DEL(c->hash, xx); }
gcc -E version in https://gist.github.com/Aketzu/9da9266bc33ac5829f7d41910c7fb138
Reduced example:
struct A; struct B { A* hash; }; void f(void* p, B* b) { b->hash = (__typeof(b->hash))(p); }
internalAstError is reported for __typeof, __typeof__, typeof, decltype
internalAstError
__typeof
__typeof__
typeof
decltype
It also fails for any function call, like this:
struct A; struct B { A* hash; }; auto g(A* a) { return [=](void*) { return a; }; } void f(void* p, B* b) { b->hash = (g(b->hash))(p); }
We should probably file a ticket for this.
New ticket is here: https://trac.cppcheck.net/ticket/10839
Log in to post a comment.
Hi all.
there's a new syntax error occurring with cppcheck head.
With 7406dd8c941a60ba111dd4857dce0b99c54eef79 it appeared.
With 12abf85d1d63e87edfeab8533e025ee7aec45a89 it wasn't there.
Example code is:
cppcheck output is:
Could you please check?
Thanks,
Martin
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10739
Same goes for:
cppcheck says:
Ran probably into same issue with cppcheck 2.7 and uthash.h
gcc -E version in https://gist.github.com/Aketzu/9da9266bc33ac5829f7d41910c7fb138
Reduced example:
internalAstError
is reported for__typeof
,__typeof__
,typeof
,decltype
It also fails for any function call, like this:
We should probably file a ticket for this.
New ticket is here: https://trac.cppcheck.net/ticket/10839