From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id AB316393A42C for ; Wed, 12 Jan 2022 10:06:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB316393A42C Received: by mail-wm1-x329.google.com with SMTP id d18-20020a05600c251200b0034974323cfaso3083836wma.4 for ; Wed, 12 Jan 2022 02:06:23 -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=9KSduT9eDyhlGfntAPOg1zJlrTU9kGWU9swVC+beYQ4=; b=wWe9G4Bd/PTWXQxWfeiNoepAS2BpBCsKKaKDh/LYFhHuuLgiBxvMmmbc+h27VqGhMt WmA167nQlMW2z/ndly2FmSMxTmmIcMGd5EcpnSl7SPVEE5WD4/SSmEWVenoQZF54GGkb r3POonrDHunHFJxL+T95jDoRBZmuhyGtTO9YTYG+sCgBPTos6Qe1H7vPW0gk9j61Je6O grKD7gjn3lAJN1jRBwA0g6XSxeQcOK/9/teGc2zEtlfdLxwwna28Ecr5HKW0qLFDw6Fm JjyY9dAlYZAgrQ5E7+UuXOcD0D6+WsiwMiAoLDU6eL9b9YMWHXSZUUWd8AoHOLflbz+y LuVQ== X-Gm-Message-State: AOAM531SY5mrZuGcsjPi0V4PcYVAY8wEsP1i52QbeFQTJF4bnqUVrgb0 DNuH40dwFY64yV4IrY5eOg5L+FvO6seKhzpGGEVsT0eAE7M= X-Google-Smtp-Source: ABdhPJzcBgcf9KTInTNCPoxZd0otND0rJU2Q/GIDBI3J8jFmoUlR6B7IPu1U5BQUwkXKtkxfzwBrwum7zcdPDW0XdyM= X-Received: by 2002:a05:600c:384c:: with SMTP id s12mr6109603wmr.108.1641981982377; Wed, 12 Jan 2022 02:06:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 12 Jan 2022 10:06:11 +0000 Message-ID: Subject: Re: Better diagnostic for shadowed function? To: NightStrike Cc: gcc-help Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 10:06:25 -0000 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 vector > 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[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 !