summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-01-15 04:36:32 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-01-15 04:36:32 +0000
commit2c485a700322e73783bc6543e419fbb861fcb768 (patch)
tree4074303a211ffb87ac8669b27735bb42e762dd23 /clang/lib/Sema/SemaDeclAttr.cpp
parentd51e9933b6aaa6d99efe871bf6a73c0484e317b9 (diff)
downloadbcm5719-llvm-2c485a700322e73783bc6543e419fbb861fcb768.tar.gz
bcm5719-llvm-2c485a700322e73783bc6543e419fbb861fcb768.zip
PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration, by Denis Zobnin
Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which includes FunctionDecl and EnumConstantDecl), emit an error if this attribute is used with function declarations and enum constants. Differential Revision: http://reviews.llvm.org/D16112 llvm-svn: 257868
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index dcd7fd1ec48..f670b52d0d2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3391,13 +3391,8 @@ static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
QualType OldTy;
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
OldTy = TD->getUnderlyingType();
- else if (ValueDecl *VD = dyn_cast<ValueDecl>(D))
- OldTy = VD->getType();
- else {
- S.Diag(D->getLocation(), diag::err_attr_wrong_decl)
- << Attr.getName() << Attr.getRange();
- return;
- }
+ else
+ OldTy = cast<VarDecl>(D)->getType();
// Base type can also be a vector type (see PR17453).
// Distinguish between base type and base element type.
@@ -3470,7 +3465,7 @@ static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
else
- cast<ValueDecl>(D)->setType(NewTy);
+ cast<VarDecl>(D)->setType(NewTy);
D->addAttr(::new (S.Context)
ModeAttr(Attr.getRange(), S.Context, Name,
OpenPOWER on IntegriCloud