diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-06-26 06:27:57 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-06-26 06:27:57 +0000 |
| commit | 4b413ea3bfa05d915b355298803c07071951c00e (patch) | |
| tree | 6fc5c29c5ab8c218b00a1b57fc593c43a5725d11 /clang/lib/Sema/SemaDecl.cpp | |
| parent | dd7c10227b862a3de396a3e4a934cb6de6cfed81 (diff) | |
| download | bcm5719-llvm-4b413ea3bfa05d915b355298803c07071951c00e.tar.gz bcm5719-llvm-4b413ea3bfa05d915b355298803c07071951c00e.zip | |
fix a bug handling type attributes in the declspec. declspec processing
used to mutate the attribute list for declspecs when the type was
converted, breaking the case where one declspec was shared by multiple
declarators.
This fixes rdar://6032532.
llvm-svn: 52769
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c2874106f4e..cdcdebae817 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2350,17 +2350,7 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) { diag::err_typecheck_ext_vector_not_typedef); break; case AttributeList::AT_address_space: - if (TypedefDecl *tDecl = dyn_cast<TypedefDecl>(New)) { - QualType newType = HandleAddressSpaceTypeAttribute( - tDecl->getUnderlyingType(), - Attr); - tDecl->setUnderlyingType(newType); - } else if (ValueDecl *vDecl = dyn_cast<ValueDecl>(New)) { - QualType newType = HandleAddressSpaceTypeAttribute(vDecl->getType(), - Attr); - // install the new addr spaced type into the decl - vDecl->setType(newType); - } + // Ignore this, this is a type attribute, handled by ProcessTypeAttributes. break; case AttributeList::AT_mode: if (TypedefDecl *tDecl = dyn_cast<TypedefDecl>(New)) { @@ -2430,10 +2420,25 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) { void Sema::HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix, AttributeList *declarator_postfix) { + if (declspec_prefix == 0 && declarator_postfix == 0) return; + while (declspec_prefix) { HandleDeclAttribute(New, declspec_prefix); declspec_prefix = declspec_prefix->getNext(); } + + // If there are any type attributes that were in the declarator, apply them to + // its top level type. + if (ValueDecl *VD = dyn_cast<ValueDecl>(New)) { + QualType DT = VD->getType(); + ProcessTypeAttributes(DT, declarator_postfix); + VD->setType(DT); + } else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(New)) { + QualType DT = TD->getUnderlyingType(); + ProcessTypeAttributes(DT, declarator_postfix); + TD->setUnderlyingType(DT); + } + while (declarator_postfix) { HandleDeclAttribute(New, declarator_postfix); declarator_postfix = declarator_postfix->getNext(); |

