This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/41970
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 07 Apr 2010 11:15:02 -0400
- Subject: C++ PATCH for c++/41970
The bug report asked for the error message to be clearer about what the
problem is, so I've reworded it a bit.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit ee86bd7912d414dddda84c29d6842f7b39f9a6ab
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jan 20 18:34:15 2010 -0500
PR c++/41970
* decl.c (grokvardecl): Tweak warning message.
(grokfndecl): Likewise.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a308d64..4ae924b 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/g++.old-deja/g++.other/linkage1.C b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C
index e9b5a9d..556ef97 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" }
}