diff options
author | John McCall <rjmccall@apple.com> | 2013-04-01 18:34:28 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-04-01 18:34:28 +0000 |
commit | b65e8fe143f8822ada578063f8d4b65db61b2788 (patch) | |
tree | dd0652c5f22227c876e9be4ba8e43363fe6663c2 /clang/test/CXX/basic/basic.link/p6.cpp | |
parent | ec0748068ed3bc261ccd1fc83a1423ace88d2567 (diff) | |
download | bcm5719-llvm-b65e8fe143f8822ada578063f8d4b65db61b2788.tar.gz bcm5719-llvm-b65e8fe143f8822ada578063f8d4b65db61b2788.zip |
Only merge down a variable type if the previous declaration was
visible. There's a lot of potential badness in how we're modelling
these things, but getting this much correct is reasonably easy.
rdar://13535367
llvm-svn: 178488
Diffstat (limited to 'clang/test/CXX/basic/basic.link/p6.cpp')
-rw-r--r-- | clang/test/CXX/basic/basic.link/p6.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/CXX/basic/basic.link/p6.cpp b/clang/test/CXX/basic/basic.link/p6.cpp new file mode 100644 index 00000000000..8faec76fb3f --- /dev/null +++ b/clang/test/CXX/basic/basic.link/p6.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// C++11 [basic.link]p6: +// The name of a function declared in block scope and the name +// of a variable declared by a block scope extern declaration +// have linkage. If there is a visible declaration of an entity +// with linkage having the same name and type, ignoring entities +// declared outside the innermost enclosing namespace scope, the +// block scope declaration declares that same entity and +// receives the linkage of the previous declaration. + +// rdar://13535367 +namespace test0 { + extern "C" int test0_array[]; + void declare() { extern int test0_array[100]; } + extern "C" int test0_array[]; + int value = sizeof(test0_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} +} + +namespace test1 { + extern "C" int test1_array[]; + void test() { + { extern int test1_array[100]; } + extern int test1_array[]; + int x = sizeof(test1_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} + } +} + +namespace test2 { + void declare() { extern int test2_array[100]; } + extern int test2_array[]; + int value = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} +} + +namespace test3 { + void test() { + { extern int test3_array[100]; } + extern int test3_array[]; + int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} + } +} + + |