2015-03-26 12:09:53 +08:00
|
|
|
// RUN: rm -rf %t
|
2015-06-16 08:08:24 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -DTEXTUAL
|
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery
|
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -DTEXTUAL
|
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility
|
2015-11-13 05:55:58 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -DTEXTUAL -DEARLY_INDIRECT_INCLUDE
|
2015-06-16 08:08:24 +08:00
|
|
|
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -fmodule-feature use_defs_twice -DIMPORT_USE_2
|
2015-03-26 12:09:53 +08:00
|
|
|
|
|
|
|
// Trigger import of definitions, but don't make them visible.
|
|
|
|
#include "empty.h"
|
2015-06-11 11:05:39 +08:00
|
|
|
#ifdef EARLY_INDIRECT_INCLUDE
|
|
|
|
#include "indirect.h"
|
|
|
|
#endif
|
2015-03-26 12:09:53 +08:00
|
|
|
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
A pre_a;
|
2015-06-16 04:15:48 +08:00
|
|
|
#ifdef IMPORT_USE_2
|
|
|
|
// expected-error-re@-2 {{must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}}
|
|
|
|
#elif EARLY_INDIRECT_INCLUDE
|
|
|
|
// expected-error@-4 {{must be imported from module 'merged-defs'}}
|
|
|
|
#else
|
|
|
|
// expected-error@-6 {{must be imported from module 'stuff.use'}}
|
|
|
|
#endif
|
2015-03-28 04:16:58 +08:00
|
|
|
// expected-note@defs.h:1 +{{here}}
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
extern class A pre_a2;
|
|
|
|
int pre_use_a = use_a(pre_a2); // expected-error {{'A' must be imported}} expected-error {{'use_a' must be imported}}
|
2015-06-12 09:32:13 +08:00
|
|
|
// expected-note@defs.h:2 +{{here}}
|
2015-03-26 12:09:53 +08:00
|
|
|
|
2015-03-27 08:41:57 +08:00
|
|
|
B::Inner2 pre_bi; // expected-error +{{must be imported}}
|
|
|
|
// expected-note@defs.h:4 +{{here}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:17 +{{here}}
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
void pre_bfi(B b) { // expected-error +{{must be imported}}
|
|
|
|
b.f<int>(); // expected-error +{{}}
|
2015-07-02 03:32:54 +08:00
|
|
|
}
|
2015-03-27 08:41:57 +08:00
|
|
|
|
|
|
|
C_Base<1> pre_cb1; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:23 +{{here}}
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
C1 pre_c1; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:25 +{{here}}
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
C2 pre_c2; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:26 +{{here}}
|
2015-03-27 08:41:57 +08:00
|
|
|
|
2015-03-27 09:37:43 +08:00
|
|
|
D::X pre_dx; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:28 +{{here}}
|
|
|
|
// expected-note@defs.h:29 +{{here}}
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
int pre_use_dx = use_dx(pre_dx); // ignored; pre_dx is invalid
|
2015-03-27 09:37:43 +08:00
|
|
|
|
2015-03-28 05:57:41 +08:00
|
|
|
int pre_e = E(0); // expected-error {{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:32 +{{here}}
|
2015-03-28 05:57:41 +08:00
|
|
|
|
|
|
|
int pre_ff = F<int>().f(); // expected-error +{{must be imported}}
|
|
|
|
int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:34 +{{here}}
|
2015-03-28 05:57:41 +08:00
|
|
|
|
2015-06-18 07:07:50 +08:00
|
|
|
G::A pre_ga // expected-error +{{must be imported}}
|
|
|
|
= G::a; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:49 +{{here}}
|
|
|
|
// expected-note@defs.h:50 +{{here}}
|
2015-07-02 03:32:54 +08:00
|
|
|
decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}}
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:51 +{{here}}
|
2015-06-18 07:07:50 +08:00
|
|
|
|
2015-06-18 04:16:32 +08:00
|
|
|
J<> pre_j; // expected-error {{declaration of 'J' must be imported}}
|
|
|
|
#ifdef IMPORT_USE_2
|
2015-06-18 04:39:41 +08:00
|
|
|
// expected-error-re@-2 {{default argument of 'J' must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}}
|
2015-06-18 04:16:32 +08:00
|
|
|
#elif EARLY_INDIRECT_INCLUDE
|
2015-06-18 04:39:41 +08:00
|
|
|
// expected-error@-4 {{default argument of 'J' must be imported from module 'merged-defs'}}
|
2015-06-18 04:16:32 +08:00
|
|
|
#else
|
2015-06-18 04:39:41 +08:00
|
|
|
// expected-error@-6 {{default argument of 'J' must be imported from module 'stuff.use'}}
|
2015-06-18 04:16:32 +08:00
|
|
|
#endif
|
2015-08-18 04:24:17 +08:00
|
|
|
// expected-note@defs.h:58 +{{here}}
|
2015-06-12 07:46:11 +08:00
|
|
|
|
[modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:
* It is visible (not in a module, or in an imported module), or
* We're doing redeclaration lookup and it's externally-visible, or
* We're doing typo correction and looking for unimported decls.
We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.
This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on). It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).
This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.
llvm-svn: 252960
2015-11-13 06:19:45 +08:00
|
|
|
ScopedEnum pre_scopedenum; // expected-error {{must be imported}}
|
|
|
|
// expected-note@defs.h:105 0-1{{here}}
|
|
|
|
// expected-note@defs.h:106 0-1{{here}}
|
2015-07-09 05:49:31 +08:00
|
|
|
enum ScopedEnum : int;
|
|
|
|
ScopedEnum pre_scopedenum_declared; // ok
|
|
|
|
|
2015-03-26 12:09:53 +08:00
|
|
|
// Make definitions from second module visible.
|
2015-03-28 05:16:39 +08:00
|
|
|
#ifdef TEXTUAL
|
2015-03-26 12:09:53 +08:00
|
|
|
#include "import-and-redefine.h"
|
2015-06-16 04:15:48 +08:00
|
|
|
#elif defined IMPORT_USE_2
|
|
|
|
#include "use-defs-2.h"
|
2015-03-28 05:16:39 +08:00
|
|
|
#else
|
|
|
|
#include "merged-defs.h"
|
|
|
|
#endif
|
2015-03-26 12:09:53 +08:00
|
|
|
|
|
|
|
A post_a;
|
2015-03-28 04:16:58 +08:00
|
|
|
int post_use_a = use_a(post_a);
|
2015-03-27 08:41:57 +08:00
|
|
|
B::Inner2 post_bi;
|
2015-07-02 03:32:54 +08:00
|
|
|
void post_bfi(B b) {
|
|
|
|
b.f<int>();
|
|
|
|
}
|
2015-03-27 08:41:57 +08:00
|
|
|
C_Base<1> post_cb1;
|
|
|
|
C1 c1;
|
|
|
|
C2 c2;
|
2015-03-27 09:37:43 +08:00
|
|
|
D::X post_dx;
|
2015-03-28 04:16:58 +08:00
|
|
|
int post_use_dx = use_dx(post_dx);
|
2015-03-28 05:57:41 +08:00
|
|
|
int post_e = E(0);
|
|
|
|
int post_ff = F<char>().f();
|
|
|
|
int post_fg = F<char>().g<int>();
|
2015-06-18 07:07:50 +08:00
|
|
|
G::A post_ga = G::a;
|
|
|
|
decltype(G::h) post_gh = G::h;
|
2015-06-12 07:46:11 +08:00
|
|
|
J<> post_j;
|
|
|
|
template<typename T, int N, template<typename> class K> struct J;
|
|
|
|
J<> post_j2;
|
2015-06-17 05:57:05 +08:00
|
|
|
FriendDefArg::Y<int> friend_def_arg;
|
2015-06-18 06:13:23 +08:00
|
|
|
FriendDefArg::D<> friend_def_arg_d;
|
2015-08-04 10:05:09 +08:00
|
|
|
int post_anon_x_n = Anon::X().n;
|
2015-06-23 05:15:01 +08:00
|
|
|
|
2015-07-02 07:19:58 +08:00
|
|
|
MergeFunctionTemplateSpecializations::X<int>::Q<char> xiqc;
|
|
|
|
|
2015-06-23 05:15:01 +08:00
|
|
|
#ifdef TEXTUAL
|
|
|
|
#include "use-defs.h"
|
|
|
|
void use_static_inline() { StaticInline::g({}); }
|
2015-11-13 05:55:58 +08:00
|
|
|
#ifdef EARLY_INDIRECT_INCLUDE
|
|
|
|
// expected-warning@-2 {{ambiguous use of internal linkage declaration 'g' defined in multiple modules}}
|
|
|
|
// expected-note@defs.h:71 {{declared here in module 'redef'}}
|
|
|
|
// expected-note@defs.h:71 {{declared here in module 'stuff.use'}}
|
|
|
|
#endif
|
2015-11-13 11:52:13 +08:00
|
|
|
int use_anon_enum = G::g;
|
|
|
|
#ifdef EARLY_INDIRECT_INCLUDE
|
|
|
|
// expected-warning@-2 3{{ambiguous use of internal linkage declaration 'g' defined in multiple modules}}
|
|
|
|
// FIXME: These notes are produced, but -verify can't match them?
|
|
|
|
// FIXME-note@defs.h:51 3{{declared here in module 'redef'}}
|
|
|
|
// FIXME-note@defs.h:51 3{{declared here in module 'stuff.use'}}
|
|
|
|
#endif
|
|
|
|
int use_named_enum = G::i;
|
2015-06-23 05:15:01 +08:00
|
|
|
#endif
|