From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id C31FB3858406 for ; Wed, 12 Jan 2022 18:36:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C31FB3858406 Received: by mail-ed1-x52f.google.com with SMTP id t24so13508678edi.8 for ; Wed, 12 Jan 2022 10:36:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Bu8vMgbKiGcNyTxMSU08txVrFRS1+GXZsM1qmRZ94D4=; b=y6iQ7j1GTgt0namz3F0mvk0DEA4GcoRJbTOeNtRvQUOISo4s2nxYwUap7Y1kfwXxlA lPn3cdhQf+p0O16P8rhlKtizo2GGUE4mNJteqkbvpBAtDyq3BJFlLdctw1qS30w7+FS2 +Ti2n55Wis8yBuUwIjY1j+OWO+C1QERJOBKi2PDap8xdj8iGF3xxaVy9YUkqGXw7ZVZK pGYy7woJE45dpOrnALth09KQuttpOTHJEKET4eaeZ52lzmtgJrkIv9sUgGSCfNpOhwjz ipDAK4jKkrfEPLig+LhpkJBXuQiPIzASadNLTQc2brEmGkdrMyESy1Jec01vpP+DW54z 3pgg== X-Gm-Message-State: AOAM5320bJaKhSti0OJIAkn+KKREFZ4BQTjG8naK5EJxEiaAxk8WftgH dGv9Ks07aNybcpiNA4Pr1qHebfWDc9JXdBBkfzY= X-Google-Smtp-Source: ABdhPJy2uuECzopV98U9XWr+s/AIPiTLJluJEZIetVlO11ASo+2ZpE7wPKhIXr7FRpK29D8PltYYWp9nAdHWzDRnlZE= X-Received: by 2002:a17:906:6148:: with SMTP id p8mr805259ejl.254.1642012600730; Wed, 12 Jan 2022 10:36:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: NightStrike Date: Wed, 12 Jan 2022 13:36:27 -0500 Message-ID: Subject: Re: Better diagnostic for shadowed function? To: Jonathan Wakely Cc: gcc-help Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 18:36:43 -0000 On Wed, Jan 12, 2022 at 5:06 AM Jonathan Wakely wro= te: > > On Wed, 12 Jan 2022 at 06:34, NightStrike via Gcc-help > wrote: > > > > I recently hit this problem: > > > > #include > > void f() { > > index[0] =3D 0; > > } > > > > #gcc is 11.2.0 > > gcc -c a.c > > a.c:4:7: error: subscripted value is neither array nor pointer nor vect= or > > 4 | index[1] =3D 0; > > | ^ > > > > -Wshadow (or all or extra) did not highlight that "index" was actually > > a function from strings.h. For the future, is there anything I could > > have done to make gcc tell me what the real error was? > > g++ is *slightly* more help: > s.c:3:10: error: invalid types =E2=80=98 type>[int]=E2=80=99 for array subscript > > This at least gives you a hint it's a function, so probably declared > somewhere in a header. The C front end could do the same, saying > "subscripted value is a function", but it just has a generic > diagnostic for all un-subscriptable types. Asking for that to be > improved seems like a good use of a bugzilla PR. > > Maybe would make sense for us to also add a note telling you where > 'index' was declared, as long as it doesn't get suppressed without > -Wsystem-headers ! Added as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103996 Thanks!