diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-02-16 12:13:41 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-02-16 12:13:41 +0000 |
commit | 8d6e459dd04ce48a04a330b97efe87acc5b8502d (patch) | |
tree | 808e61ad2855ba782e812a67a6537f62d7a73513 /gcc | |
parent | 45356ea28763e5ed5fea542d35da4657e00be1c0 (diff) | |
download | gcc-8d6e459dd04ce48a04a330b97efe87acc5b8502d.zip gcc-8d6e459dd04ce48a04a330b97efe87acc5b8502d.tar.gz gcc-8d6e459dd04ce48a04a330b97efe87acc5b8502d.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi/bitfield1.C | 34 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi/bitfield2.C | 34 |
5 files changed, 92 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ac273b1..b8f7628 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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> * decl.c (builtin_function): Set TREE_THIS_VOLATILE on return fns. @@ -65,7 +71,7 @@ PR c++/109 * decl.c (grokdeclarator): Allow friend declarations from - dependant types. + dependent types. * decl2.c (handle_class_head): Don't push into template parm contexts. * pt.c (push_template_decl_real): Template parm contexts are never being defined. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ecc6083..697120a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10073,7 +10073,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) } } } - /* C++ aggregate types. */ else if (TREE_CODE (id) == TYPE_DECL) { if (type) @@ -10083,6 +10082,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) { type = TREE_TYPE (id); TREE_VALUE (spec) = type; + typedef_decl = id; } goto found; } @@ -10097,10 +10097,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) else { type = TREE_TYPE (t); -#if 0 - /* See the code below that used this. */ - decl_attr = DECL_ATTRIBUTES (id); -#endif typedef_decl = t; } } @@ -10111,6 +10107,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) found: ; } +#if 0 + /* See the code below that used this. */ + if (typedef_decl) + decl_attr = DECL_ATTRIBUTES (typedef_decl); +#endif typedef_type = type; /* 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; } - 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 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 which came, as such, direct from a typedef name. - We must copy the type, so that each identifier gets - a distinct type, so that each identifier's size can be - controlled separately by its own initializer. */ + We must copy the type, so that the array's domain can be + individually set by the object's initializer. */ - if (type != 0 && typedef_type != 0 - && TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0 + if (type && typedef_type + && TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type)) - { - type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type)); - } + type = build_cplus_array_type (TREE_TYPE (type), NULL_TREE); /* 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 227fad4..6da2970 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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> * gcc.dg/attr-nest.c: New test. diff --git a/gcc/testsuite/g++.dg/abi/bitfield1.C b/gcc/testsuite/g++.dg/abi/bitfield1.C new file mode 100644 index 0000000..c707c85 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/bitfield1.C @@ -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; +} diff --git a/gcc/testsuite/g++.dg/abi/bitfield2.C b/gcc/testsuite/g++.dg/abi/bitfield2.C new file mode 100644 index 0000000..d4d1d58 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/bitfield2.C @@ -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; +} |