This started to ICE after r16-3747-gafa74d37e8170d which added
a call to mark_decl_used. You can't call mark_decl_used with a
typedef which is an error mark as you get an ICE.
There is a check right after the newly added call for error mark,
so let's move the call to inside that block instead.
Bootstrapped and tested on x86_64-linux-gnu.
PR c/123461
gcc/c/ChangeLog:
* c-decl.cc (declspecs_add_type): Move mark_decl_used
call after the check for error mark node.
gcc/testsuite/ChangeLog:
* gcc.dg/pr123461-1.c: New test.
Signed-off-by: Andrew Pinski <[email protected]>
---
gcc/c/c-decl.cc | 2 +-
gcc/testsuite/gcc.dg/pr123461-1.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr123461-1.c
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 10b4d77daee..98249b92269 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -13065,10 +13065,10 @@ declspecs_add_type (location_t loc, struct
c_declspecs *specs,
error_at (loc, "two or more data types in declaration specifiers");
else if (TREE_CODE (type) == TYPE_DECL)
{
- mark_decl_used (type, false);
specs->type = TREE_TYPE (type);
if (TREE_TYPE (type) != error_mark_node)
{
+ mark_decl_used (type, false);
specs->decl_attr = DECL_ATTRIBUTES (type);
specs->typedef_p = true;
specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type);
diff --git a/gcc/testsuite/gcc.dg/pr123461-1.c
b/gcc/testsuite/gcc.dg/pr123461-1.c
new file mode 100644
index 00000000000..d94932bd2d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr123461-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* PR c/123461 */
+
+void foo(int n) {
+ enum b typedef V[]; /* { dg-error "array type has incomplete element type" }
*/
+ void bar(V) /* { dg-error "old-style parameter" } */
+ V bar_ptr;
+ {}
+}
--
2.43.0