diff options
author | Martin Sebor <msebor@redhat.com> | 2021-06-04 11:21:51 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-06-04 11:22:39 -0600 |
commit | 5328cad24f7460a39b2def12bb9b62be36c92a54 (patch) | |
tree | eea3fc47111af29ca1c9c87cfa106d41e5e7dd4a | |
parent | cb6e6d5faa3f817435b6f203226fa5969d7a7264 (diff) | |
download | gcc-5328cad24f7460a39b2def12bb9b62be36c92a54.zip gcc-5328cad24f7460a39b2def12bb9b62be36c92a54.tar.gz gcc-5328cad24f7460a39b2def12bb9b62be36c92a54.tar.bz2 |
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.
-rw-r--r-- | gcc/c-family/c-attribs.c | 3 | ||||
-rw-r--r-- | gcc/c/c-objc-common.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/nonnull-6.c | 15 |
3 files changed, 24 insertions, 0 deletions
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 156f7b3..42026a8 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -698,6 +698,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 a68249d..b945de1 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 0000000..8f36870 --- /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" } |