[PATCH] Improve error recovery around colon.

Serge Pavlov sepavloff at gmail.com
Wed Jun 4 00:43:44 PDT 2014


Fixed parsing unnamed bit fields

Thank you for example, it represents a case missed from the patch.
Adding colon protector indeed helps for the code:

    const int m = 4;
    struct A {
      struct n {
        int m;
      };
      int A::n : m;
    };

I found another example, that is not MS-specific and is currently
misparsed by clang:

    struct A {
      enum class B {
        C
      };
    };
    const int C = 4;
    struct D {
      A::B : C;
    };

Fixing this case is a bit trickier because declspec is parsed with colon
protection turned off, otherwise we cannot recover typos like:

    A:B c;

To recogneze that A::B:C is not a typo for A::B::C we must know that the
parsed scope spec is a part of type specifier.

In the updated patch TryAnnotateCXXScopeToken has additional parameter,
that provide information whether a type is expected, with this change the
above example is parsed correctly.

http://reviews.llvm.org/D3653

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaCXXScopeSpec.cpp
  test/SemaCXX/MicrosoftExtensions.cpp
  test/SemaCXX/enum-bitfield.cpp
  test/SemaCXX/nested-name-spec.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3653.10083.patch
Type: text/x-patch
Size: 19843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140604/f2fd38d9/attachment.bin>


More information about the cfe-commits mailing list