Skip to content

[Clang][Sema] Fix crash when rebuilding MemberExprs with invalid object expressions #97455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,9 @@ class TreeTransform {
SS.Adopt(QualifierLoc);

Base = BaseResult.get();
if (Base->containsErrors())
return ExprError();

QualType BaseType = Base->getType();

if (isArrow && !BaseType->isPointerType())
Expand Down
31 changes: 31 additions & 0 deletions clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,34 @@ namespace N4 {
}
};
} // namespace N4

namespace N5 {
struct A {
int x;
};

template<typename T>
void f() {
A y = T::x; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
y.x;
}

template void f<int>(); // expected-note {{in instantiation of}}

struct B {
template<typename T>
B(T&&);

int x;
};

template<typename T>
void g(T y) {
B z([&]() { // expected-note {{while substituting into a lambda expression here}}
h(&y); // expected-error {{use of undeclared identifier 'h'}}
});
z.x;
}

template void g(int); // expected-note {{in instantiation of}}
} // namespace N5
Loading