[llvm-bugs] [Bug 48273] New: GNU extension: Support forward declaring function parameters

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 23 12:06:30 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48273

            Bug ID: 48273
           Summary: GNU extension: Support forward declaring function
                    parameters
           Product: clang
           Version: 11.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: josephcsible at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Consider this C function:

void transpose(double (*)[*], int);
void transpose(array, size)
  int size;
  double (*array)[size];
{
  for (int i=1; i<size; i++)
  {
    for (int j=0; j<i; j++)
    {
      double t = array[i][j];
      array[i][j] = array[j][i];
      array[j][i] = t;
    }
  }
}

It uses a K&R function definition, which is deprecated and will probably be
removed in C2x. To my knowledge, there's no standard replacement for that since
the VLA comes before its size, but a GNU extension allows forward declaring
parameters, like this:

void transpose(double (*)[*], int);
void transpose(int size; double (*array)[size], int size)
{
  for (int i=1; i<size; i++)
  {
    for (int j=0; j<i; j++)
    {
      double t = array[i][j];
      array[i][j] = array[j][i];
      array[j][i] = t;
    }
  }
}

Today, GCC will accept that code, but Clang will not. Can support for that GNU
extension be added to Clang as well?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201123/46cce7f0/attachment.html>


More information about the llvm-bugs mailing list