================
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -Wunused -x c -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -Wunused -x c++ 
-verify=expected,cxx %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+static int f(void) { return 42; }
+int g(void) __attribute__((alias("f")));
----------------
MaskRay wrote:

> Ah! right you pointed this out in your note. Perhaps we should fix/change 
> that first in clang?

I remember an existing issue about the mangling difference, but I don't recall 
the link now.
I have analyzed it a bit and run into a feature where we need mangling.
The discrepancy from GCC is indeed unfortunate and in practice makes 
`alias`/`ifunc` not useful for internal linkage targets in C++.

https://eel.is/c++draft/dcl.link gives an example

```cpp
extern "C" {
  static void f4();             // the name of the function f4 has internal 
linkage,
                                // so f4 has no language linkage; its type has 
C language linkage
}
```

I am unsure whether "no language linkage" means that ignoring the C language 
linkage is fine.

---

Improving GCC consistency is not the goal of this PR. This PR intends to make 
clangSema and clangCodeGen consistent. If we want to follow GCC in the future, 
the updated test will show the differences.

https://github.com/llvm/llvm-project/pull/87130
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to