diff mbox series

Fix ICE with -g and -std=c23 when forming composite types [PR113438]

Message ID 33351410467b29b38728c6a48e71a2b5c4518c2b.camel@tugraz.at
State New
Headers show
Series Fix ICE with -g and -std=c23 when forming composite types [PR113438] | expand

Commit Message

Martin Uecker Jan. 27, 2024, 4:10 p.m. UTC
Debug output ICEs when we do not set TYPE_STUB_DECL, fix this.


    Fix ICE with -g and -std=c23 when forming composite types [PR113438]
    
    Set TYPE_STUB_DECL to an artificial decl when creating a new structure
    as a composite type.
    
            PR c/113438
    
    gcc/c/
            * c-typeck.cc (composite_type_internal): Set TYPE_STUB_DECL.
    
    gcc/testsuite/
            * gcc.dg/pr113438.c: New test.

Comments

Joseph Myers Jan. 29, 2024, 8:27 p.m. UTC | #1
On Sat, 27 Jan 2024, Martin Uecker wrote:

> Debug output ICEs when we do not set TYPE_STUB_DECL, fix this.
> 
> 
>     Fix ICE with -g and -std=c23 when forming composite types [PR113438]
>     
>     Set TYPE_STUB_DECL to an artificial decl when creating a new structure
>     as a composite type.
>     
>             PR c/113438
>     
>     gcc/c/
>             * c-typeck.cc (composite_type_internal): Set TYPE_STUB_DECL.
>     
>     gcc/testsuite/
>             * gcc.dg/pr113438.c: New test.

OK.
diff mbox series

Patch

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 66c6abc9f07..cfa3b7ab10f 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -585,6 +585,11 @@  composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
 	  /* Setup the struct/union type.  Because we inherit all variably
 	     modified components, we can ignore the size expression.  */
 	  tree expr = NULL_TREE;
+
+	  /* Set TYPE_STUB_DECL for debugging symbols.  */
+	  TYPE_STUB_DECL (n) = pushdecl (build_decl (input_location, TYPE_DECL,
+						     NULL_TREE, n));
+
 	  n = finish_struct(input_location, n, fields, attributes, NULL, &expr);
 
 	  n = qualify_type (n, t1);
diff --git a/gcc/testsuite/gcc.dg/pr113438.c b/gcc/testsuite/gcc.dg/pr113438.c
new file mode 100644
index 00000000000..5612ee4fa38
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113438.c
@@ -0,0 +1,7 @@ 
+/* PR113438
+ * { dg-do compile }
+ * { dg-options "-std=c23 -g" } */
+
+void g(struct foo { int x; } a);
+void g(struct foo { int x; } a);
+