r224903 - Parse: Don't crash when 'typename' shows up in an attribute

David Majnemer david.majnemer at gmail.com
Sat Jan 3 11:42:11 PST 2015


Should be fixed with r225118.

On Sat, Jan 3, 2015 at 8:34 AM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Sun, Dec 28, 2014 at 5:28 PM, David Majnemer
> <david.majnemer at gmail.com> wrote:
> > Author: majnemer
> > Date: Sun Dec 28 16:28:32 2014
> > New Revision: 224903
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=224903&view=rev
> > Log:
> > Parse: Don't crash when 'typename' shows up in an attribute
> >
> > isDeclarationSpecifier performs error recovers which jostles the token
> > stream.  Specifically, TryAnnotateTypeOrScopeToken will end up consuming
> > a typename token which will confuse the attribute parsing machinery as
> > we no-longer have something identifier-like.
> >
> > Modified:
> >     cfe/trunk/lib/Parse/ParseDecl.cpp
> >     cfe/trunk/test/Parser/cxx-attributes.cpp
> >     cfe/trunk/test/Parser/namespace-alias-attr.cpp
> >
> > Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=224903&r1=224902&r2=224903&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> > +++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Dec 28 16:28:32 2014
> > @@ -143,7 +143,8 @@ void Parser::ParseGNUAttributes(ParsedAt
> >          continue;
> >
> >        // Expect an identifier or declaration specifier (const, int,
> etc.)
> > -      if (Tok.isNot(tok::identifier) && !isDeclarationSpecifier())
> > +      if (Tok.isNot(tok::identifier) && !isTypeQualifier() &&
> > +          !isKnownToBeTypeSpecifier(Tok))
> >          break;
> >
> >        IdentifierInfo *AttrName = Tok.getIdentifierInfo();
> >
> > Modified: cfe/trunk/test/Parser/cxx-attributes.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-attributes.cpp?rev=224903&r1=224902&r2=224903&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Parser/cxx-attributes.cpp (original)
> > +++ cfe/trunk/test/Parser/cxx-attributes.cpp Sun Dec 28 16:28:32 2014
> > @@ -20,3 +20,5 @@ namespace PR17666 {
> >    typedef int __attribute__((aligned(int(1)))) T1;
> >    typedef int __attribute__((aligned(int))) T2; // expected-error
> {{expected '(' for function-style cast}}
> >  }
> > +
> > +__attribute((typename)) int x; // expected-error {{expected ')'}}
> >
> > Modified: cfe/trunk/test/Parser/namespace-alias-attr.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/namespace-alias-attr.cpp?rev=224903&r1=224902&r2=224903&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Parser/namespace-alias-attr.cpp (original)
> > +++ cfe/trunk/test/Parser/namespace-alias-attr.cpp Sun Dec 28 16:28:32
> 2014
> > @@ -4,5 +4,5 @@ namespace A
> >  {
> >  }
> >
> > -namespace B __attribute__ (( static )) = A; //
> expected-error{{attributes cannot be specified on namespace alias}}
> > +namespace B __attribute__ (( const )) = A; //
> expected-error{{attributes cannot be specified on namespace alias}}
>
> Also, while I'm at it... why did this test change in this way?
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150103/151e2f90/attachment.html>


More information about the cfe-commits mailing list