[all-commits] [llvm/llvm-project] d6425e: Properly implement 'enum class' parsing.

Richard Smith via All-commits all-commits at lists.llvm.org
Sun May 10 13:21:25 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d6425e2c14370ecb5e2a4be4cfdef65f8ae69bd0
      https://github.com/llvm/llvm-project/commit/d6425e2c14370ecb5e2a4be4cfdef65f8ae69bd0
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-05-10 (Sun, 10 May 2020)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticParseKinds.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Parse/Parser.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseTentative.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/Parser/MicrosoftExtensions.cpp
    M clang/test/Parser/cxx0x-ambig.cpp
    M clang/test/Parser/cxx0x-decl.cpp
    M clang/test/SemaCXX/enum-scoped.cpp
    M clang/test/SemaObjC/enum-fixed-type.m
    M clang/test/SemaTemplate/instantiate-local-class.cpp

  Log Message:
  -----------
  Properly implement 'enum class' parsing.

The 'class' or 'struct' keyword is only permitted as part of either an
enum definition or a standalone opaque-enum-declaration, not as part of
an elaborated type specifier. We previously failed to diagnose this, and
generally didn't properly implement the restrictions on elaborated type
specifiers for enumeration types.

In passing, also fixed incorrect parsing for enum-bases, which we
previously parsed as a type-name, but are actually a type-specifier-seq.
This matters for cases like 'enum E : int *p;', which is valid as a
Microsoft extension.

Plus some minor parse diagnostic improvements.

Bumped the recently-added ExtWarn for 'enum E : int x;' to be
DefaultError; this is not an intentional extension, so producing an
error by default seems appropriate, but the warning flag to disable it
may still be useful for code written against old Clang. The same
treatment is given here to the diagnostic for 'enum class E x;', which
we similarly have incorrectly accepted for many years. These diagnostics
continue to be suppressed under -fms-extensions and when compiling
Objective-C code. We will need to decide separately whether Objective-C
should follow the C++ rules or the (older) MSVC rules.




More information about the All-commits mailing list