[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 03:39:09 PDT 2024


================
@@ -0,0 +1,30 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST1
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -target-feature +sme2 -emit-llvm -o - %s -verify -DTEST2
+
+int normal_fn(int);
+int streaming_fn(int) __arm_streaming;
+int streaming_compatible_fn(int) __arm_streaming_compatible;
+
+#ifdef TEST1
+
+// expected-error at +3 {{definition with same mangled name '_ZZ32function_params_normal_streamingvENK3$_0clIFiiEEEDaRT_' as another definition}}
+// expected-note at +2 {{previous definition is here}}
+int function_params_normal_streaming() {
+  auto a = [](auto &fn) { return fn(42); };
+  return a(normal_fn) + a(streaming_fn);
+}
+
+#endif
+
+#ifdef TEST2
+
+// expected-error at +3 {{definition with same mangled name '_ZZ36function_params_streaming_compatiblevENK3$_0clIFiiEEEDaRT_' as another definition}}
+// expected-note at +2 {{previous definition is here}}
+int function_params_streaming_compatible() {
+  auto a = [](auto &fn) { return fn(42); };
+  return a(streaming_fn) + a(streaming_compatible_fn);
+}
+
+#endif
----------------
sdesmalen-arm wrote:

Can you add a separate test for a non-SME attribute that has a similar issue?

Type attributes for the calling convention are also not part of the type mangling, e.g. https://godbolt.org/z/sEdsGr53K which would (without your change) miscompile.

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


More information about the cfe-commits mailing list