[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:08 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:

This test adds much value over the other test above, because the logic is no different for streaming and streaming-compatible attributes, so I think you can remove it.

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


More information about the cfe-commits mailing list