public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix PR4446
@ 2001-11-13 15:03 Kriang Lerdsuwanakij
  2001-11-13 15:03 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Kriang Lerdsuwanakij @ 2001-11-13 15:03 UTC (permalink / raw)
  To: gcc-patches

Hi

Inside function create_array_type_for_decl, the variable 'name' 
may be NULL_TREE.  A testcase for such case is provided in the 
patch.  Therefore, when displaying error messages, the case when 
it is NULL_TREE must be handled.  The appended patch fixes this
problem.

Tested on i686-pc-linux-gnu with no regressions.  OK to commit
to the mainline ?

--Kriang


2001-11-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

        * decl.c (create_array_type_for_decl): Check if NAME is NULL_TREE
        when displaying error message about missing array bounds.

diff -cprN gcc-main-save/gcc/cp/decl.c gcc-main-new/gcc/cp/decl.c
*** gcc-main-save/gcc/cp/decl.c Tue Oct 23 16:14:14 2001
--- gcc-main-new/gcc/cp/decl.c  Sat Nov 17 20:23:02 2001
*************** create_array_type_for_decl (name, type, 
*** 9452,9459 ****
       can be omitted only for the first member of the sequence.  */
    if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type))
      {
!       cp_error ("declaration of `%D' as multidimensional array must have bounds for all dimensions except the first",
!               name);
  
        return error_mark_node;
      }
--- 9452,9462 ----
       can be omitted only for the first member of the sequence.  */
    if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type))
      {
!       if (name)
!       cp_error ("declaration of `%D' as multidimensional array must have bounds for all dimensions except the first",
!                 name);
!       else
!       cp_error ("multidimensional array must have bounds for all dimensions except the first");
  
        return error_mark_node;
      }
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/other/array1.C gcc-main-new/gcc/testsuite/g++.dg/other/array1.C
*** gcc-main-save/gcc/testsuite/g++.dg/other/array1.C   Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/other/array1.C    Sat Nov 17 20:32:58 2001
***************
*** 0 ****
--- 1,10 ----
+ // Test typeid of multidimensional array with no bounds.
+ // { dg-do compile }
+ 
+ #include <typeinfo>
+ 
+ int main()
+ {
+       const char *s = typeid(double[][]).name(); // { dg-error "bounds|confused" }
+       return 0;
+ }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Fix PR4446
  2001-11-13 15:03 [C++ PATCH] Fix PR4446 Kriang Lerdsuwanakij
@ 2001-11-13 15:03 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2001-11-13 15:03 UTC (permalink / raw)
  To: lerdsuwa; +Cc: gcc-patches

OK.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-11-17 22:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-13 15:03 [C++ PATCH] Fix PR4446 Kriang Lerdsuwanakij
2001-11-13 15:03 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).