[clang] [clang] fix crash in friend definition (PR #186398)

via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 15 15:30:02 PDT 2026


Serosh-commits wrote:

> > @mizvekov using SS.clear() and Previous.clear() stops the crash but it breaks some existing tests i think the reason is that it runs for all qualified friend definitions, including cases like friend void C::f() inside a class, which should produce a different diagnostic so i am kinda thinking maybe the recovery should run only when the qualifier refers to namespace/global scope, which we can check using computeDeclContext(SS) will that would be a good approach ? i think this should work
> 
> Ah yes, though that case is simpler to check, you don't need `computeDeclContext`, you can simply check for the right kinds of nested name specifier (namespace, namespace alias, and global).

oh yeah that's simple thanks :)

https://github.com/llvm/llvm-project/pull/186398


More information about the cfe-commits mailing list