[llvm-bugs] [Bug 39925] New: struct definition leaks out of function prototype scope

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Dec 8 11:03:06 PST 2018


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

            Bug ID: 39925
           Summary: struct definition leaks out of function prototype
                    scope
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: anders.granlund.0 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The following C11 program (prog.c) should compile without error:

  struct T;

  void f(
    struct S {
      struct T {
        int a;
      } *b;
    }
  );

  struct T {
    int c;
  };

  int main()
  {
  }

When I compile it with  clang prog.c -std=c11 -pedantic-errors "-w"  i get the
following unexpected error:

  error: redefinition of 'T'

This is wrong since the struct definition inside the function declaration has
function prototype scope and therefore should be independent of the struct
definition in the file scope.

Online compiler link:

  https://wandbox.org/permlink/UpaD0znT5jkohSNP

Note that gcc does not give any errors.

-- 
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/20181208/4f7ff6b7/attachment.html>


More information about the llvm-bugs mailing list