[PATCH] D137020: [clang][AST] Handle variable declaration with unknown typedef in C

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 30 08:06:59 PST 2022


sammccall added inline comments.


================
Comment at: clang/test/Parser/recovery.c:105
+  unknown_t a; // expected-error {{unknown type name 'unknown_t'}}
+  unknown_t *b; // expected-error {{unknown type name 'unknown_t'}}
+  unknown_t const *c; // expected-error {{unknown type name 'unknown_t'}}
----------------
aaron.ballman wrote:
> urazoff wrote:
> > sammccall wrote:
> > > this diagnostic is worse than the old one (less accurate).
> > > 
> > > (I think it's OK to trade off diagnostics quality if it's better on balance, maybe leave a comment?)
> > Just to mention, this is exact behavior of clang for C++.
> > this diagnostic is worse than the old one (less accurate).
> 
> Less accurate how? It went from `use of undeclared identifier 'unknown_t'` to `unknown type name 'unknown_t'` and that seems accurate to me given that the undeclared identifier is written in a type position.
It *could* be a type position, or it could be an operand of multiplication - because the identifier is unresolved, we don't know.

(We could discount the possibility it's a multiplication expression because the result would be discarded, but AFAICT that's not actually what's happening and it'll fire in other cases).

Regardless, this seems OK to me (especially given we already make this guess for C++!)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137020/new/

https://reviews.llvm.org/D137020



More information about the cfe-commits mailing list