From ea0e2a51f400471a67bf3979fb9e30390eb7a34b Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Tue, 16 Dec 2003 01:15:14 +0000 Subject: [PATCH] re PR c++/12989 ([new parser] internal compiler error: tree check: expected field_decl) PR c++/12989 * typeck.c (cxx_sizeof_or_alignof_expr): Robustify. PR c++/12989 * g++.dg/expr/sizeof1.C: New test. From-SVN: r74660 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 1 + gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/expr/sizeof1.C | 7 +++++++ 4 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/expr/sizeof1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 60bfd419ddf..43389e8cbe2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2003-12-15 Mark Mitchell + PR c++/12989 + * typeck.c (cxx_sizeof_or_alignof_expr): Robustify. + PR c++/13310 * pt.c (dependent_template_p): Handle OVERLOADs. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index f2cca5feabf..791ba210b15 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1233,6 +1233,7 @@ cxx_sizeof_or_alignof_expr (tree e, enum tree_code op) } if (TREE_CODE (e) == COMPONENT_REF + && TREE_CODE (TREE_OPERAND (e, 1)) == FIELD_DECL && DECL_C_BIT_FIELD (TREE_OPERAND (e, 1))) { error ("invalid application of `%s' to a bit-field", op_name); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 941809d2c61..83352dcfb70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2003-12-15 Mark Mitchell + PR c++/12989 + * g++.dg/expr/sizeof1.C: New test. + PR c++/13310 * g++.dg/template/crash15.C: New test. diff --git a/gcc/testsuite/g++.dg/expr/sizeof1.C b/gcc/testsuite/g++.dg/expr/sizeof1.C new file mode 100644 index 00000000000..fa84481fabf --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/sizeof1.C @@ -0,0 +1,7 @@ +// PR c++/12989 + +struct A +{ + int foo() { return sizeof(bar); } // { dg-error "" } + int bar(); +};