Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[C++11] member pointer declaration cannot use decltype specifier #20989

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR20990
Status NEW
Importance P normal
Reported by Mitsuru Kariya (kariya_mitsuru@hotmail.com)
Reported on 2014-09-17 23:22:47 -0700
Last modified on 2014-09-17 23:37:25 -0700
Version trunk
Hardware All All
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The sample code below should be compiled successfully but it causes compilation
error by clang.
================================
struct S {
    int i;
};

int main()
{
    S v;
    int decltype(v)::*p = &S::i;
}
================================

The "decltype(v)::*" is ptr-operator and "decltype(v)::" is nested-name-
specifier, so it is well-formed.

cf. http://melpon.org/wandbox/permlink/o2cISNE0JqJ2YbDj
Quuxplusone commented 10 years ago
Here's the bug (Parser::ParseDeclaratorInternal):

  // C++ member pointers start with a '::' or a nested-name.
  // Member pointers get special handling, since there's no place for the
  // scope spec in the generic path below.
  if (getLangOpts().CPlusPlus &&
      (Tok.is(tok::coloncolon) ||
       (Tok.is(tok::identifier) &&
        (NextToken().is(tok::coloncolon) || NextToken().is(tok::less))) ||
       Tok.is(tok::annot_cxxscope))) {