summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/merge-using-decls/a.h43
-rw-r--r--clang/test/Modules/Inputs/merge-using-decls/b.h50
-rw-r--r--clang/test/Modules/Inputs/merge-using-decls/module.modulemap2
-rw-r--r--clang/test/Modules/merge-using-decls.cpp69
4 files changed, 164 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/merge-using-decls/a.h b/clang/test/Modules/Inputs/merge-using-decls/a.h
new file mode 100644
index 00000000000..0fe0067bf23
--- /dev/null
+++ b/clang/test/Modules/Inputs/merge-using-decls/a.h
@@ -0,0 +1,43 @@
+struct X {
+ int v;
+ typedef int t;
+};
+
+struct YA {
+ int value;
+ typedef int type;
+};
+
+template<typename T> struct C : X, T {
+ using T::value;
+ using typename T::type;
+ using X::v;
+ using typename X::t;
+};
+
+template<typename T> struct D : X, T {
+ using T::value;
+ using typename T::type;
+ using X::v;
+ using typename X::t;
+};
+
+template<typename T> struct E : X, T {
+ using T::value;
+ using typename T::type;
+ using X::v;
+ using typename X::t;
+};
+
+template<typename T> struct F : X, T {
+ using T::value;
+ using typename T::type;
+ using X::v;
+ using typename X::t;
+};
+
+// Force instantiation.
+typedef C<YA>::type I;
+typedef D<YA>::type I;
+typedef E<YA>::type I;
+typedef F<YA>::type I;
diff --git a/clang/test/Modules/Inputs/merge-using-decls/b.h b/clang/test/Modules/Inputs/merge-using-decls/b.h
new file mode 100644
index 00000000000..359555570a4
--- /dev/null
+++ b/clang/test/Modules/Inputs/merge-using-decls/b.h
@@ -0,0 +1,50 @@
+struct X {
+ int v;
+ typedef int t;
+};
+
+struct YB {
+ typedef YB Y;
+ int value;
+ typedef int type;
+};
+
+struct YBRev {
+ typedef int value;
+ int type;
+};
+
+template<typename T> struct C : X, T {
+ using T::value;
+ using typename T::type;
+ using X::v;
+ using typename X::t;
+};
+
+template<typename T> struct D : X, T {
+ // Mismatch in type/non-type-ness.
+ using typename T::value;
+ using T::type;
+ using X::v;
+ using typename X::t;
+};
+
+template<typename T> struct E : X, T {
+ // Mismatch in using/access-declaration-ness.
+ T::value;
+ X::v;
+};
+
+template<typename T> struct F : X, T {
+ // Mismatch in nested-name-specifier.
+ using T::Y::value;
+ using typename T::Y::type;
+ using ::X::v;
+ using typename ::X::t;
+};
+
+// Force instantiation.
+typedef C<YB>::type I;
+typedef D<YBRev>::t I;
+typedef E<YB>::type I;
+typedef F<YB>::type I;
diff --git a/clang/test/Modules/Inputs/merge-using-decls/module.modulemap b/clang/test/Modules/Inputs/merge-using-decls/module.modulemap
new file mode 100644
index 00000000000..a415527813c
--- /dev/null
+++ b/clang/test/Modules/Inputs/merge-using-decls/module.modulemap
@@ -0,0 +1,2 @@
+module A { header "a.h" }
+module B { header "b.h" }
diff --git a/clang/test/Modules/merge-using-decls.cpp b/clang/test/Modules/merge-using-decls.cpp
new file mode 100644
index 00000000000..3b84d0e5a3a
--- /dev/null
+++ b/clang/test/Modules/merge-using-decls.cpp
@@ -0,0 +1,69 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
+
+#if ORDER == 1
+#include "a.h"
+#include "b.h"
+#else
+#include "b.h"
+#include "a.h"
+#endif
+
+struct Y {
+ int value; // expected-note 0-1{{target of using}}
+ typedef int type; // expected-note 0-1{{target of using}}
+};
+
+template<typename T> int Use() {
+ int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
+ typedef typename T::type I;
+ typedef typename T::t I;
+ typedef int I;
+ return k;
+}
+
+template<typename T> int UseAll() {
+ return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
+}
+
+template int UseAll<YA>();
+template int UseAll<YB>();
+template int UseAll<Y>();
+
+#if ORDER == 1
+// Here, we're instantiating the definition from 'A' and merging the definition
+// from 'B' into it.
+
+// expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+// expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+
+// expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+
+// expected-note@a.h:* +{{does not match}}
+#else
+// Here, we're instantiating the definition from 'B' and merging the definition
+// from 'A' into it.
+
+// expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
+// expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
+// expected-error@b.h:* 2{{'typename' keyword used on a non-type}}
+// expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
+
+// expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-note@b.h:* 2{{definition has no member}}
+
+// expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+
+// expected-note@b.h:* +{{does not match}}
+// expected-note@b.h:* +{{target of using}}
+#endif
OpenPOWER on IntegriCloud