]> git.pld-linux.org Git - packages/crosssparc-gcc.git/blob - gcc-pr21454.patch
- put const c++ arrays in .rodata section.
[packages/crosssparc-gcc.git] / gcc-pr21454.patch
1 From: Jakub Jelinek <jakub at redhat dot com>
2 Subject: [PATCH] Set TREE_READONLY const POD arrays with size determined from initializer (PR c++/21454)
3
4 This is a fallout of the PR c++/20073 fix.
5 For arrays like:
6 const int a[] = { 0, 1, 2, 3 };
7 when cp_apply_type_quals_to_decl is called, its type is not complete yet,
8 so C++ frontend does not set TREE_READONLY flag.  But such variables
9 aren't put into incomplete_vars chain either, so nothing sets the flag
10 afterwards.
11
12 2005-05-11  Jakub Jelinek  <jakub@redhat.com>
13
14         PR c++/21454
15         * decl.c (maybe_deduce_size_from_array_init): Call
16         cp_apply_type_quals_to_decl after completing array type.
17
18         * g++.dg/opt/const4.C: New test.
19
20 --- gcc/gcc/cp/decl.c   2005-05-11 11:50:14.000000000 +0200
21 +++ gcc/gcc/cp/decl.c   2005-05-11 19:03:28.000000000 +0200
22 @@ -3933,6 +3933,8 @@ maybe_deduce_size_from_array_init (tree 
23        if (failure == 3)
24         error ("zero-size array %qD", decl);
25  
26 +      cp_apply_type_quals_to_decl (cp_type_quals (TREE_TYPE (decl)), decl);
27 +
28        layout_decl (decl, 0);
29      }
30  }
This page took 0.075891 seconds and 3 git commands to generate.