From: Richard Smith Date: Thu, 5 Oct 2017 00:48:18 +0000 (+0000) Subject: Add testcase for r314956: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5085172fa3c7010ced43519ff23ce244f1e7607;p=clang Add testcase for r314956: 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 --- diff --git a/test/Modules/merge-lambdas.cpp b/test/Modules/merge-lambdas.cpp new file mode 100644 index 0000000000..6f243ae54c --- /dev/null +++ b/test/Modules/merge-lambdas.cpp @@ -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 void doFormat(T &&out) {} }; +template 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(); +}