Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during te…
…mplate 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 llvm-svn: 329517
- Loading branch information
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify %s | ||
|
||
// expected-no-diagnostics | ||
|
||
void check(int&) = delete; | ||
void check(int const&) { } | ||
|
||
template <typename> | ||
struct A { | ||
union { | ||
int b; | ||
}; | ||
struct { | ||
int c; | ||
}; | ||
union { | ||
struct { | ||
union { | ||
struct { | ||
struct { | ||
int d; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
int e; | ||
void foo() const { | ||
check(b); | ||
check(c); | ||
check(d); | ||
check(d); | ||
check(e); | ||
} | ||
}; | ||
|
||
int main(){ | ||
A<int> a; | ||
a.foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters