diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-11-24 15:15:54 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2024-11-24 20:23:25 +0100 |
commit | adb4f2329a6da903fffe33b48a03510c52d1a0b8 (patch) | |
tree | ed7d03fad69c9edfb06e96830cceaa2314717227 /gcc | |
parent | aa09e32c4d4ebdd58f677a7ecbdcb93cce84823d (diff) | |
download | gcc-adb4f2329a6da903fffe33b48a03510c52d1a0b8.zip gcc-adb4f2329a6da903fffe33b48a03510c52d1a0b8.tar.gz gcc-adb4f2329a6da903fffe33b48a03510c52d1a0b8.tar.bz2 |
Adjust error message for initialized variable in .bss
The current message does not make sense with -fno-zero-initialized-in-bss.
gcc/
* doc/invoke.texi (-fno-zero-initialized-in-bss): Adjust for Ada.
* varasm.cc (get_variable_section): Adjust the error message for an
initialized variable in .bss to -fno-zero-initialized-in-bss.
gcc/testsuite/
* gnat.dg/specs/bss1.ads: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/doc/invoke.texi | 2 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/bss1.ads | 5 | ||||
-rw-r--r-- | gcc/varasm.cc | 11 |
3 files changed, 14 insertions, 4 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 44f0fd2..8141811 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -13068,7 +13068,7 @@ rely on variables going to the data section---e.g., so that the resulting executable can find the beginning of that section and/or make assumptions based on that. -The default is @option{-fzero-initialized-in-bss}. +The default is @option{-fzero-initialized-in-bss} except in Ada. @opindex fthread-jumps @item -fthread-jumps diff --git a/gcc/testsuite/gnat.dg/specs/bss1.ads b/gcc/testsuite/gnat.dg/specs/bss1.ads new file mode 100644 index 0000000..56f1802 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/bss1.ads @@ -0,0 +1,5 @@ +package Bss1 is + + I : Integer := 0 with Linker_Section => ".bss"; -- { dg-error "no initializers" } + +end Bss1; diff --git a/gcc/varasm.cc b/gcc/varasm.cc index acc4b4a..dd67dd4 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -1264,9 +1264,14 @@ get_variable_section (tree decl, bool prefer_noswitch_p) if ((sect->common.flags & SECTION_BSS) && !bss_initializer_p (decl, true)) { - error_at (DECL_SOURCE_LOCATION (decl), - "only zero initializers are allowed in section %qs", - sect->named.name); + if (flag_zero_initialized_in_bss) + error_at (DECL_SOURCE_LOCATION (decl), + "only zero initializers are allowed in section %qs", + sect->named.name); + else + error_at (DECL_SOURCE_LOCATION (decl), + "no initializers are allowed in section %qs", + sect->named.name); DECL_INITIAL (decl) = error_mark_node; } return sect; |