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: unassignedclangb...@nondot.org
          Reporter: josephcsi...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to