]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: dump alias-declaration scope
authorJason Merrill <jason@redhat.com>
Thu, 31 Mar 2022 22:15:24 +0000 (18:15 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 29 Apr 2022 13:21:15 +0000 (09:21 -0400)
An alias can't be declared with a qualified-id in actual code, but in
diagnostics we want to know which scope it belongs to, and I think a
nested-name-specifier is the best way to provide that.

gcc/cp/ChangeLog:

* error.cc (dump_decl): Check TFF_UNQUALIFIED_NAME.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-1.C: Expect qualified name.

gcc/cp/error.cc
gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C

index 1e944ca3f750a16412d04d216a86a454a473e49e..2b07136b5ca79feb68c6bda95472f270dec86055 100644 (file)
@@ -1246,6 +1246,8 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
              || flags & TFF_CLASS_KEY_OR_ENUM))
        {
          pp_cxx_ws_string (pp, "using");
+         if (! (flags & TFF_UNQUALIFIED_NAME))
+           dump_scope (pp, CP_DECL_CONTEXT (t), flags);
          dump_decl (pp, DECL_NAME (t), flags);
          pp_cxx_whitespace (pp);
          pp_cxx_ws_string (pp, "=");
index 24b052092237b30abe4b9bd5edfa6b19d71663a5..6dcb780e8955df3ca744f7491257750c81ddaae2 100644 (file)
@@ -12,5 +12,5 @@ template<class U> struct Ptr<U*> {}; // { dg-error "specialization" }
 
 struct A {
     using A = int;  // { dg-error "11:ISO C\\+\\+ forbids nested type .A." }
-// { dg-error "11:.using A = int. has the same name as" "" { target c++11 } .-1 }  
+// { dg-error "11:.using A::A = int. has the same name as" "" { target c++11 } .-1 }  
 };