diff mbox series

[C++,obvious] PR 86661

Message ID 85998f72-ff47-9d8e-6f46-e6e096d3ef49@oracle.com
State New
Headers show
Series [C++,obvious] PR 86661 | expand

Commit Message

Paolo Carlini Aug. 1, 2018, 12:07 p.m. UTC
Hi,

when I lately changed a couple of permerrors to permerror + warning and 
accurate location for the first call, I went for the simple choice of 
using DECL_SOURCE_LOCATION for the first call and keeping location_of in 
the second call. Turns out we consistently want location_of for both, 
because we may have to handle OVERLOADs. Tested x86_64-linux, committed 
to mainline.

Thanks, Paolo.

/////////////////////////
/cp
2018-08-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/86661
	* class.c (note_name_declared_in_class): Use location_of in permerror
	instead of DECL_SOURCE_LOCATION (for OVERLOADs).

/testsuite
2018-08-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/86661
	* g++.dg/lookup/name-clash12.C: New.
diff mbox series

Patch

Index: cp/class.c
===================================================================
--- cp/class.c	(revision 263197)
+++ cp/class.c	(working copy)
@@ -8285,7 +8285,7 @@  note_name_declared_in_class (tree name, tree decl)
 	 A name N used in a class S shall refer to the same declaration
 	 in its context and when re-evaluated in the completed scope of
 	 S.  */
-      if (permerror (DECL_SOURCE_LOCATION (decl),
+      if (permerror (location_of (decl),
 		     "declaration of %q#D changes meaning of %qD",
 		     decl, OVL_NAME (decl)))
 	inform (location_of ((tree) n->value),
Index: testsuite/g++.dg/lookup/name-clash12.C
===================================================================
--- testsuite/g++.dg/lookup/name-clash12.C	(nonexistent)
+++ testsuite/g++.dg/lookup/name-clash12.C	(working copy)
@@ -0,0 +1,9 @@ 
+// PR c++/86661
+
+typedef int a;  // { dg-message "declared here" }
+namespace {
+class b {
+  a c;
+  template <typename> void a();  // { dg-error "changes meaning" }
+};
+}