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
This commit is contained in:
parent
2ea9dc6459
commit
2401726e18
4 changed files with 25 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" }
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue