summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-11-03 03:13:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-11-03 03:13:11 +0000
commit5cd86f8cec1a41b28318ce3a8678e5f53441a753 (patch)
tree927708a23036bc1bd91652702b45251023009b10 /clang/test
parent7339b9d75fff424d7d9a0686f303ef10b6c7ab05 (diff)
downloadbcm5719-llvm-5cd86f8cec1a41b28318ce3a8678e5f53441a753.tar.gz
bcm5719-llvm-5cd86f8cec1a41b28318ce3a8678e5f53441a753.zip
[modules] Rationalize the behavior of Decl::declarationReplaces, and in
particular don't assume that two declarations of the same kind in the same context are declaring the same entity. That's not true when the same name is declared multiple times as internal-linkage symbols within a module. (getCanonicalDecl is cheap now, so we can just use it here.) llvm-svn: 251898
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Modules/Inputs/internal-constants/a.h3
-rw-r--r--clang/test/Modules/Inputs/internal-constants/b.h3
-rw-r--r--clang/test/Modules/Inputs/internal-constants/c.h3
-rw-r--r--clang/test/Modules/Inputs/internal-constants/const.h3
-rw-r--r--clang/test/Modules/Inputs/internal-constants/module.modulemap6
-rw-r--r--clang/test/Modules/internal-constants.cpp12
-rw-r--r--clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp4
-rw-r--r--clang/test/SemaCXX/enable_if.cpp8
8 files changed, 36 insertions, 6 deletions
diff --git a/clang/test/Modules/Inputs/internal-constants/a.h b/clang/test/Modules/Inputs/internal-constants/a.h
new file mode 100644
index 00000000000..d2881381b75
--- /dev/null
+++ b/clang/test/Modules/Inputs/internal-constants/a.h
@@ -0,0 +1,3 @@
+#pragma once
+#include "const.h"
+inline int f() { return N::k; }
diff --git a/clang/test/Modules/Inputs/internal-constants/b.h b/clang/test/Modules/Inputs/internal-constants/b.h
new file mode 100644
index 00000000000..679603afa25
--- /dev/null
+++ b/clang/test/Modules/Inputs/internal-constants/b.h
@@ -0,0 +1,3 @@
+#pragma once
+#include "const.h"
+inline int g() { return N::k; }
diff --git a/clang/test/Modules/Inputs/internal-constants/c.h b/clang/test/Modules/Inputs/internal-constants/c.h
new file mode 100644
index 00000000000..43a37f831a4
--- /dev/null
+++ b/clang/test/Modules/Inputs/internal-constants/c.h
@@ -0,0 +1,3 @@
+#pragma once
+#include "a.h"
+inline int h() { return N::k; }
diff --git a/clang/test/Modules/Inputs/internal-constants/const.h b/clang/test/Modules/Inputs/internal-constants/const.h
new file mode 100644
index 00000000000..e2dc8e14571
--- /dev/null
+++ b/clang/test/Modules/Inputs/internal-constants/const.h
@@ -0,0 +1,3 @@
+namespace N {
+ const int k = 5;
+}
diff --git a/clang/test/Modules/Inputs/internal-constants/module.modulemap b/clang/test/Modules/Inputs/internal-constants/module.modulemap
new file mode 100644
index 00000000000..6d471f5fc94
--- /dev/null
+++ b/clang/test/Modules/Inputs/internal-constants/module.modulemap
@@ -0,0 +1,6 @@
+module X {
+ textual header "const.h"
+ module A { header "a.h" export * }
+ module B { header "b.h" export * }
+ module C { header "c.h" export * }
+}
diff --git a/clang/test/Modules/internal-constants.cpp b/clang/test/Modules/internal-constants.cpp
new file mode 100644
index 00000000000..f95e95cc8bb
--- /dev/null
+++ b/clang/test/Modules/internal-constants.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-local-submodule-visibility -I%S/Inputs/internal-constants %s -verify
+
+// expected-no-diagnostics
+#include "c.h"
+
+int q = h();
+int r = N::k;
+
+#include "b.h"
+
+int s = N::k; // FIXME: This should be ambiguous if we really want internal linkage declarations to not collide.
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index 145bc49fff1..787868fae17 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -90,8 +90,8 @@ namespace odr_tmpl {
}
namespace pvt_diff_params {
- template<typename T, typename> T v; // expected-note {{previous template declaration is here}}
- template<typename T> T v; // expected-error {{too few template parameters in template redeclaration}} expected-note {{previous template declaration is here}}
+ template<typename T, typename> T v; // expected-note 2{{previous template declaration is here}}
+ template<typename T> T v; // expected-error {{too few template parameters in template redeclaration}}
template<typename T, typename, typename> T v; // expected-error {{too many template parameters in template redeclaration}}
}
diff --git a/clang/test/SemaCXX/enable_if.cpp b/clang/test/SemaCXX/enable_if.cpp
index b04d9b4c9df..b32bcd01f42 100644
--- a/clang/test/SemaCXX/enable_if.cpp
+++ b/clang/test/SemaCXX/enable_if.cpp
@@ -11,7 +11,7 @@ struct X {
X(bool b) __attribute__((enable_if(b, "chosen when 'b' is true"))); // expected-note{{candidate disabled: chosen when 'b' is true}}
void f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero")));
- void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one"))); // expected-note{{member declaration nearly matches}} expected-note{{candidate disabled: chosen when 'n' is one}}
+ void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one"))); // expected-note{{member declaration nearly matches}} expected-note 2{{candidate disabled: chosen when 'n' is one}}
void g(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))); // expected-note{{candidate disabled: chosen when 'n' is zero}}
@@ -31,11 +31,11 @@ struct X {
operator fp() __attribute__((enable_if(false, "never enabled"))) { return surrogate; } // expected-note{{conversion candidate of type 'int (*)(int)'}} // FIXME: the message is not displayed
};
-void X::f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) // expected-note{{member declaration nearly matches}} expected-note{{candidate disabled: chosen when 'n' is zero}}
+void X::f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) // expected-note{{member declaration nearly matches}} expected-note 2{{candidate disabled: chosen when 'n' is zero}}
{
}
-void X::f(int n) __attribute__((enable_if(n == 2, "chosen when 'n' is two"))) // expected-error{{out-of-line definition of 'f' does not match any declaration in 'X'}} expected-note{{candidate disabled: chosen when 'n' is two}}
+void X::f(int n) __attribute__((enable_if(n == 2, "chosen when 'n' is two"))) // expected-error{{out-of-line definition of 'f' does not match any declaration in 'X'}}
{
}
@@ -73,7 +73,7 @@ void test() {
X x;
x.f(0);
x.f(1);
- x.f(2); // no error, suppressed by erroneous out-of-line definition
+ x.f(2); // expected-error{{no matching member function for call to 'f'}}
x.f(3); // expected-error{{no matching member function for call to 'f'}}
x.g(0);
OpenPOWER on IntegriCloud