[PATCH] PR20716 - Crash when recovering from type in known dependent base (ms-compatibility)
David Blaikie
dblaikie at gmail.com
Wed Aug 20 19:38:41 PDT 2014
On Wed, Aug 20, 2014 at 6:33 PM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> Are you saying you ran the test case without my change and it didn't crash?
No, I'm saying a test that only ensures the compiler doesn't crash is
usually not a very good test. We usually want a program to do
something more specific than "does not crash" - and the test should
test for that specific behavior, not merely the absence of a crash.
>
> Just -cc1 -fms-compatibility -fsyntax-only and you should see it.
>
>
> On Thu, Aug 21, 2014 at 11:31 AM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>> On Wed, Aug 20, 2014 at 5:19 PM, Nikola Smiljanić <popizdeh at gmail.com>
>> wrote:
>> > Hi rnk,
>> >
>> > The call to cast crashes because getTemplateDecl returns null for
>> > TemplateTemplateParmDecls.
>> >
>> > http://reviews.llvm.org/D4992
>> >
>> > Files:
>> > lib/Sema/SemaDecl.cpp
>> > test/SemaTemplate/ms-lookup-template-base-classes.cpp
>> >
>> > Index: lib/Sema/SemaDecl.cpp
>> > ===================================================================
>> > --- lib/Sema/SemaDecl.cpp
>> > +++ lib/Sema/SemaDecl.cpp
>> > @@ -150,7 +150,7 @@
>> > if (!TST || !TST->isDependentType())
>> > continue;
>> > auto *TD = TST->getTemplateName().getAsTemplateDecl();
>> > - if (!TD)
>> > + if (!TD || !TD->getTemplatedDecl())
>>
>> Looks like the indentation might've broken here? (or maybe it's just
>> misrendering in the email)
>>
>> > continue;
>> > auto *BasePrimaryTemplate =
>> > cast<CXXRecordDecl>(TD->getTemplatedDecl());
>> > // FIXME: Allow lookup into non-dependent bases of dependent bases,
>> > possibly
>> > Index: test/SemaTemplate/ms-lookup-template-base-classes.cpp
>> > ===================================================================
>> > --- test/SemaTemplate/ms-lookup-template-base-classes.cpp
>> > +++ test/SemaTemplate/ms-lookup-template-base-classes.cpp
>> > @@ -460,3 +460,19 @@
>> > int x = f<NameFromBase>();
>> > };
>> > }
>> > +
>> > +namespace PR20716 {
>>
>> Test cases that just "don't crash" always seem a bit questionable to
>> me - is there some behavior this should be testing for?
>>
>> > +template <class T>
>> > +struct A
>> > +{
>> > + void foo() {}
>> > +};
>> > +
>> > +template <template <typename T> class C>
>> > +struct B : public C<int>
>> > +{
>> > + void bar() {
>> > + foo();
>> > + }
>> > +};
>> > +}
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>
>
More information about the cfe-commits
mailing list