public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4852] c++: Improve error location for class using-decl.
@ 2020-11-09 20:18 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2020-11-09 20:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:05b03452db6a520091aed254d3c399caed714b15

commit r11-4852-g05b03452db6a520091aed254d3c399caed714b15
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Nov 6 20:41:54 2020 -0500

    c++: Improve error location for class using-decl.
    
    We should use the location of the using-declaration, not the location of the
    class.
    
    gcc/cp/ChangeLog:
    
            * class.c (handle_using_decl): Add an iloc_sentinel.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/lookup/using26.C: Adjust location.
            * g++.old-deja/g++.other/using1.C: Adjust location.

Diff:
---
 gcc/cp/class.c                                | 4 +++-
 gcc/testsuite/g++.dg/lookup/using26.C         | 4 ++--
 gcc/testsuite/g++.old-deja/g++.other/using1.C | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index c03737294eb..7c34d9466fc 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1,4 +1,4 @@
-/* Functions related to building classes and their related objects.
+/* Functions related to building -*- C++ -*- classes and their related objects.
    Copyright (C) 1987-2020 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
@@ -1322,6 +1322,8 @@ handle_using_decl (tree using_decl, tree t)
       return;
     }
 
+  iloc_sentinel ils (DECL_SOURCE_LOCATION (using_decl));
+
   /* Make type T see field decl FDECL with access ACCESS.  */
   if (flist)
     for (ovl_iterator iter (flist); iter; ++iter)
diff --git a/gcc/testsuite/g++.dg/lookup/using26.C b/gcc/testsuite/g++.dg/lookup/using26.C
index 857c1348181..dd4e13039d7 100644
--- a/gcc/testsuite/g++.dg/lookup/using26.C
+++ b/gcc/testsuite/g++.dg/lookup/using26.C
@@ -17,9 +17,9 @@ struct C
     int next;
 };
 
-struct D : A, B, C // { dg-error "context" }
+struct D : A, B, C
 {
-    using B::next;
+    using B::next; // { dg-error "context" }
     void f()
     {
 	next = 12;
diff --git a/gcc/testsuite/g++.old-deja/g++.other/using1.C b/gcc/testsuite/g++.old-deja/g++.other/using1.C
index 6cebc292a41..89100918a1e 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/using1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/using1.C
@@ -10,9 +10,9 @@ protected:
   friend class D2;
 };
 
-class D : public B { // { dg-error "" } within this context
+class D : public B {
 public:
-  using B::a;
+  using B::a; // { dg-error "" } within this context
   using B::b;
 };


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-09 20:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 20:18 [gcc r11-4852] c++: Improve error location for class using-decl 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).