[clang] [clang] Fix possible nullptr deref in BuildCXXNestedNameSpecifier (PR #166995)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 7 13:22:46 PST 2025


================
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+namespace a {
+template <class b>
+void c() {
+  ((::c::)); // expected-error {{expected unqualified-id}}
----------------
ilovepi wrote:

> This looks like we aren't actually diagnosing the error? I'd expect something like `error: 'c' is not a class, namespace, or enumeration`, which is what we generate in the non-template case.
> 

Yeah, that was something I wasn't sure about.

> What happens if you instead write the following?
> 
> ```
>   ((::c::x));
> ```

Looks like we report nothing, the way I've structured it. That version still causes the crash w/o the nullptr check, so let me update the check to make sure it works in the expected way.

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


More information about the cfe-commits mailing list