[clang] [clang][AST] fix ast-print of `extern <lang>` with >=2 declarators (PR #93131)

Artem Yurchenko via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 12:16:34 PDT 2024


================
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+// CHECK: extern "C" int printf(const char *, ...);
+extern "C" int printf(const char *...);
+
+// CHECK: extern "C++" {
----------------
temyurchenko wrote:

> Oofda, there are differences between the braced and non-braced versions, so ideally, we want to reproduce exactly what was in the user's source to avoid accidentally changing the meaning of code

You are completely right, my bad. I'll work on fixing this. 

> z, y, and z are external, a, b, and c are not: https://godbolt.org/z/evG9KPKMM

I believe, they all have external linkage. However, x, y and z are also definitions, while a, b, and c are just declarations. So, for example, you can reference `x` from another translation unit and the value will be `0`. 

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


More information about the cfe-commits mailing list