Last year I've extended the asm template syntax in inline asm to support
%cc0 etc., apparently the first 2 letter generic operand modifier.
As the following testcase shows, I forgot to tweak the [foo] handling
for it though. As final.cc will error on any % ISALPHA not followed by
digit (with the exception of % c c digit), I think we can safely handle
this for any 2 letters in between % and [, instead of hardcoding it for
now only for %cc[ and changing it again next time we add something
two-letter.
2025-10-06 Jakub Jelinek <jakub@redhat.com>
PR middle-end/122133
* stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
by open square.
* c-c++-common/toplevel-asm-9.c: New test.
{
if (c[1] == '[')
break;
- else if (ISALPHA (c[1]) && c[2] == '[')
+ else if (ISALPHA (c[1])
+ && (c[2] == '[' || (ISALPHA (c[2]) && c[3] == '[')))
break;
else
{
p += 1;
else if (ISALPHA (p[1]) && p[2] == '[')
p += 2;
+ else if (ISALPHA (p[1]) && ISALPHA (p[2]) && p[3] == '[')
+ p += 3;
else
{
p += 1 + (p[1] == '%');
--- /dev/null
+/* PR middle-end/122133 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+extern int v[42], w;
+int x[42], y;
+void foo (void);
+void bar (void) {}
+
+asm ("# %cc[foo]: %cc[v]: %cc[w]: %cc[bar] %cc[x] %cc[y]"
+ :: [foo] ":" (foo), [v] ":" (v), [w] ":" (&w),
+ [bar] "-i" (bar), [x] "-s" (x), [y] "-s" (&y));