Debian Codegraph @

clang/test/Modules/merge-using-decls.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=1
4 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=1
5 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++17 %s -DORDER=1
6 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
7 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=2
8 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=2
9
10 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++17 %s -DORDER=2
11 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fmodules -fimplicit-module-maps -fexperimental-new-constant-interpreter -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=1
12
13 #if ORDER == 1
14 #include "a.h"
15 #include "b.h"
16 #else
17 #include "b.h"
18 #include "a.h"
19 #endif
20
21 struct Y {
22 int value; // expected-note 0-1{{target of using}}
23 typedef int type; // expected-note 0-1{{target of using}}
24 };
25
26 template<typename T> int Use() {
27 int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
28 typedef typename T::type I;
29 typedef typename T::t I;
30 typedef int I;
31 return k;
32 }
33
34 template<typename T> int UseAll() {
35 #if __cplusplus <= 199711L // C++11 does not allow access declarations
36 return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
37 #else
38 return Use<C<T> >() + Use<D<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
39 #endif
40 }
41
42 template int UseAll<YA>();
43 template int UseAll<YB>();
44 template int UseAll<Y>();
45
46 #if __cplusplus >= 201702L
47 void use_g(Q q) {
48 q.f(q); // expected-error {{ambiguous}}
49 #if ORDER == 1
50 // [email protected]:* {{candidate function}}
51 // [email protected]:* {{candidate function}}
52 #else
53 // [email protected]:* {{candidate function}}
54 // [email protected]:* {{candidate function}}
55 #endif
56 }
57 #endif
58
59 // Which of these two sets of diagnostics is chosen is not important. It's OK
60 // if this varies with ORDER, but it must be consistent across runs.
61 #if ORDER == 1
62 // Here, we're instantiating the definition from 'A' and merging the definition
63 // from 'B' into it.
64
65 #if __cplusplus <= 199711L // C++11 does not allow access declarations
66 // [email protected]:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
67 // [email protected]:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
68 #endif
69
70 // [email protected]:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
71 // [email protected]:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
72 // [email protected]:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
73 // [email protected]:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
74
75 // [email protected]:* +{{does not match}}
76 #else
77 // Here, we're instantiating the definition from 'B' and merging the definition
78 // from 'A' into it.
79
80 // [email protected]:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
81 // [email protected]:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
82 // [email protected]:* 2{{'typename' keyword used on a non-type}}
83 // [email protected]:* 2{{dependent using declaration resolved to type without 'typename'}}
84
85 #if __cplusplus <= 199711L // C++11 does not allow access declarations
86 // [email protected]:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
87 // [email protected]:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
88 // [email protected]:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
89 // [email protected]:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
90 // [email protected]:* 2{{definition has no member}}
91 #endif
92
93
94 // [email protected]:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
95 // [email protected]:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
96 // [email protected]:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
97 // [email protected]:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
98
99 // [email protected]:* +{{does not match}}
100 // [email protected]:* +{{target of using}}
101 #endif