gnu.cfg: Define `__typeof__` as `typeof`, fix simplifyTypedef() (#2260)

`__typeof__` is just an alternative keyword for `typeof`, see
https://gcc.gnu.org/onlinedocs/gcc/Typeof.html
Since `typeof` is handled in several checkers it makes sense to define
`__typeof__` as `typeof`.
Tokenizer::simplifyTypedef(): Use `typeof` instead of `__typeof__` to
be consistent with the rest of the code.
This commit is contained in:
Sebastian 2019-10-14 08:20:22 +02:00 committed by GitHub
parent bf5c90a2be
commit 267d23f1b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -47,6 +47,7 @@
<define name="__builtin_nanl(str)" value="nanl(str)"/>
<define name="__builtin_signbit(value)" value="signbit(value)"/>
<define name="__extension__" value=""/>
<define name="__typeof__(T)" value="typeof(T)"/>
<!-- void *__builtin_alloca (size_t size) -->
<!-- alloca() is often defined as __builtin_alloca() so the define above does not work always -->
<!-- void *alloca(size_t size); -->

View File

@ -842,8 +842,8 @@ void Tokenizer::simplifyTypedef()
}
}
// typeof: typedef __typeof__ ( ... ) type;
else if (Token::simpleMatch(tokOffset->previous(), "__typeof__ (") &&
// typeof: typedef typeof ( ... ) type;
else if (Token::simpleMatch(tokOffset->previous(), "typeof (") &&
Token::Match(tokOffset->link(), ") %type% ;")) {
argStart = tokOffset;
argEnd = tokOffset->link();

View File

@ -1626,10 +1626,10 @@ private:
}
void simplifyTypedef64() {
const char code[] = "typedef __typeof__(__type1() + __type2()) __type;"
const char code[] = "typedef typeof(__type1() + __type2()) __type;"
"__type t;";
const std::string actual(tok(code));
ASSERT_EQUALS("__typeof__ ( __type1 ( ) + __type2 ( ) ) t ;", actual);
ASSERT_EQUALS("typeof ( __type1 ( ) + __type2 ( ) ) t ;", actual);
ASSERT_EQUALS("", errout.str());
}