[clang] [clang] Add parser test for empty asm label with paren initializer (PR #247032)

Shraavasti Bhat via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 17:12:40 PST 2026


https://github.com/shraavb created https://github.com/llvm/llvm-project/pull/247032

Add a regression test for a declaration with an empty asm label followed by a parenthesized initializer, e.g.

  char hello __asm__("")('c', 'c');

Clang used to crash on this input. It now reports that an asm label can't be an empty string literal and that a ';' is missing after the declarator, and doesn't crash.

Fixes #205320

>From 64740be9cfd35e666f73a207c85325a920672970 Mon Sep 17 00:00:00 2001
From: Shraavasti Bhat <shraavastib at gmail.com>
Date: Sun, 29 Nov 2026 17:09:34 -0800
Subject: [PATCH] [clang] Add parser test for empty asm label with paren
 initializer

Add a regression test for a declaration with an empty asm label
followed by a parenthesized initializer, e.g.

  char hello __asm__("")('c', 'c');

Clang used to crash on this input. It now reports that an asm label
can't be an empty string literal and that a ';' is missing after the
declarator, and doesn't crash.

Fixes #205320
---
 clang/test/Parser/asm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/test/Parser/asm.c b/clang/test/Parser/asm.c
index 0eb89ea72c1c9b..c8ec5b73ccf192 100644
--- a/clang/test/Parser/asm.c
+++ b/clang/test/Parser/asm.c
@@ -34,6 +34,10 @@ asm(; // expected-error {{expected string literal in 'asm'}}
 
 asm("") // expected-error {{expected ';' after top-level asm block}}
 
+// Don't crash on an empty asm label followed by a parenthesized initializer.
+char hello __asm__("")('c', 'c'); // expected-error {{cannot use an empty string literal in 'asm'}}
+// expected-error at -1 {{expected ';' after top level declarator}}
+
 // Unterminated asm strings at the end of the file were causing us to crash, so
 // this needs to be last.
 // expected-warning at +3 {{missing terminating '"' character}}



More information about the cfe-commits mailing list