]> granicus.if.org Git - clang/commit
[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantia...
authorEric Fiselier <eric@efcs.ca>
Sun, 8 Apr 2018 05:11:59 +0000 (05:11 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 8 Apr 2018 05:11:59 +0000 (05:11 +0000)
commitb6baea1ebfc6c6cde166917781f1f24eceeb6910
treeee32b846745484c8faf4878817ff3a2a8b3eee94
parent639427d5d327e33d797db8a39eedf466d1159e97
[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template instantiation.

Summary:
Currently Clang fails to propagate qualifiers from the `CXXThisExpr` to the rebuilt `FieldDecl` for IndirectFieldDecls. For example:

```
template <class T> struct Foo {
  struct { int x; };
  int y;
  void foo() const {
      static_assert(__is_same(int const&, decltype((y))));
      static_assert(__is_same(int const&, decltype((x)))); // assertion fails
  }
};
template struct Foo<int>;
```

The fix is to delegate rebuilding of the MemberExpr to `BuildFieldReferenceExpr` which correctly propagates the qualifiers.

Reviewers: rsmith, lebedev.ri, aaron.ballman, bkramer, rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D45412

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329517 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/TreeTransform.h
test/SemaCXX/PR22637.cpp [new file with mode: 0644]
test/SemaCXX/cxx0x-nontrivial-union.cpp