mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-10 18:59:52 +08:00
decl.c (grokdeclarator): Set typedef_decl for all TYPE_DECLs, remove incorrect comment.
cp: * decl.c (grokdeclarator): Set typedef_decl for all TYPE_DECLs, remove incorrect comment. Move #if 0'd code to common path. Use IMPLICIT_TYPENAME_P. Simplify & reformat ARRAY_TYPE duplication. testsuite: * g++.dg/abi/bitfield1.C: New test. * g++.dg/abi/bitfield2.C: New test. From-SVN: r49803
This commit is contained in:
parent
45356ea287
commit
8d6e459dd0
@ -1,3 +1,9 @@
|
|||||||
|
2002-02-15 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* decl.c (grokdeclarator): Set typedef_decl for all TYPE_DECLs,
|
||||||
|
remove incorrect comment. Move #if 0'd code to common path. Use
|
||||||
|
IMPLICIT_TYPENAME_P. Simplify & reformat ARRAY_TYPE duplication.
|
||||||
|
|
||||||
2002-02-13 Jason Merrill <jason@redhat.com>
|
2002-02-13 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
* decl.c (builtin_function): Set TREE_THIS_VOLATILE on return fns.
|
* decl.c (builtin_function): Set TREE_THIS_VOLATILE on return fns.
|
||||||
@ -65,7 +71,7 @@
|
|||||||
|
|
||||||
PR c++/109
|
PR c++/109
|
||||||
* decl.c (grokdeclarator): Allow friend declarations from
|
* decl.c (grokdeclarator): Allow friend declarations from
|
||||||
dependant types.
|
dependent types.
|
||||||
* decl2.c (handle_class_head): Don't push into template parm contexts.
|
* decl2.c (handle_class_head): Don't push into template parm contexts.
|
||||||
* pt.c (push_template_decl_real): Template parm contexts are never
|
* pt.c (push_template_decl_real): Template parm contexts are never
|
||||||
being defined.
|
being defined.
|
||||||
|
@ -10073,7 +10073,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* C++ aggregate types. */
|
|
||||||
else if (TREE_CODE (id) == TYPE_DECL)
|
else if (TREE_CODE (id) == TYPE_DECL)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
@ -10083,6 +10082,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
{
|
{
|
||||||
type = TREE_TYPE (id);
|
type = TREE_TYPE (id);
|
||||||
TREE_VALUE (spec) = type;
|
TREE_VALUE (spec) = type;
|
||||||
|
typedef_decl = id;
|
||||||
}
|
}
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@ -10097,10 +10097,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
type = TREE_TYPE (t);
|
type = TREE_TYPE (t);
|
||||||
#if 0
|
|
||||||
/* See the code below that used this. */
|
|
||||||
decl_attr = DECL_ATTRIBUTES (id);
|
|
||||||
#endif
|
|
||||||
typedef_decl = t;
|
typedef_decl = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10111,6 +10107,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
found: ;
|
found: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* See the code below that used this. */
|
||||||
|
if (typedef_decl)
|
||||||
|
decl_attr = DECL_ATTRIBUTES (typedef_decl);
|
||||||
|
#endif
|
||||||
typedef_type = type;
|
typedef_type = type;
|
||||||
|
|
||||||
/* No type at all: default to `int', and set DEFAULTED_INT
|
/* No type at all: default to `int', and set DEFAULTED_INT
|
||||||
@ -10157,7 +10158,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
type = integer_type_node;
|
type = integer_type_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type && TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type))
|
if (type && IMPLICIT_TYPENAME_P (type))
|
||||||
{
|
{
|
||||||
/* The implicit typename extension is deprecated and will be
|
/* The implicit typename extension is deprecated and will be
|
||||||
removed. Warn about its use now. */
|
removed. Warn about its use now. */
|
||||||
@ -11221,16 +11222,13 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
|
|||||||
|
|
||||||
/* Detect the case of an array type of unspecified size
|
/* Detect the case of an array type of unspecified size
|
||||||
which came, as such, direct from a typedef name.
|
which came, as such, direct from a typedef name.
|
||||||
We must copy the type, so that each identifier gets
|
We must copy the type, so that the array's domain can be
|
||||||
a distinct type, so that each identifier's size can be
|
individually set by the object's initializer. */
|
||||||
controlled separately by its own initializer. */
|
|
||||||
|
|
||||||
if (type != 0 && typedef_type != 0
|
if (type && typedef_type
|
||||||
&& TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0
|
&& TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type)
|
||||||
&& TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type))
|
&& TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type))
|
||||||
{
|
type = build_cplus_array_type (TREE_TYPE (type), NULL_TREE);
|
||||||
type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Detect where we're using a typedef of function type to declare a
|
/* Detect where we're using a typedef of function type to declare a
|
||||||
function. last_function_parms will not be set, so we must create
|
function. last_function_parms will not be set, so we must create
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2002-02-15 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* g++.dg/abi/bitfield1.C: New test.
|
||||||
|
* g++.dg/abi/bitfield2.C: New test.
|
||||||
|
|
||||||
2002-02-15 Richard Sandiford <rsandifo@redhat.com>
|
2002-02-15 Richard Sandiford <rsandifo@redhat.com>
|
||||||
|
|
||||||
* gcc.dg/attr-nest.c: New test.
|
* gcc.dg/attr-nest.c: New test.
|
||||||
|
34
gcc/testsuite/g++.dg/abi/bitfield1.C
Normal file
34
gcc/testsuite/g++.dg/abi/bitfield1.C
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// { dg-do run }
|
||||||
|
// { dg-options "-ansi -pedantic-errors -funsigned-bitfields" }
|
||||||
|
|
||||||
|
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
// Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
typedef int Int;
|
||||||
|
typedef signed int SInt;
|
||||||
|
typedef unsigned int UInt;
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
SInt bitS : 1; // signed
|
||||||
|
UInt bitU : 1; // unsigned
|
||||||
|
Int bit : 1; // signedness by -f{signed,unsigned}-bitfields
|
||||||
|
};
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
A a;
|
||||||
|
|
||||||
|
a.bitS = 1;
|
||||||
|
a.bitU = 1;
|
||||||
|
a.bit = 1;
|
||||||
|
|
||||||
|
if (a.bitS != -1)
|
||||||
|
return 1;
|
||||||
|
if (a.bitU != 1)
|
||||||
|
return 2;
|
||||||
|
if (a.bit != 1)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
34
gcc/testsuite/g++.dg/abi/bitfield2.C
Normal file
34
gcc/testsuite/g++.dg/abi/bitfield2.C
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// { dg-do run }
|
||||||
|
// { dg-options "-ansi -pedantic-errors -fsigned-bitfields" }
|
||||||
|
|
||||||
|
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||||
|
// Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
typedef int Int;
|
||||||
|
typedef signed int SInt;
|
||||||
|
typedef unsigned int UInt;
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
SInt bitS : 1; // signed
|
||||||
|
UInt bitU : 1; // unsigned
|
||||||
|
Int bit : 1; // signedness by -f{signed,unsigned}-bitfields
|
||||||
|
};
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
A a;
|
||||||
|
|
||||||
|
a.bitS = 1;
|
||||||
|
a.bitU = 1;
|
||||||
|
a.bit = 1;
|
||||||
|
|
||||||
|
if (a.bitS != -1)
|
||||||
|
return 1;
|
||||||
|
if (a.bitU != 1)
|
||||||
|
return 2;
|
||||||
|
if (a.bit != -1)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user