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] | |
A one-component aggregate in a non-static context is suspicious, and may be
a user error where a subtype name rather than a single component association
was intended, In any case, the aggregate must be expanded into an assignment
because gcc cannot handle a constant one-component array in such a context.
The following must compile and yield the warning:
one_comp.adb:14:18: warning: single component aggregate in non-static context
one_comp.adb:14:18: warning: maybe subtype name was meant
---
procedure One_Comp is
function F return Integer is
begin
return 1;
end;
type Rec is record
Val : integer;
end record;
Max_Val : constant Integer := F;
subtype Size is integer range 1 .. Max_Val;
type Arr is array (Size) of Rec;
Index : constant Size := 1;
Obj : Arr := (Index => (Val => 111));
begin
null;
end;
Tested on i686-pc-linux-gnu, committed on trunk
2008-07-31 Ed Schonberg <schonberg@adacore.com>
* exp_aggr.adb (Aggr_Size_OK): If the aggregate has a single component
and the context is an object declaration with non-static bounds, treat
the aggregate as non-static.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |