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 9749


This patch fixes PR 9749, an ICE on invalid code regression.

Fixed by correctly issuing error messages about attempts to declare
parameters with variably modified types.

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

--
Mark Mitchell                   mark at codesourcery dot com
CodeSourcery, LLC               http://www.codesourcery.com

2003-02-21  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9749
	* decl.c (grokdeclarator): Do not allow parameters with variably
	modified types.

2003-02-21  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9749
	* g++.dg/parse/varmod1.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.14
diff -c -5 -p -r1.965.2.14 decl.c
*** cp/decl.c	21 Feb 2003 20:22:05 -0000	1.965.2.14
--- cp/decl.c	21 Feb 2003 22:51:52 -0000
*************** grokdeclarator (declarator, declspecs, d
*** 11537,11551 ****
        /* If we proceed with the array type as it is, we'll eventually
  	 crash in tree_low_cst().  */
        type = error_mark_node;
      }
  
!   if (decl_context == FIELD 
        && !processing_template_decl 
        && variably_modified_type_p (type))
      {
!       error ("data member may not have variably modified type `%T'", type);
        type = error_mark_node;
      }
  
    if (explicitp == 1 || (explicitp && friendp))
      {
--- 11537,11554 ----
        /* If we proceed with the array type as it is, we'll eventually
  	 crash in tree_low_cst().  */
        type = error_mark_node;
      }
  
!   if ((decl_context == FIELD || decl_context == PARM)
        && !processing_template_decl 
        && variably_modified_type_p (type))
      {
!       if (decl_context == FIELD)
! 	error ("data member may not have variably modified type `%T'", type);
!       else
! 	error ("parameter may not have variably modified type `%T'", type);
        type = error_mark_node;
      }
  
    if (explicitp == 1 || (explicitp && friendp))
      {
Index: testsuite/g++.dg/parse/varmod1.C
===================================================================
RCS file: testsuite/g++.dg/parse/varmod1.C
diff -N testsuite/g++.dg/parse/varmod1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/varmod1.C	21 Feb 2003 22:51:53 -0000
***************
*** 0 ****
--- 1,7 ----
+ int main(int argc, char** argv) {
+   int nx = 2;
+   void theerror(double a[][nx+1]); // { dg-error "" }
+   double** a;
+   theerror(a); // { dg-error "" }
+   return 0;
+ }


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