* C++ PATCH for c++/65721 (ICE with invalid using-declaration)
@ 2015-04-14 15:28 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-04-14 15:28 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
The standard says that the nested-name-specifier in a using-declaration
needs to name a base of the class. When we have dependent bases we
can't be sure whether a particular type is a base or not, but we can
certainly complain if name lookup find the current class rather than a base.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 65721.patch --]
[-- Type: text/x-patch, Size: 1215 bytes --]
commit d9ebf555e29b24e5fa3338471edbc9d922ae0edb
Author: Jason Merrill <jason@redhat.com>
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<typename T>
+struct A {
+ typedef T D;
+};
+
+template<typename X>
+class B : public A<X> {
+ using typename B::D; // { dg-error "not a base" }
+public:
+ D echo(D x) { // { dg-error "D" }
+ return x;
+ }
+};
+
+int main() {
+ B<int> b;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-04-14 15:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14 15:28 C++ PATCH for c++/65721 (ICE with invalid using-declaration) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).