]> granicus.if.org Git - clang/commitdiff
Add testcase for r314956:
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 5 Oct 2017 00:48:18 +0000 (00:48 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 5 Oct 2017 00:48:18 +0000 (00:48 +0000)
PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314957 91177308-0d34-0410-b5e6-96231b3b80d8

test/Modules/merge-lambdas.cpp [new file with mode: 0644]

diff --git a/test/Modules/merge-lambdas.cpp b/test/Modules/merge-lambdas.cpp
new file mode 100644 (file)
index 0000000..6f243ae
--- /dev/null
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm-only -fmodules %s
+
+// PR33924: ensure that we merge together local lambas in multiple definitions
+// of the same function.
+
+#pragma clang module build format
+module format {}
+#pragma clang module contents
+#pragma clang module begin format
+struct A { template<typename T> void doFormat(T &&out) {} };
+template<typename T> void format(T t) { A().doFormat([]{}); }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build foo1
+module foo1 { export * }
+#pragma clang module contents
+#pragma clang module begin foo1
+#pragma clang module import format
+inline void foo1() {
+  format(0);
+}
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build foo2
+module foo2 { export * }
+#pragma clang module contents
+#pragma clang module begin foo2
+#pragma clang module import format
+inline void foo2() {
+  format(0);
+}
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module import foo1
+#pragma clang module import foo2
+
+int main() {
+  foo1();
+  foo2();
+}