From 2401726e18691dec7144312cb531aa9e11ca8240 Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Wed, 7 Apr 2010 11:54:17 -0400
Subject: [PATCH] re PR c++/41970 (use of a type with no linkage to declare a
 variable with linkage)

	PR c++/41970
	* decl.c (grokvardecl): Tweak warning message.
	(grokfndecl): Likewise.

From-SVN: r158071
---
 gcc/cp/ChangeLog                                |  6 ++++++
 gcc/cp/decl.c                                   | 15 +++++++++------
 gcc/testsuite/ChangeLog                         |  5 +++++
 gcc/testsuite/g++.old-deja/g++.other/linkage1.C | 10 +++++-----
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3d412443a7be..a6e6f3a85e8d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-07  Jason Merrill  <jason@redhat.com>
+
+	PR c++/41970
+	* decl.c (grokvardecl): Tweak warning message.
+	(grokfndecl): Likewise.
+
 2010-04-07  Dodji Seketeli  <dodji@redhat.com>
 
 	PR c++/42697
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a308d64d9fff..4ae924b32ad4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6821,8 +6821,9 @@ grokfndecl (tree ctype,
 		/* Allow this; it's pretty common in C.  */;
 	      else
 		{
-		  permerror (input_location, "non-local function %q#D uses anonymous type",
-			      decl);
+		  permerror (input_location, "anonymous type with no linkage "
+			     "used to declare function %q#D with linkage",
+			     decl);
 		  if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
 		    permerror (input_location, "%q+#D does not refer to the unqualified "
 			       "type, so it is not used for linkage",
@@ -6830,7 +6831,8 @@ grokfndecl (tree ctype,
 		}
 	    }
 	  else
-	    permerror (input_location, "non-local function %q#D uses local type %qT", decl, t);
+	    permerror (input_location, "type %qT with no linkage used to "
+		       "declare function %q#D with linkage", t, decl);
 	}
     }
 
@@ -7104,8 +7106,8 @@ grokvardecl (tree type,
 		     no linkage can only be used to declare extern "C"
 		     entities.  Since it's not always an error in the
 		     ISO C++ 90 Standard, we only issue a warning.  */
-		  warning (0, "non-local variable %q#D uses anonymous type",
-			   decl);
+		  warning (0, "anonymous type with no linkage used to declare "
+			   "variable %q#D with linkage", decl);
 		  if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
 		    warning (0, "%q+#D does not refer to the unqualified "
 			     "type, so it is not used for linkage",
@@ -7113,7 +7115,8 @@ grokvardecl (tree type,
 		}
 	    }
 	  else
-	    warning (0, "non-local variable %q#D uses local type %qT", decl, t);
+	    warning (0, "type %qT with no linkage used to declare variable "
+		     "%q#D with linkage", t, decl);
 	}
     }
   else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0032dd813b0d..3138c8a3d1cf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-07  Jason Merrill  <jason@redhat.com>
+
+	PR c++/41970
+	* g++.old-deja/g++.other/linkage1.C: Adjust.
+
 2010-04-07  Dodji Seketeli  <dodji@redhat.com>
 
 	PR c++/42697
diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage1.C b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
index e9b5a9d2aa32..556ef9716a8d 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
@@ -3,13 +3,13 @@ typedef struct {
   int i;
 } *p;
 
-void f (p) { }			// { dg-error "uses anonymous type" }
-p q;				// { dg-warning "uses anonymous type" } 
+void f (p) { }			// { dg-error "with no linkage" }
+p q;				// { dg-warning "with no linkage" }
 
 int main()
 {
-  extern p j;			// { dg-warning "uses anonymous type" }
+  extern p j;			// { dg-warning "with no linkage" }
   struct A { int j; };
-  extern A a;			// { dg-warning "uses local type" }
-  extern void f (A);		// { dg-error "uses local type" }
+  extern A a;			// { dg-warning "with no linkage" }
+  extern void f (A);		// { dg-error "with no linkage" }
 }
-- 
GitLab