* Patch ping @ 2008-05-07 8:38 Jakub Jelinek 2008-05-07 14:59 ` Jason Merrill 2008-05-10 19:23 ` Patch ping Diego Novillo 0 siblings, 2 replies; 7+ messages in thread From: Jakub Jelinek @ 2008-05-07 8:38 UTC (permalink / raw) To: gcc-patches; +Cc: Mark Mitchell, Jason Merrill, Richard Guenther Hi! - C++ compound literal diagnostics PR c++/36023 P2 4.3/4.4 http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02045.html - fix dwarf2out.c for Fortran COMMONs PR debug/35896 P1 4.4 http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02114.html - change simplify_plus_minus canonicalization PR target/36090 P1 4.3/4.4 http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00202.html testcase in http://gcc.gnu.org/bugzilla/attachment.cgi?id=15576&action=view - nowait for tree-parloops.c - - 4.4 http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00288.html All patches have been bootstrapped/regtested on x86_64-linux, PR36090 also on ppc-linux, ppc64-linux and i386-linux. Jakub ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch ping 2008-05-07 8:38 Patch ping Jakub Jelinek @ 2008-05-07 14:59 ` Jason Merrill 2008-05-21 15:05 ` Jakub Jelinek 2008-05-10 19:23 ` Patch ping Diego Novillo 1 sibling, 1 reply; 7+ messages in thread From: Jason Merrill @ 2008-05-07 14:59 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, Mark Mitchell, Richard Guenther Jakub Jelinek wrote: > - C++ compound literal diagnostics PR c++/36023 P2 4.3/4.4 > http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02045.html Rather than duplicating code, please split out the parts of check_initializer that are also appropriate for finish_compound_literal. > - fix dwarf2out.c for Fortran COMMONs PR debug/35896 P1 4.4 > http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02114.html OK. Jason ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch ping 2008-05-07 14:59 ` Jason Merrill @ 2008-05-21 15:05 ` Jakub Jelinek 2008-05-21 15:51 ` Jason Merrill 0 siblings, 1 reply; 7+ messages in thread From: Jakub Jelinek @ 2008-05-21 15:05 UTC (permalink / raw) To: Jason Merrill; +Cc: gcc-patches On Wed, May 07, 2008 at 10:52:42AM -0400, Jason Merrill wrote: > Jakub Jelinek wrote: > >- C++ compound literal diagnostics PR c++/36023 P2 4.3/4.4 > > http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02045.html > > Rather than duplicating code, please split out the parts of > check_initializer that are also appropriate for finish_compound_literal. Sorry for getting to this so late. check_initializer has: if (TREE_CODE (type) == ARRAY_TYPE) { tree element_type = TREE_TYPE (type); /* The array type itself need not be complete, because the initializer may tell us how many elements are in the array. But, the elements of the array must be complete. */ if (!COMPLETE_TYPE_P (complete_type (element_type))) { error ("elements of array %q#D have incomplete type", decl); return NULL_TREE; } /* It is not valid to initialize a VLA. */ if (init && ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) || !TREE_CONSTANT (TYPE_SIZE (element_type)))) { error ("variable-sized object %qD may not be initialized", decl); return NULL_TREE; } } While the 3 if conditions can be the same (assuming finish_compound_literal passes compound_literal as init), the problem is with the diagnostics, as finish_compound_literal doesn't have any decl, just the type, and in check_initializer reporting the decl is really preferrable over just returning the type. So, if I were to move the above into separate function, it would need to special case that, say: bool check_array_initializer (tree decl, tree type, tree init) { if (TREE_CODE (type) == ARRAY_TYPE) { tree element_type = TREE_TYPE (type); /* The array type itself need not be complete, because the initializer may tell us how many elements are in the array. But, the elements of the array must be complete. */ if (!COMPLETE_TYPE_P (complete_type (element_type))) { if (decl) error ("elements of array %q#D have incomplete type", decl); else error ("elements of array %q#T have incomplete type", type); return true; } /* It is not valid to initialize a VLA. */ if (init && ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) || !TREE_CONSTANT (TYPE_SIZE (element_type)))) { if (decl) error ("variable-sized object %qD may not be initialized", decl); else error ("variable-sized compound literal"); return true; } } return false; } and check_initializer replacing its code with if (check_array_initializer (decl, type, init)) return NULL_TREE; and finish_compound_literal adding: if (check_array_initializer (NULL_TREE, type, compound_literal)) return error_mark_node; I think this is uglification rather than cleanup, especially given the size of the duplicated code and that the error messages need to be different, but certainly if you prefer it that way, I can write a patch. Jakub ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch ping 2008-05-21 15:05 ` Jakub Jelinek @ 2008-05-21 15:51 ` Jason Merrill 2008-05-21 16:39 ` [C++ PATCH] Fix compound literal diagnostics (take 2, PR c++/36023) Jakub Jelinek 0 siblings, 1 reply; 7+ messages in thread From: Jason Merrill @ 2008-05-21 15:51 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches Jakub Jelinek wrote: > I think this is uglification rather than cleanup, especially given the > size of the duplicated code and that the error messages need to be > different, but certainly if you prefer it that way, I can write a patch. I think I do prefer it that way, so that if we add additional checks in the future it will be obvious that we need to handle both cases. If checks are in two different places changes in one tend not to be reflected in the other. Jason ^ permalink raw reply [flat|nested] 7+ messages in thread
* [C++ PATCH] Fix compound literal diagnostics (take 2, PR c++/36023) 2008-05-21 15:51 ` Jason Merrill @ 2008-05-21 16:39 ` Jakub Jelinek 2008-05-21 20:36 ` Jason Merrill 0 siblings, 1 reply; 7+ messages in thread From: Jakub Jelinek @ 2008-05-21 16:39 UTC (permalink / raw) To: Jason Merrill; +Cc: gcc-patches On Wed, May 21, 2008 at 11:04:42AM -0400, Jason Merrill wrote: > Jakub Jelinek wrote: > >I think this is uglification rather than cleanup, especially given the > >size of the duplicated code and that the error messages need to be > >different, but certainly if you prefer it that way, I can write a patch. > > I think I do prefer it that way, so that if we add additional checks in > the future it will be obvious that we need to handle both cases. If > checks are in two different places changes in one tend not to be > reflected in the other. Ok, here it is lightly tested, ok for trunk/4.3 if full bootstrap/regression testing succeeds? 2008-05-21 Jakub Jelinek <jakub@redhat.com> PR c++/36023 * cp-tree.h (check_array_initializer): New prototype. * decl.c (check_array_initializer): New function. (check_initializer): Call it. * semantics.c (finish_compound_literal): Call it for ARRAY_TYPEs. * g++.dg/ext/complit10.C: New test. --- gcc/cp/cp-tree.h.jj 2008-04-24 13:36:03.000000000 +0200 +++ gcc/cp/cp-tree.h 2008-05-21 17:18:40.000000000 +0200 @@ -4211,6 +4211,7 @@ extern tree shadow_tag (cp_decl_speci extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *); extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *); extern void start_decl_1 (tree, bool); +extern bool check_array_initializer (tree, tree, tree); extern void cp_finish_decl (tree, tree, bool, tree, int); extern void finish_decl (tree, tree, tree); extern int cp_complete_array_type (tree *, tree, bool); --- gcc/cp/decl.c.jj 2008-05-08 01:06:18.000000000 +0200 +++ gcc/cp/decl.c 2008-05-21 17:39:11.000000000 +0200 @@ -4894,6 +4894,38 @@ reshape_init (tree type, tree init) return new_init; } +/* Verify array initializer. Returns true if errors have been reported. */ + +bool +check_array_initializer (tree decl, tree type, tree init) +{ + tree element_type = TREE_TYPE (type); + + /* The array type itself need not be complete, because the + initializer may tell us how many elements are in the array. + But, the elements of the array must be complete. */ + if (!COMPLETE_TYPE_P (complete_type (element_type))) + { + if (decl) + error ("elements of array %q#D have incomplete type", decl); + else + error ("elements of array %q#T have incomplete type", type); + return true; + } + /* It is not valid to initialize a VLA. */ + if (init + && ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) + || !TREE_CONSTANT (TYPE_SIZE (element_type)))) + { + if (decl) + error ("variable-sized object %qD may not be initialized", decl); + else + error ("variable-sized compound literal"); + return true; + } + return false; +} + /* Verify INIT (the initializer for DECL), and record the initialization in DECL_INITIAL, if appropriate. CLEANUP is as for grok_reference_init. @@ -4917,24 +4949,8 @@ check_initializer (tree decl, tree init, if (TREE_CODE (type) == ARRAY_TYPE) { - tree element_type = TREE_TYPE (type); - - /* The array type itself need not be complete, because the - initializer may tell us how many elements are in the array. - But, the elements of the array must be complete. */ - if (!COMPLETE_TYPE_P (complete_type (element_type))) - { - error ("elements of array %q#D have incomplete type", decl); - return NULL_TREE; - } - /* It is not valid to initialize a VLA. */ - if (init - && ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) - || !TREE_CONSTANT (TYPE_SIZE (element_type)))) - { - error ("variable-sized object %qD may not be initialized", decl); - return NULL_TREE; - } + if (check_array_initializer (decl, type, init)) + return NULL_TREE; } else if (!COMPLETE_TYPE_P (type)) { --- gcc/cp/semantics.c.jj 2008-05-18 22:13:50.000000000 +0200 +++ gcc/cp/semantics.c 2008-05-21 17:40:01.000000000 +0200 @@ -2123,6 +2123,9 @@ finish_compound_literal (tree type, VEC( } type = complete_type (type); + if (TREE_CODE (type) == ARRAY_TYPE + && check_array_initializer (NULL_TREE, type, compound_literal)) + return error_mark_node; compound_literal = reshape_init (type, compound_literal); if (TREE_CODE (type) == ARRAY_TYPE) cp_complete_array_type (&type, compound_literal, false); --- gcc/testsuite/g++.dg/ext/complit10.C.jj 2008-05-21 17:20:50.000000000 +0200 +++ gcc/testsuite/g++.dg/ext/complit10.C 2008-05-21 17:20:45.000000000 +0200 @@ -0,0 +1,20 @@ +// PR c++/36023 +// { dg-do compile } +// { dg-options "" } + +struct A; + +void +f1 (int i) +{ + (int[i]) { 1 }; // { dg-error "variable-sized compound literal" } + (A[5]) { 1 }; // { dg-error "have incomplete type" } + (A[i]) { 1 }; // { dg-error "have incomplete type" } +} + +void +f2 () +{ + (int[]) { 1 }; + (int[1]) { 1 }; +} Jakub ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [C++ PATCH] Fix compound literal diagnostics (take 2, PR c++/36023) 2008-05-21 16:39 ` [C++ PATCH] Fix compound literal diagnostics (take 2, PR c++/36023) Jakub Jelinek @ 2008-05-21 20:36 ` Jason Merrill 0 siblings, 0 replies; 7+ messages in thread From: Jason Merrill @ 2008-05-21 20:36 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches OK. Jason ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Patch ping 2008-05-07 8:38 Patch ping Jakub Jelinek 2008-05-07 14:59 ` Jason Merrill @ 2008-05-10 19:23 ` Diego Novillo 1 sibling, 0 replies; 7+ messages in thread From: Diego Novillo @ 2008-05-10 19:23 UTC (permalink / raw) To: Jakub Jelinek; +Cc: gcc-patches, Mark Mitchell, Jason Merrill, Richard Guenther On 5/7/08 4:32 AM, Jakub Jelinek wrote: > - nowait for tree-parloops.c - - 4.4 > http://gcc.gnu.org/ml/gcc-patches/2008-05/msg00288.html ISTR approving this one. If I didn't, the patch is OK. Diego. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-05-21 19:22 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-05-07 8:38 Patch ping Jakub Jelinek 2008-05-07 14:59 ` Jason Merrill 2008-05-21 15:05 ` Jakub Jelinek 2008-05-21 15:51 ` Jason Merrill 2008-05-21 16:39 ` [C++ PATCH] Fix compound literal diagnostics (take 2, PR c++/36023) Jakub Jelinek 2008-05-21 20:36 ` Jason Merrill 2008-05-10 19:23 ` Patch ping Diego Novillo
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).