From: Benjamin Kramer Date: Sun, 29 Mar 2015 16:42:06 +0000 (+0000) Subject: [parser] Push _Atomic locs through DeclaratorChunk. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d7fe73daa9f060ace98bf644ee3aa37bcc29e35;p=clang [parser] Push _Atomic locs through DeclaratorChunk. Otherwise it stays uninitialized with potentially catastrophic results. Found by afl-fuzz. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233494 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 03c3427d68..de39d83bde 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1415,7 +1415,8 @@ struct DeclaratorChunk { static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, - SourceLocation RestrictQualLoc) { + SourceLocation RestrictQualLoc, + SourceLocation AtomicQualLoc) { DeclaratorChunk I; I.Kind = Pointer; I.Loc = Loc; @@ -1423,6 +1424,7 @@ struct DeclaratorChunk { I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding(); I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding(); I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding(); + I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding(); I.Ptr.AttrList = nullptr; return I; } diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 5726fb622c..8f4afdf903 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -4782,7 +4782,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, D.AddTypeInfo(DeclaratorChunk::getPointer(DS.getTypeQualifiers(), Loc, DS.getConstSpecLoc(), DS.getVolatileSpecLoc(), - DS.getRestrictSpecLoc()), + DS.getRestrictSpecLoc(), + DS.getAtomicSpecLoc()), DS.getAttributes(), SourceLocation()); else diff --git a/test/Parser/atomic.c b/test/Parser/atomic.c index 07a83dddcd..e435518d85 100644 --- a/test/Parser/atomic.c +++ b/test/Parser/atomic.c @@ -36,3 +36,5 @@ typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int; struct S _Atomic atomic_s_no_missing_semicolon; + +int *const _Atomic atomic_return_type();