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

            Bug ID: 40169
           Summary: c11: Accepts ill-formed program using an enum type
                    before it is complete.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: anders.granlun...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

Test program (prog.c):

  int main()
  {
    enum E { x = sizeof (enum E *) };
  }

Compilation command line:

  clang prog.c -Wall -Wextra -std=c11 -pedantic-errors 

Observed behaviour:

  No error messages outputed.

Expected behaviour:

  An error message outputed.

  The use of the typespecifier  enum E  in  enum E *  is not allowed becuase
  the enum  E  is not yet complete at that point. 

References to the c17 (bugfix of c11) standard:

  6.7.2.3/3:

    "A type specifier of the form enum identifier without an enumerator list
     shall only appear after the type it specifies is complete."

  6.7.2.2/4:

     "... The enumerated type is incomplete until immediately after the }
      that terminates the list of enumerator declarations, and complete
      thereafter."

Note:

  GCC outputs the expected error message.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to