summaryrefslogtreecommitdiff
path: root/test/Modules/merge-static-locals.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-04 02:25:38 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-04 02:25:38 +0000
commitef356db5c03a0f052c09ebd0a964b9eda3852847 (patch)
tree28fbb44d59ddb9c84297007d9191b53710a1b53f /test/Modules/merge-static-locals.cpp
parent2926189c9bf4982cd6a0e9cc00d785837112d457 (diff)
downloadclang-ef356db5c03a0f052c09ebd0a964b9eda3852847.tar.gz
PR33924: merge local declarations that have linkage of some kind within
merged function definitions; also merge functions with deduced return types. This seems like two independent fixes, but unfortunately they are hard to separate because it's challenging to reliably test either one of them without also testing the other. A complication arises with deduced return type support: we need the type of the function in order to know how to merge it, but we can't load the actual type of the function because it might reference an entity declared within the function (and we need to have already merged the function to correctly merge that entity, which we would need to do to determine if the function types match). So we instead compare the declared function type when merging functions, and defer loading the actual type of a function with a deduced type until we've finished loading and merging the function. This reverts r336175, reinstating r336021, with one change (for PR38015): we look at the TypeSourceInfo of the first-so-far declaration of each function when considering whether to merge two functions. This works around a problem where the calling convention in the TypeSourceInfo for subsequent redeclarations may not match if it was implicitly adjusted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules/merge-static-locals.cpp')
-rw-r--r--test/Modules/merge-static-locals.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Modules/merge-static-locals.cpp b/test/Modules/merge-static-locals.cpp
new file mode 100644
index 0000000000..37ae22ee38
--- /dev/null
+++ b/test/Modules/merge-static-locals.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++17 -fmodules -verify %s
+// expected-no-diagnostics
+
+#pragma clang module build A
+module A {}
+#pragma clang module contents
+#pragma clang module begin A
+template<int*> struct X {};
+auto get() { static int n; return X<&n>(); }
+using A = decltype(get());
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build B
+module B {}
+#pragma clang module contents
+#pragma clang module begin B
+template<int*> struct X {};
+auto get() { static int n; return X<&n>(); }
+using B = decltype(get());
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module import A
+#pragma clang module import B
+using T = A;
+using T = B;