]> gcc.gnu.org Git - gcc.git/commitdiff
Fix ICE with -g and -std=c23 when forming composite types [PR113438]
authorMartin Uecker <uecker@tugraz.at>
Tue, 23 Jan 2024 12:33:34 +0000 (13:33 +0100)
committerMartin Uecker <uecker@tugraz.at>
Wed, 31 Jan 2024 19:56:01 +0000 (20:56 +0100)
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.

gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/pr113438.c [new file with mode: 0644]

index 12d1a5a5fa19e01dcde8f6a1b5dfd58ea0d2433f..3b519c48ae0a17951e394dac131f32485ad974cc 100644 (file)
@@ -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 (file)
index 0000000..5612ee4
--- /dev/null
@@ -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);
+
This page took 0.087451 seconds and 5 git commands to generate.