commit d9ebf555e29b24e5fa3338471edbc9d922ae0edb Author: Jason Merrill Date: Sat Apr 11 10:41:22 2015 -0400 PR c++/65721 * name-lookup.c (do_class_using_decl): Complain about specifying the current class even if there are dependent bases. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e3f7cca..9e4e0e3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3408,7 +3408,7 @@ do_class_using_decl (tree scope, tree name) tf_warning_or_error); if (b_kind < bk_proper_base) { - if (!bases_dependent_p) + if (!bases_dependent_p || b_kind == bk_same_type) { error_not_base_type (scope, current_class_type); return NULL_TREE; diff --git a/gcc/testsuite/g++.dg/lookup/using55.C b/gcc/testsuite/g++.dg/lookup/using55.C new file mode 100644 index 0000000..61098b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using55.C @@ -0,0 +1,19 @@ +// PR c++/65721 + +template +struct A { + typedef T D; +}; + +template +class B : public A { + using typename B::D; // { dg-error "not a base" } +public: + D echo(D x) { // { dg-error "D" } + return x; + } +}; + +int main() { + B b; +}