[cfe-commits] r155187 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaTemplate/class-template-decl.cpp test/SemaTemplate/friend-template.cpp
Richard Smith
richard at metafoo.co.uk
Fri Apr 20 18:28:29 PDT 2012
Thanks, fixed in r155269.
On Fri, Apr 20, 2012 at 9:09 AM, David Dean <david_dean at apple.com> wrote:
> One of the dejagnu tests is now failing because clang is no longer
> reporting any errors.
>
> The expected output is:
> $clang g++.dg/lookup/crash6.C
> g++.dg/lookup/crash6.C:8:22: error: redefinition of 'A' as different kind
> of symbol
> template<int> struct A; // { dg-error "different kind of symbol" }
> ^
> g++.dg/lookup/crash6.C:7:5: note: previous definition is here
> int A; // { dg-error "previous declaration" }
> ^
> 1 error generated.
>
> Can you take a look?
>
>
> On 20 Apr 2012, at 12:12 AM, Richard Smith wrote:
>
> > Author: rsmith
> > Date: Fri Apr 20 02:12:26 2012
> > New Revision: 155187
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=155187&view=rev
> > Log:
> > Replace r155185 with a better fix, which also addresses PR12557. When
> looking
> > up an elaborated type specifier in a friend declaration, only look for
> type
> > declarations, per [basic.lookup.elab]p2. If we know that the
> redeclaration
> > lookup for a friend class template in a dependent context finds a
> non-template,
> > don't delay the diagnostic to instantiation time.
> >
> > Modified:
> > cfe/trunk/lib/Sema/SemaTemplate.cpp
> > cfe/trunk/test/SemaTemplate/class-template-decl.cpp
> > cfe/trunk/test/SemaTemplate/friend-template.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=155187&r1=155186&r2=155187&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Apr 20 02:12:26 2012
> > @@ -867,7 +867,7 @@
> >
> > // Find any previous declaration with this name.
> > DeclContext *SemanticContext;
> > - LookupResult Previous(*this, Name, NameLoc, LookupOrdinaryName,
> > + LookupResult Previous(*this, Name, NameLoc, LookupTagName,
> > ForRedeclaration);
> > if (SS.isNotEmpty() && !SS.isInvalid()) {
> > SemanticContext = computeDeclContext(SS, true);
> > @@ -938,7 +938,7 @@
> > while (!OutermostContext->isFileContext())
> > OutermostContext = OutermostContext->getLookupParent();
> >
> > - if (PrevClassTemplate &&
> > + if (PrevDecl &&
> > (OutermostContext->Equals(PrevDecl->getDeclContext()) ||
> > OutermostContext->Encloses(PrevDecl->getDeclContext()))) {
> > SemanticContext = PrevDecl->getDeclContext();
> > @@ -951,7 +951,7 @@
> > }
> > }
> >
> > - if (CurContext->isDependentContext()) {
> > + if (CurContext->isDependentContext() && PrevClassTemplate) {
> > // If this is a dependent context, we don't want to link the friend
> > // class template to the template in scope, because that would
> perform
> > // checking of the template parameter lists that can't be performed
> >
> > Modified: cfe/trunk/test/SemaTemplate/class-template-decl.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-decl.cpp?rev=155187&r1=155186&r2=155187&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaTemplate/class-template-decl.cpp (original)
> > +++ cfe/trunk/test/SemaTemplate/class-template-decl.cpp Fri Apr 20
> 02:12:26 2012
> > @@ -94,13 +94,3 @@
> > };
> > };
> > }
> > -
> > -namespace Redecl {
> > - struct S {
> > - int packaged_task;
> > - template<typename> class future {
> > - template<typename> friend class packaged_task;
> > - };
> > - future<void> share;
> > - };
> > -}
> >
> > Modified: cfe/trunk/test/SemaTemplate/friend-template.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/friend-template.cpp?rev=155187&r1=155186&r2=155187&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/SemaTemplate/friend-template.cpp (original)
> > +++ cfe/trunk/test/SemaTemplate/friend-template.cpp Fri Apr 20 02:12:26
> 2012
> > @@ -243,3 +243,27 @@
> >
> > A<double>::B<double> ab;
> > }
> > +
> > +namespace RedeclUnrelated {
> > + struct S {
> > + int packaged_task;
> > + template<typename> class future {
> > + template<typename> friend class packaged_task;
> > + };
> > + future<void> share;
> > + };
> > +}
> > +
> > +namespace PR12557 {
> > + template <typename>
> > + struct Foo;
> > +
> > + template <typename Foo_>
> > + struct Bar {
> > + typedef Foo_ Foo; // expected-note {{previous}}
> > +
> > + template <typename> friend struct Foo; // expected-error
> {{redefinition of 'Foo' as different kind of symbol}}
> > + };
> > +
> > + Bar<int> b;
> > +}
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> -David
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120420/c8961215/attachment.html>
More information about the cfe-commits
mailing list