From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1930) id 3747B398A41E; Thu, 17 Jun 2021 20:08:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3747B398A41E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Sebor To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8605] PR c/100783 - ICE on -Wnonnull and erroneous type X-Act-Checkin: gcc X-Git-Author: Martin Sebor X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: b9edb8fb8202dc6907f69094a8b2a621840174e1 X-Git-Newrev: 3863203bf306a730482861e974ff779e0d1db02f Message-Id: <20210617200814.3747B398A41E@sourceware.org> Date: Thu, 17 Jun 2021 20:08:14 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 20:08:14 -0000 https://gcc.gnu.org/g:3863203bf306a730482861e974ff779e0d1db02f commit r11-8605-g3863203bf306a730482861e974ff779e0d1db02f Author: Martin Sebor Date: Thu Jun 17 12:17:02 2021 -0600 PR c/100783 - ICE on -Wnonnull and erroneous type gcc/c-family/ChangeLog: PR c/100783 * c-attribs.c (positional_argument): Bail on erroneous types. gcc/c/ChangeLog: PR c/100783 * c-objc-common.c (print_type): Handle erroneous types. gcc/testsuite/ChangeLog: PR c/100783 * gcc.dg/nonnull-6.c: New test. Diff: --- gcc/c-family/c-attribs.c | 3 +++ gcc/c/c-objc-common.c | 6 ++++++ gcc/testsuite/gcc.dg/nonnull-6.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 1413f5e9b39..cdf89d66fe1 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -694,6 +694,9 @@ positional_argument (const_tree fntype, const_tree atname, tree pos, if (tree argtype = type_argument_type (fntype, ipos)) { + if (argtype == error_mark_node) + return NULL_TREE; + if (flags & POSARG_ELLIPSIS) { if (argno < 1) diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c index a68249d7011..b945de15ab8 100644 --- a/gcc/c/c-objc-common.c +++ b/gcc/c/c-objc-common.c @@ -185,6 +185,12 @@ get_aka_type (tree type) static void print_type (c_pretty_printer *cpp, tree t, bool *quoted) { + if (t == error_mark_node) + { + pp_string (cpp, _("{erroneous}")); + return; + } + gcc_assert (TYPE_P (t)); struct obstack *ob = pp_buffer (cpp)->obstack; char *p = (char *) obstack_base (ob); diff --git a/gcc/testsuite/gcc.dg/nonnull-6.c b/gcc/testsuite/gcc.dg/nonnull-6.c new file mode 100644 index 00000000000..8f368702e0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/nonnull-6.c @@ -0,0 +1,15 @@ +/* PR c/100783 - ICE on -Wnonnull and erroneous type + { dg-do compile } + { dg-options "-Wall" } */ + +__attribute__((nonnull (1))) void +f1 (char[][n]); // { dg-error "undeclared" } + +__attribute__((nonnull (2))) void +f2 (int n, char[n][m]); // { dg-error "undeclared" } + +__attribute__((nonnull (1))) void +f3 (char[*][n]); // { dg-error "undeclared" } + +__attribute__((nonnull (1))) void +f4 (char[f1]); // { dg-error "size" }