aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-12-30 13:07:57 -0500
committerJason Merrill <jason@redhat.com>2021-04-29 14:43:38 -0400
commitf03973251db33ad8d08c03ac570cd378e46d3a20 (patch)
tree5a8d34b72d57b10e04d37e4d63c192d32f20659c
parentbc99c54de5a262ffc5f7801e16d919d335a53a8b (diff)
downloadgcc-f03973251db33ad8d08c03ac570cd378e46d3a20.zip
gcc-f03973251db33ad8d08c03ac570cd378e46d3a20.tar.gz
gcc-f03973251db33ad8d08c03ac570cd378e46d3a20.tar.bz2
c++: Add using-declaration testcase
gcc/testsuite/ChangeLog: * g++.dg/lookup/using-decl1.C: New test.
-rw-r--r--gcc/testsuite/g++.dg/lookup/using-decl1.C38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/lookup/using-decl1.C b/gcc/testsuite/g++.dg/lookup/using-decl1.C
new file mode 100644
index 0000000..7ccb4fc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using-decl1.C
@@ -0,0 +1,38 @@
+// Testcase from [namespace.udecl] updated by P1787
+
+namespace A {
+ int x;
+ int f(int);
+ int g;
+ void h();
+}
+
+namespace B {
+ int i;
+ struct g { };
+ struct x { };
+ void f(int);
+ void f(double);
+ void g(char); // OK: hides struct g
+}
+
+void func() {
+ int i;
+ using B::i; // { dg-error "" } i conflicts
+ void f(char);
+ using B::f; // OK: each f is a function
+ using A::f; // OK, but interferes with B::f(int)
+ f(1); // { dg-error "" } ambiguous
+ static_cast<int(*)(int)>(f)(1); // OK: calls A::f
+ f(3.5); // calls B::f(double)
+ using B::g;
+ g('a'); // calls B::g(char)
+ struct g g1; // g1 has class type B::g
+ using A::g; // { dg-error "" } conflicts with B::g
+ void h();
+ using A::h; // { dg-error "" } conflicts
+ using B::x;
+ using A::x; // OK: hides struct B::x
+ x = 99; // assigns to A::x
+ struct x x1; // x1 has class type B::x
+}