]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c/100625 - avoid building invalid labels in the GIMPLE FE
authorRichard Biener <rguenther@suse.de>
Mon, 17 May 2021 12:47:08 +0000 (14:47 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 17 May 2021 14:18:31 +0000 (16:18 +0200)
When duplicate labes are diagnosed, avoid building a GIMPLE_LABEL.

2021-05-17  Richard Biener  <rguenther@suse.de>

PR c/100625
gcc/c/
* gimple-parser.c (c_parser_gimple_label): Avoid building
a GIMPLE label with NULL label decl.

gcc/testsuite/
* gcc.dg/gimplefe-error-9.c: New testcase.

gcc/c/gimple-parser.c
gcc/testsuite/gcc.dg/gimplefe-error-9.c [new file with mode: 0644]

index 3a6e72ef0028de475ca96cc379b8ea5e476e8480..398e21631d9aeef17dd69d2af4909e07e9771ca4 100644 (file)
@@ -1887,7 +1887,8 @@ c_parser_gimple_label (gimple_parser &parser, gimple_seq *seq)
   gcc_assert (c_parser_next_token_is (parser, CPP_COLON));
   c_parser_consume_token (parser);
   tree label = define_label (loc1, name);
-  gimple_seq_add_stmt_without_update (seq, gimple_build_label (label));
+  if (label)
+    gimple_seq_add_stmt_without_update (seq, gimple_build_label (label));
   return;
 }
 
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-9.c b/gcc/testsuite/gcc.dg/gimplefe-error-9.c
new file mode 100644 (file)
index 0000000..87014c1
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+void __GIMPLE
+foo()
+{
+bb1:
+bb1:; /* { dg-error "duplicate" } */
+}