This revision was automatically updated to reflect the committed changes. Closed by commit rC329517: [Sema] Fix PR22637 - IndirectFieldDecl's discard qualifiers during template… (authored by EricWF, committed by ).
Changed prior to commit: https://reviews.llvm.org/D45412?vs=141520&id=141523#toc Repository: rC Clang https://reviews.llvm.org/D45412 Files: lib/Sema/TreeTransform.h test/SemaCXX/PR22637.cpp test/SemaCXX/cxx0x-nontrivial-union.cpp Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -2250,11 +2250,11 @@ if (BaseResult.isInvalid()) return ExprError(); Base = BaseResult.get(); - ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind(); - MemberExpr *ME = new (getSema().Context) - MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo, - cast<FieldDecl>(Member)->getType(), VK, OK_Ordinary); - return ME; + + CXXScopeSpec EmptySS; + return getSema().BuildFieldReferenceExpr( + Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member), + DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo); } CXXScopeSpec SS; Index: test/SemaCXX/PR22637.cpp =================================================================== --- test/SemaCXX/PR22637.cpp +++ test/SemaCXX/PR22637.cpp @@ -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(); +} Index: test/SemaCXX/cxx0x-nontrivial-union.cpp =================================================================== --- test/SemaCXX/cxx0x-nontrivial-union.cpp +++ test/SemaCXX/cxx0x-nontrivial-union.cpp @@ -110,7 +110,7 @@ } explicit operator bool() const { return has; } - T &operator*() const { return value; } + T &operator*() { return value; } }; optional<non_trivial> o1;
Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -2250,11 +2250,11 @@ if (BaseResult.isInvalid()) return ExprError(); Base = BaseResult.get(); - ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind(); - MemberExpr *ME = new (getSema().Context) - MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo, - cast<FieldDecl>(Member)->getType(), VK, OK_Ordinary); - return ME; + + CXXScopeSpec EmptySS; + return getSema().BuildFieldReferenceExpr( + Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member), + DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo); } CXXScopeSpec SS; Index: test/SemaCXX/PR22637.cpp =================================================================== --- test/SemaCXX/PR22637.cpp +++ test/SemaCXX/PR22637.cpp @@ -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(); +} Index: test/SemaCXX/cxx0x-nontrivial-union.cpp =================================================================== --- test/SemaCXX/cxx0x-nontrivial-union.cpp +++ test/SemaCXX/cxx0x-nontrivial-union.cpp @@ -110,7 +110,7 @@ } explicit operator bool() const { return has; } - T &operator*() const { return value; } + T &operator*() { return value; } }; optional<non_trivial> o1;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits