summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/basic/basic.link/p7.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-09-20 01:15:31 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-09-20 01:15:31 +0000
commit541b38be7bf3afded3269a33586418254d82d7b3 (patch)
tree50251df12a54fbe196671445b8eee3d1a785b8cd /clang/test/CXX/basic/basic.link/p7.cpp
parent508939428d005dff37df7f2131aeb06ed674b719 (diff)
downloadbcm5719-llvm-541b38be7bf3afded3269a33586418254d82d7b3.tar.gz
bcm5719-llvm-541b38be7bf3afded3269a33586418254d82d7b3.zip
Switch the semantic DeclContext for a block-scope declaration of a function or
variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
Diffstat (limited to 'clang/test/CXX/basic/basic.link/p7.cpp')
-rw-r--r--clang/test/CXX/basic/basic.link/p7.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/clang/test/CXX/basic/basic.link/p7.cpp b/clang/test/CXX/basic/basic.link/p7.cpp
new file mode 100644
index 00000000000..9a85eacdda4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.link/p7.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -verify -std=c++1y %s
+
+// Example from the standard.
+namespace X {
+ void p() {
+ q(); // expected-error {{undeclared}}
+ extern void q();
+ }
+ void middle() {
+ q(); // expected-error {{undeclared}}
+ }
+ void q() { /*...*/ }
+ void bottom() {
+ q();
+ }
+}
+int q();
+
+namespace Test1 {
+ void f() {
+ extern int a; // expected-note {{previous}}
+ int g(void); // expected-note {{previous}}
+ }
+ double a; // expected-error {{different type: 'double' vs 'int'}}
+ double g(); // expected-error {{differ only in their return type}}
+}
+
+namespace Test2 {
+ void f() {
+ extern int a; // expected-note {{previous}}
+ int g(void); // expected-note {{previous}}
+ }
+ void h() {
+ extern double a; // expected-error {{different type: 'double' vs 'int'}}
+ double g(void); // expected-error {{differ only in their return type}}
+ }
+}
+
+namespace Test3 {
+ constexpr void (*f())() {
+ void h();
+ return &h;
+ }
+ constexpr void (*g())() {
+ void h();
+ return &h;
+ }
+ static_assert(f() == g(), "");
+}
+
+namespace Test4 {
+ template<typename T>
+ constexpr void (*f())() {
+ void h();
+ return &h;
+ }
+ static_assert(f<int>() == f<char>(), "");
+ void h();
+ static_assert(f<int>() == &h, "");
+}
+
+namespace Test5 {
+ constexpr auto f() -> void (*)() {
+ void g();
+ struct X {
+ friend void g();
+ static constexpr auto h() -> void (*)() { return g; }
+ };
+ return X::h();
+ }
+ void g();
+ static_assert(f() == g, "");
+}
OpenPOWER on IntegriCloud