https://llvm.org/bugs/show_bug.cgi?id=24791
Bug ID: 24791
Summary: Clang crashes when suggesting unencessary "this->"
fixit
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
push.cpp:
struct A {
void Run(int x) {
Get<>(x, x);
}
template <typename X>
void Get(X x, int y) {
// correct error message
//this->Set(x);
// correct error message
//Set(y);
// compiles
//Set(&x);
// crash
Set(x);
}
// comment either overload to prevent crash and get correct error messages
static void Set(int*) {}
static void Set(double*) {}
};
Command:
clang push.cpp
Output:
push.cpp:18:5: error: use of undeclared identifier 'Set'
Set(x);
^
this->
push.cpp:3:5: note: in instantiation of function template specialization
'A::Get<int>' requested here
Get<>(x, x);
^
The fixit "this->" for Set is not needed since the two Set functions are in
scope, and the various other calls to Set don't require it. The crash happens
at:
lib/Sema/SemaExpr.cpp:
1839 else if (CurMethod->getTemplatedKind() ==
1840 FunctionDecl::TK_FunctionTemplateSpecialization)
1841 DepMethod =
cast<CXXMethodDecl>(CurMethod->getPrimaryTemplate()->
1842 getInstantiatedFromMemberTemplate()->getTemplatedDecl());
getTemplateDecl() returns a null pointer. cast<CXXMethodDecl> then crashes
when passed that null pointer.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs