This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 12989


This patch fixes a problem in code that was borrowed from the C front
end long ago and never updated for C++ -- where the second argument to
a COMPONENT_REF need not be a FIELD_DECL.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


2003-12-15  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12989
	* typeck.c (cxx_sizeof_or_alignof_expr): Robustify.

2003-12-15  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12989
	* g++.dg/expr/sizeof1.C: New test.

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.512
diff -c -5 -p -r1.512 typeck.c
*** cp/typeck.c	23 Nov 2003 11:32:12 -0000	1.512
--- cp/typeck.c	16 Dec 2003 01:00:23 -0000
*************** cxx_sizeof_or_alignof_expr (tree e, enum
*** 1231,1240 ****
--- 1231,1241 ----
        
        return e;
      }
    
    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);
        e = char_type_node;
      }
Index: testsuite/g++.dg/expr/sizeof1.C
===================================================================
RCS file: testsuite/g++.dg/expr/sizeof1.C
diff -N testsuite/g++.dg/expr/sizeof1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/expr/sizeof1.C	16 Dec 2003 01:00:23 -0000
***************
*** 0 ****
--- 1,5 ----
+ struct A
+ {
+   int foo() { return sizeof(bar); } // { dg-error "" }
+   int bar();
+ };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]