From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 690 invoked by alias); 24 Apr 2002 22:56:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 661 invoked by uid 71); 24 Apr 2002 22:56:01 -0000 Date: Wed, 24 Apr 2002 15:56:00 -0000 Message-ID: <20020424225601.657.qmail@sources.redhat.com> To: jason@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Jason Merrill Subject: Re: c++/6331: g++ 3.1 looses const qualifiers (C++ PATCH) Reply-To: Jason Merrill X-SW-Source: 2002-04/txt/msg01293.txt.bz2 List-Id: The following reply was made to PR c++/6331; it has been noted by GNATS. From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/6331: g++ 3.1 looses const qualifiers (C++ PATCH) Date: Wed, 24 Apr 2002 23:47:07 +0100 --=-=-= Here's the patch to always complain about array assignment, and a fix for further fallout. crash51.C got confused because we passed a STRING_CST with a VOIDmode type into the middle-end, as the type was never updated by the instantiation. This patch generates the right ARRAY_TYPE in the template for simple cases, so we don't have to fix strings up later. Tested i686-pc-linux-gnu, applied trunk and 3.1. 2002-04-24 Jason Merrill * typeck.c (build_modify_expr): The pedwarn for array assignment is now unconditional. * tree.c (build_cplus_array_type_1): Still process simple array types normally in templates. --=-=-= Content-Type: text/x-patch Content-Disposition: inline Index: cp/tree.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v retrieving revision 1.268.2.2 diff -c -p -r1.268.2.2 tree.c *** cp/tree.c 21 Mar 2002 23:12:40 -0000 1.268.2.2 --- cp/tree.c 24 Apr 2002 22:31:53 -0000 *************** build_cplus_array_type_1 (elt_type, inde *** 464,470 **** if (elt_type == error_mark_node || index_type == error_mark_node) return error_mark_node; ! if (processing_template_decl || uses_template_parms (elt_type) || uses_template_parms (index_type)) { --- 464,475 ---- if (elt_type == error_mark_node || index_type == error_mark_node) return error_mark_node; ! /* Don't do the minimal thing just because processing_template_decl is ! set; we want to give string constants the right type immediately, so ! we don't have to fix them up at instantiation time. */ ! if ((processing_template_decl ! && index_type && TYPE_MAX_VALUE (index_type) ! && TREE_CODE (TYPE_MAX_VALUE (index_type)) != INTEGER_CST) || uses_template_parms (elt_type) || uses_template_parms (index_type)) { Index: cp/typeck.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v retrieving revision 1.388.2.8 diff -c -p -r1.388.2.8 typeck.c *** cp/typeck.c 24 Apr 2002 10:49:54 -0000 1.388.2.8 --- cp/typeck.c 24 Apr 2002 22:31:57 -0000 *************** build_modify_expr (lhs, modifycode, rhs) *** 5665,5671 **** } /* Allow array assignment in compiler-generated code. */ ! if (pedantic && ! DECL_ARTIFICIAL (current_function_decl)) pedwarn ("ISO C++ forbids assignment of arrays"); from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE --- 5665,5671 ---- } /* Allow array assignment in compiler-generated code. */ ! if (! DECL_ARTIFICIAL (current_function_decl)) pedwarn ("ISO C++ forbids assignment of arrays"); from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE Index: testsuite/g++.old-deja/g++.benjamin/14664-1.C =================================================================== RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/14664-1.C,v retrieving revision 1.2 diff -c -p -r1.2 14664-1.C *** testsuite/g++.old-deja/g++.benjamin/14664-1.C 16 Dec 1998 21:21:42 -0000 1.2 --- testsuite/g++.old-deja/g++.benjamin/14664-1.C 24 Apr 2002 22:31:58 -0000 *************** *** 1,7 **** // 981203 bkoz // g++/14664 - test // Build don't link: - // Special g++ Options: -fconst-strings char foo[26]; --- 1,6 ---- Index: testsuite/g++.old-deja/g++.benjamin/14664-2.C =================================================================== RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C,v retrieving revision 1.2 diff -c -p -r1.2 14664-2.C *** testsuite/g++.old-deja/g++.benjamin/14664-2.C 16 Dec 1998 21:21:43 -0000 1.2 --- testsuite/g++.old-deja/g++.benjamin/14664-2.C 24 Apr 2002 22:31:58 -0000 *************** *** 1,7 **** // 981203 bkoz // g++/14664 + test // Build don't link: ! // Special g++ Options: -fno-const-strings char foo[26]; --- 1,7 ---- // 981203 bkoz // g++/14664 + test // Build don't link: ! // Special g++ Options: -fpermissive -w char foo[26]; Index: testsuite/g++.old-deja/g++.pt/crash51.C =================================================================== RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.pt/crash51.C,v retrieving revision 1.2 diff -c -p -r1.2 crash51.C *** testsuite/g++.old-deja/g++.pt/crash51.C 4 Sep 1999 15:09:07 -0000 1.2 --- testsuite/g++.old-deja/g++.pt/crash51.C 24 Apr 2002 22:31:59 -0000 *************** *** 1,5 **** // Build don't link: ! // Special g++ Options: -fno-const-strings // Origin: Mark Mitchell char foo[26]; --- 1,5 ---- // Build don't link: ! // Special g++ Options: -fpermissive -w // Origin: Mark Mitchell char foo[26]; --=-=-=--