diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-29 11:16:50 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-29 11:16:50 +0000 |
commit | b7edeb2322c878081a6542263dd698cfbd7b4136 (patch) | |
tree | f933bf28ffc6e8514814d1f5e3aab7549afff83b /gcc/testsuite/g++.dg | |
parent | f12876dd1718b4284363d55510a7b5d95605ab5a (diff) | |
download | gcc-b7edeb2322c878081a6542263dd698cfbd7b4136.tar.gz |
cp:
PR c++/9447
* decl.c (add_binding): Add bval local variable.
(push_class_level_binding): Likewise. Allow a USING_DECL to be
pushed.
* decl2.c (do_class_using_decl): The type of a using decl is
unknown.
* parser.c (cp_parser_postfix_expression): Refactor unqualified-id
function call lookup code.
* pt.c (tsubst): A USING_DECL will have unknown type.
(tsubst_copy_and_build): Allow a using decl.
(type_dependent_expression_p): A USING_DECL will make it
dependent.
* semantics.c (finish_member_declaration): Push a dependent using
declaration.
testsuite:
PR c++/9447
* g++.dg/template/using1.C: New test.
* g++.dg/template/using2.C: New test.
* g++.dg/template/using3.C: New test.
* g++.dg/template/using4.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69921 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/template/using1.C | 42 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/using2.C | 30 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/using3.C | 42 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/using4.C | 39 |
4 files changed, 153 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/using1.C b/gcc/testsuite/g++.dg/template/using1.C new file mode 100644 index 00000000000..e4d4a004e32 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using1.C @@ -0,0 +1,42 @@ +// { dg-do run } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com> + +// PR 9447. Using decls in template classes. + +template <class T> +struct Foo { + int i; +}; + +struct Baz +{ + int j; +}; + +template <class T> +struct Bar : public Foo<T>, Baz { + using Foo<T>::i; + using Baz::j; + + int foo () { return i; } + int baz () { return j; } +}; + +int main() +{ + Bar<int> bar; + + bar.i = 1; + bar.j = 2; + + if (bar.foo() != 1) + return 1; + + if (bar.baz() != 2) + return 1; + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/template/using2.C b/gcc/testsuite/g++.dg/template/using2.C new file mode 100644 index 00000000000..87cdbc18657 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using2.C @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com> + +// PR 9447. Using decls in template classes. + +template <class T> +struct Foo { + int i; // { dg-error "" "" } +}; + +struct Baz +{ + int i; // { dg-error "" "" } +}; + +template <class T> +struct Bar : public Foo<T>, Baz { + using Foo<T>::i; + using Baz::i; + + int foo () { return i; } // { dg-error "request for member" "" } +}; + +void foo (Bar<int> &bar) +{ + bar.foo(); // { dg-error "instantiated" "" } +} + diff --git a/gcc/testsuite/g++.dg/template/using3.C b/gcc/testsuite/g++.dg/template/using3.C new file mode 100644 index 00000000000..11f2899c592 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using3.C @@ -0,0 +1,42 @@ +// { dg-do run } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com> + +// PR 9447. Using decls in template classes. + +template <class T> +struct Foo { + int i (int) {return 1;} +}; + +struct Baz +{ + int k (int) {return 2;} +}; + +template <class T> +struct Bar : public Foo<T> , Baz { + using Foo<T>::i; + using Baz::k; + + int i (float) {return 3;} + int k (float) {return 3;} + + int foo() + { + if (i (1) != 1) + return 1; + if (k (1) != 2) + return 2; + + return 0; + } +}; + +int main() +{ + Bar<int> bar; + + return bar.foo(); +} diff --git a/gcc/testsuite/g++.dg/template/using4.C b/gcc/testsuite/g++.dg/template/using4.C new file mode 100644 index 00000000000..8c46da464a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using4.C @@ -0,0 +1,39 @@ +// { dg-do run } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com> + +// PR 9447. Using decls in template classes. + +template <class T> +struct Foo { + int k (float) {return 1;} +}; + +struct Baz +{ + int k (int) {return 2;} +}; + +template <class T> +struct Bar : public Foo<T> , Baz { + using Foo<T>::k; + using Baz::k; + + int foo() + { + if (k (1.0f) != 1) + return 1; + if (k (1) != 2) + return 2; + + return 0; + } +}; + +int main() +{ + Bar<int> bar; + + return bar.foo(); +} |