re PR c++/12989 ([new parser] internal compiler error: tree check: expected field_decl)
authorMark Mitchell <mark@codesourcery.com>
Tue, 16 Dec 2003 01:15:14 +0000 (01:15 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 16 Dec 2003 01:15:14 +0000 (01:15 +0000)
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
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/sizeof1.C [new file with mode: 0644]

index 60bfd419ddfc2972f64ba7011962bab41fcc5caf..43389e8cbe2240ef9dda78c8b7c92ad1b8816531 100644 (file)
@@ -1,5 +1,8 @@
 2003-12-15  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/12989
+       * typeck.c (cxx_sizeof_or_alignof_expr): Robustify.
+
        PR c++/13310
        * pt.c (dependent_template_p): Handle OVERLOADs.
 
index f2cca5feabf1dcba6b17cead2d21d694b39a8bde..791ba210b1589c9eb84b57734994abfbd96874dd 100644 (file)
@@ -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);
index 941809d2c613d02a4df1fba2e489e9ad883d8781..83352dcfb70efab27513e79a99d447443964f86f 100644 (file)
@@ -1,5 +1,8 @@
 2003-12-15  Mark Mitchell  <mark@codesourcery.com>
 
+       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 (file)
index 0000000..fa84481
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/12989
+
+struct A
+{
+  int foo() { return sizeof(bar); } // { dg-error "" }
+  int bar();
+};