diagnostics: fix gcc-urlifier.cc bootstrap failure [PR112379]

Message ID 20231104162318.4142088-1-slyich@gmail.com
State Unresolved
Headers
Series diagnostics: fix gcc-urlifier.cc bootstrap failure [PR112379] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Sergei Trofimovich Nov. 4, 2023, 4:23 p.m. UTC
  From: Sergei Trofimovich <siarheit@google.com>

Without the change `./configure --enable-checking=release` bootstrap
fails as:

    gcc/gcc-urlifier.cc:100:1: error: 'get_url_suffix_for_quoted_text()'
        defined but not used [-Werror=unused-function]

This happens because the helper is used only in `ASSERT` macros which
don't always get expanded to executable code.

The fix marks helper function with `ATTRIBUTE_UNUSED`.

gcc/
	PR bootstrap/112379
	* gcc-urlifier.cc (get_url_suffix_for_quoted_text): Mark as
	ATTRIBUTE_UNUSED.
---
 gcc/gcc-urlifier.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

David Malcolm Nov. 4, 2023, 5:36 p.m. UTC | #1
On Sat, 2023-11-04 at 16:23 +0000, Sergei Trofimovich wrote:
> From: Sergei Trofimovich <siarheit@google.com>
> 
> Without the change `./configure --enable-checking=release` bootstrap
> fails as:
> 
>     gcc/gcc-urlifier.cc:100:1: error:
> 'get_url_suffix_for_quoted_text()'
>         defined but not used [-Werror=unused-function]
> 
> This happens because the helper is used only in `ASSERT` macros which
> don't always get expanded to executable code.
> 
> The fix marks helper function with `ATTRIBUTE_UNUSED`.

Sorry for the breakage.

Patch looks good to me; thanks
Dave

> 
> gcc/
>         PR bootstrap/112379
>         * gcc-urlifier.cc (get_url_suffix_for_quoted_text): Mark as
>         ATTRIBUTE_UNUSED.
> ---
>  gcc/gcc-urlifier.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/gcc-urlifier.cc b/gcc/gcc-urlifier.cc
> index 269246bc703..0dbff985313 100644
> --- a/gcc/gcc-urlifier.cc
> +++ b/gcc/gcc-urlifier.cc
> @@ -37,7 +37,8 @@ public:
>    char *get_url_for_quoted_text (const char *p, size_t sz) const
> final override;
>  
>    const char *get_url_suffix_for_quoted_text (const char *p, size_t
> sz) const;
> -  const char *get_url_suffix_for_quoted_text (const char *p) const;
> +  /* We use ATTRIBUTE_UNUSED as this helper is called only from
> ASSERTs.  */
> +  const char *get_url_suffix_for_quoted_text (const char *p) const
> ATTRIBUTE_UNUSED;
>  
>  private:
>    static char *
  

Patch

diff --git a/gcc/gcc-urlifier.cc b/gcc/gcc-urlifier.cc
index 269246bc703..0dbff985313 100644
--- a/gcc/gcc-urlifier.cc
+++ b/gcc/gcc-urlifier.cc
@@ -37,7 +37,8 @@  public:
   char *get_url_for_quoted_text (const char *p, size_t sz) const final override;
 
   const char *get_url_suffix_for_quoted_text (const char *p, size_t sz) const;
-  const char *get_url_suffix_for_quoted_text (const char *p) const;
+  /* We use ATTRIBUTE_UNUSED as this helper is called only from ASSERTs.  */
+  const char *get_url_suffix_for_quoted_text (const char *p) const ATTRIBUTE_UNUSED;
 
 private:
   static char *