]> granicus.if.org Git - clang/commitdiff
[parser] Push _Atomic locs through DeclaratorChunk.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 29 Mar 2015 16:42:06 +0000 (16:42 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 29 Mar 2015 16:42:06 +0000 (16:42 +0000)
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

include/clang/Sema/DeclSpec.h
lib/Parse/ParseDecl.cpp
test/Parser/atomic.c

index 03c3427d68b14153ce81b2f77dc68311064a4c9a..de39d83bded43e5c25bdd7aca4eadade6cc1d5d1 100644 (file)
@@ -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;
   }
index 5726fb622c6a0994f12e97d74179c4852329296c..8f4afdf9034c080b35c7db40c2fc9b5e7254f751 100644 (file)
@@ -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
index 07a83dddcd3c9abf28a1bd8d37045313eabe1bed..e435518d85f4a0e61d942cb9ff7fe705116681ee 100644 (file)
@@ -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();