[cfe-commits] r144159 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/pseudo-destructors.cpp
Douglas Gregor
dgregor at apple.com
Tue Nov 8 18:49:37 PST 2011
On Nov 8, 2011, at 6:26 PM, Eli Friedman wrote:
> On Tue, Nov 8, 2011 at 6:19 PM, Douglas Gregor <dgregor at apple.com> wrote:
>> Author: dgregor
>> Date: Tue Nov 8 20:19:47 2011
>> New Revision: 144159
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=144159&view=rev
>> Log:
>> Don't crash when transforming an ill-formed pseudo-destructor
>> expression. Fixes PR11339.
>>
>> Modified:
>> cfe/trunk/lib/Sema/TreeTransform.h
>> cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
>>
>> Modified: cfe/trunk/lib/Sema/TreeTransform.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=144159&r1=144158&r2=144159&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
>> +++ cfe/trunk/lib/Sema/TreeTransform.h Tue Nov 8 20:19:47 2011
>> @@ -7218,7 +7218,7 @@
>> if (!DestroyedTypeInfo)
>> return ExprError();
>> Destroyed = DestroyedTypeInfo;
>> - } else if (ObjectType->isDependentType()) {
>> + } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
>> // We aren't likely to be able to resolve the identifier down to a type
>> // now anyway, so just retain the identifier.
>> Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
>>
>> Modified: cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pseudo-destructors.cpp?rev=144159&r1=144158&r2=144159&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/pseudo-destructors.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/pseudo-destructors.cpp Tue Nov 8 20:19:47 2011
>> @@ -68,3 +68,12 @@
>> x0.~X0();
>> }
>>
>> +namespace PR11339 {
>> + template<class T>
>> + void destroy(T* p) {
>> + p->~T(); // ok
>> + p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}}
>
> This isn't the same error we get for the non-dependent case:
>
> <stdin>:1:22: error: 'oops' does not refer to a type name in
> pseudo-destructor expression; expected the name of type 'int'
> void f(int* p) { p->~oops(); }
> ^
>
> Not sure how much that matters, though.
Yeah, we're missing some resolution of the identifier at template instantiation time. I don't think it has any impact on semantics (just diagnostics), so it's fairly low priority.
- Doug
More information about the cfe-commits
mailing list