Commit 9fc444cc by Geoffrey Keating Committed by Geoffrey Keating

Index: cp/ChangeLog

2004-03-04  Geoffrey Keating  <geoffk@apple.com>

	* decl.c (grokfndecl): Update old incorrect comment.
	(grokvardecl): Diagnose C++ variables of type with no linkage.

Index: testsuite/ChangeLog
2004-03-04  Geoffrey Keating  <geoffk@apple.com>

	* g++.old-deja/g++.other/linkage1.C: Expect errors about
	global variables of a type with no linkage.
	* g++.old-deja/g++.other/qual1.C: Name class for 'action'.
	* g++.old-deja/g++.mike/misc13.C: Name enum for 'want'.
	* g++.old-deja/g++.bugs/900210_01.C: Name enum for 'ep'.
	* g++.old-deja/g++.bugs/900210_02.C: Likewise.
	* g++.old-deja/g++.bugs/900210_03.C: Likewise.
	* g++.old-deja/g++.brendan/bit-fields2.C: Name structure for 's'.
	* g++.old-deja/g++.brendan/init10.C: Name structure for 'a'.
	* g++.dg/warn/deprecated.C: Name enum Color.
	* g++.dg/overload/VLA.C: Name structure for 'b'.
	* g++.dg/lookup/anon2.C: Expect diagnostic about type linkage.

From-SVN: r78939
parent 8653fed7
2004-03-04 Geoffrey Keating <geoffk@apple.com>
* decl.c (grokfndecl): Update old incorrect comment.
(grokvardecl): Diagnose C++ variables of type with no linkage.
2004-03-01 Mark Mitchell <mark@codesourcery.com>
PR c++/14369
......
......@@ -5544,8 +5544,7 @@ grokfndecl (tree ctype,
}
/* Members of anonymous types and local classes have no linkage; make
them internal. */
/* FIXME what if it gets a name from typedef? */
them internal. If a typedef is made later, this will be changed. */
if (ctype && (TYPE_ANONYMOUS_P (ctype)
|| decl_function_context (TYPE_MAIN_DECL (ctype))))
publicp = 0;
......@@ -5880,7 +5879,19 @@ grokvardecl (tree type,
if (t)
{
if (TYPE_ANONYMOUS_P (t))
/* Ignore for now; `enum { foo } e' is pretty common. */;
{
if (DECL_EXTERN_C_P (decl))
/* Allow this; it's pretty common in C. */;
else
{
pedwarn ("non-local variable `%#D' uses anonymous type",
decl);
if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
cp_pedwarn_at ("\
`%#D' does not refer to the unqualified type, so it is not used for linkage",
TYPE_NAME (t));
}
}
else
pedwarn ("non-local variable `%#D' uses local type `%T'",
decl, t);
......
2004-03-04 Geoffrey Keating <geoffk@apple.com>
* g++.old-deja/g++.other/linkage1.C: Expect errors about
global variables of a type with no linkage.
* g++.old-deja/g++.other/qual1.C: Name class for 'action'.
* g++.old-deja/g++.mike/misc13.C: Name enum for 'want'.
* g++.old-deja/g++.bugs/900210_01.C: Name enum for 'ep'.
* g++.old-deja/g++.bugs/900210_02.C: Likewise.
* g++.old-deja/g++.bugs/900210_03.C: Likewise.
* g++.old-deja/g++.brendan/bit-fields2.C: Name structure for 's'.
* g++.old-deja/g++.brendan/init10.C: Name structure for 'a'.
* g++.dg/warn/deprecated.C: Name enum Color.
* g++.dg/overload/VLA.C: Name structure for 'b'.
* g++.dg/lookup/anon2.C: Expect diagnostic about type linkage.
2004-03-04 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20040304-1.c: New test.
......
// { dg-do compile }
// { dg-options "" }
class { int i; } a; // { dg-error "private" }
class { int i; } a; // { dg-error "private|anonymous type" }
void foo() { a.i; } // { dg-error "context" }
......@@ -6,7 +6,7 @@
// { dg-do compile }
struct {
struct S {
int (*p)[];
} B;
......
......@@ -20,7 +20,7 @@ INT2 f4(void) { return 0; } /* { dg-warning "`INT2' is deprecated" "" } */
int f5(INT2 x); /* { dg-warning "`INT2' is deprecated" "" } */
int f6(INT2 x) __attribute__ ((__deprecated__));
typedef enum {red, green, blue} Color __attribute__((deprecated));
typedef enum Color {red, green, blue} Color __attribute__((deprecated));
int g1;
int g2 __attribute__ ((deprecated));
......
// { dg-do assemble }
// GROUPS passed bit-fields
struct {
struct S {
char c;
int i:8;
} s;
......
// { dg-do assemble }
// GROUPS passed initialization
struct { int :0; } a;
struct S { int :0; } a;
......@@ -15,7 +15,7 @@ char c;
float f;
double d;
long double ld;
enum {enum_value_0} e;
enum E {enum_value_0} e;
signed int si;
signed long sl;
......@@ -30,8 +30,8 @@ unsigned char uc;
void* vp;
char* cp;
int* ip;
enum {enum_value_1} * ep;
struct { int member; } * sp;
enum E2 {enum_value_1} * ep;
struct S { int member; } * sp;
void (*fp) (void);
void global_function ()
......
......@@ -16,7 +16,7 @@ char c;
float f;
double d;
long double ld;
enum {enum_value_0} e;
enum E {enum_value_0} e;
signed int si;
signed long sl;
......@@ -31,8 +31,8 @@ unsigned char uc;
void* vp;
char* cp;
int* ip;
enum {enum_value_1} * ep;
struct { int member; } * sp;
enum E2 {enum_value_1} * ep;
struct S { int member; } * sp;
void (*fp) (void);
void global_function ()
......
......@@ -11,8 +11,8 @@
void* vp;
char* cp;
int* ip;
enum {enum_value_1} * ep;
struct { int member; } * sp;
enum E {enum_value_1} * ep;
struct S { int member; } * sp;
void (*fp) (void);
void global_function ()
......
// { dg-do run }
// GROUPS passed vtable
extern "C" int printf (const char *, ...);
enum { vf_request, vf_event } want;
enum E { vf_request, vf_event } want;
int errs = 0;
......
......@@ -3,13 +3,13 @@ typedef struct {
int i;
} *p;
void f (p) { } // { dg-error "" } function uses anonymous type
p q;
void f (p) { } // { dg-error "uses anonymous type" }
p q; // { dg-error "uses anonymous type" }
int main()
{
extern p j;
extern p j; // { dg-error "uses anonymous type" }
struct A { int j; };
extern A a; // { dg-error "" } extern uses local type
extern void f (A); // { dg-error "" } extern uses local type
extern A a; // { dg-error "uses local type" }
extern void f (A); // { dg-error "uses local type" }
}
......@@ -6,7 +6,7 @@
typedef const char *(func_type)();
class
class C
{
public:
func_type *Function;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment