diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-12-20 18:11:52 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-12-20 18:11:52 +0000 |
| commit | 21823bfe318a02a73f96e05c368211b640f6bc53 (patch) | |
| tree | 24b3d01c99ad5d6f4085defcdc657a8eb032dddf /clang/test | |
| parent | 9735fc9abd19b13ae521c6c29be043da74e93d0d (diff) | |
| download | bcm5719-llvm-21823bfe318a02a73f96e05c368211b640f6bc53.tar.gz bcm5719-llvm-21823bfe318a02a73f96e05c368211b640f6bc53.zip | |
When performing name lookup for a redeclaration, ignore module
visibility restrictions. This ensures that all declarations of the
same entity end up in the same redeclaration chain, even if some of
those declarations aren't visible. While this may seem unfortunate to
some---why can't two C modules have different functions named
'f'?---it's an acknowedgment that a module does not introduce a new
"namespace" of names.
As part of this, stop merging the 'module-private' bit from previous
declarations to later declarations, because we want each declaration
in a module to stand on its own because this can effect, for example,
submodule visibility.
Note that this notion of names that are invisible to normal name
lookup but are available for redeclaration lookups is how we should
implement friend declarations and extern declarations within local
function scopes. I'm not tackling that problem now.
llvm-svn: 146980
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Modules/Inputs/module.map | 3 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/module_private_left.h | 8 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/module_private_right.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/redecl-merge-left.h | 6 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/redecl-merge-right.h | 6 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/redecl-merge-top-explicit.h | 5 | ||||
| -rw-r--r-- | clang/test/Modules/module-private.cpp | 24 | ||||
| -rw-r--r-- | clang/test/Modules/redecl-merge.m | 12 |
8 files changed, 48 insertions, 18 deletions
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index b101c01567d..13a44eb6a76 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -44,7 +44,8 @@ module decldef { } module redecl_merge_top { - header "redecl-merge-top.h" + header "redecl-merge-top.h" + explicit module Explicit { header "redecl-merge-top-explicit.h" } } module redecl_merge_left { header "redecl-merge-left.h" diff --git a/clang/test/Modules/Inputs/module_private_left.h b/clang/test/Modules/Inputs/module_private_left.h index 617a7abf3d9..ff33999d0fb 100644 --- a/clang/test/Modules/Inputs/module_private_left.h +++ b/clang/test/Modules/Inputs/module_private_left.h @@ -1,6 +1,6 @@ __module_private__ struct HiddenStruct; -struct HiddenStruct { +__module_private__ struct HiddenStruct { }; @@ -10,17 +10,17 @@ template<typename T> __module_private__ void f1(T*); template<typename T> -void f1(T*); +__module_private__ void f1(T*); template<typename T> __module_private__ class vector; template<typename T> -class vector { +__module_private__ class vector { }; vector<float> vec_float; typedef __module_private__ int Integer; -typedef int Integer; +typedef __module_private__ int Integer; diff --git a/clang/test/Modules/Inputs/module_private_right.h b/clang/test/Modules/Inputs/module_private_right.h index e7c1bb82216..53efe25d088 100644 --- a/clang/test/Modules/Inputs/module_private_right.h +++ b/clang/test/Modules/Inputs/module_private_right.h @@ -1,5 +1,5 @@ __module_private__ double &f0(double); -double &f0(double); +__module_private__ double &f0(double); __module_private__ int hidden_var; diff --git a/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h index 8e2fa53ae13..4e009591de6 100644 --- a/clang/test/Modules/Inputs/redecl-merge-left.h +++ b/clang/test/Modules/Inputs/redecl-merge-left.h @@ -10,6 +10,12 @@ __import_module__ redecl_merge_top; @class A; +@class Explicit; + +int *explicit_func(void); + +struct explicit_struct; + #ifdef __cplusplus template<typename T> class Vector; diff --git a/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h index 6d697347114..f0bfd35746f 100644 --- a/clang/test/Modules/Inputs/redecl-merge-right.h +++ b/clang/test/Modules/Inputs/redecl-merge-right.h @@ -9,6 +9,12 @@ __import_module__ redecl_merge_top; @class B; +@class Explicit; + +int *explicit_func(void); + +struct explicit_struct; + #ifdef __cplusplus template<typename T> class Vector { public: diff --git a/clang/test/Modules/Inputs/redecl-merge-top-explicit.h b/clang/test/Modules/Inputs/redecl-merge-top-explicit.h new file mode 100644 index 00000000000..c8f51589f31 --- /dev/null +++ b/clang/test/Modules/Inputs/redecl-merge-top-explicit.h @@ -0,0 +1,5 @@ +@class Explicit; + +int *explicit_func(void); + +struct explicit_struct { int member; }; diff --git a/clang/test/Modules/module-private.cpp b/clang/test/Modules/module-private.cpp index eb932a8eb85..bdfa2682ce1 100644 --- a/clang/test/Modules/module-private.cpp +++ b/clang/test/Modules/module-private.cpp @@ -31,28 +31,28 @@ int test_broken() { // Check for private redeclarations of public entities. template<typename T> -class public_class_template; // expected-note{{previous declaration is here}} +class public_class_template; template<typename T> -__module_private__ class public_class_template; // expected-error{{__module_private__ declaration of 'public_class_template' follows public declaration}} +__module_private__ class public_class_template; -typedef int public_typedef; // expected-note{{previous declaration is here}} -typedef __module_private__ int public_typedef; // expected-error{{__module_private__ declaration of 'public_typedef' follows public declaration}} +typedef int public_typedef; +typedef __module_private__ int public_typedef; -extern int public_var; // expected-note{{previous declaration is here}} -extern __module_private__ int public_var; // expected-error{{__module_private__ declaration of 'public_var' follows public declaration}} +extern int public_var; +extern __module_private__ int public_var; -void public_func(); // expected-note{{previous declaration is here}} -__module_private__ void public_func(); // expected-error{{__module_private__ declaration of 'public_func' follows public declaration}} +void public_func(); +__module_private__ void public_func(); template<typename T> -void public_func_template(); // expected-note{{previous declaration is here}} +void public_func_template(); template<typename T> -__module_private__ void public_func_template(); // expected-error{{__module_private__ declaration of 'public_func_template' follows public declaration}} +__module_private__ void public_func_template(); -struct public_struct; // expected-note{{previous declaration is here}} -__module_private__ struct public_struct; // expected-error{{__module_private__ declaration of 'public_struct' follows public declaration}} +struct public_struct; +__module_private__ struct public_struct; // Check for attempts to make specializations private template<> __module_private__ void public_func_template<int>(); // expected-error{{template specialization cannot be declared __module_private__}} diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m index 6497268c384..7021d14f698 100644 --- a/clang/test/Modules/redecl-merge.m +++ b/clang/test/Modules/redecl-merge.m @@ -20,6 +20,18 @@ B *f1() { @class B; +// Test redeclarations of entities in explicit submodules, to make +// sure we're maintaining the declaration chains even when normal name +// lookup can't see what we're looking for. +void testExplicit() { + Explicit *e; + int *(*fp)(void) = &explicit_func; + int *ip = explicit_func(); + + // FIXME: Should complain about definition not having been imported. + struct explicit_struct es = { 0 }; +} + __import_module__ redecl_merge_bottom; @implementation B |

