summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-10-22 13:51:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-10-22 13:51:06 +0000
commit0fad0d7724339d9397ad55ec6c9580a9236dad17 (patch)
treec51f274d1fa587baad76553c95711d6290a843ba /clang/lib/Sema/SemaDeclAttr.cpp
parentacf49f31b6d4fd1589bd47600ec7fc956e18750a (diff)
downloadbcm5719-llvm-0fad0d7724339d9397ad55ec6c9580a9236dad17.tar.gz
bcm5719-llvm-0fad0d7724339d9397ad55ec6c9580a9236dad17.zip
This patch causes clang to reject alias attributes that point to undefined
names. For example, with this patch we now reject void f1(void) __attribute__((alias("g1"))); This patch is implemented in CodeGen. It is quiet a bit simpler and more compatible with gcc than implementing it in Sema. The downside is that the errors only fire during -emit-llvm. llvm-svn: 193161
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index a71d3c0d7b5..a08abd9efcf 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5020,6 +5020,13 @@ void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W) {
W.setUsed(true);
if (W.getAlias()) { // clone decl, impersonate __attribute(weak,alias(...))
IdentifierInfo *NDId = ND->getIdentifier();
+
+ // FIXME: we should reject this (pr17640).
+ NamedDecl *Aliasee = LookupSingleName(TUScope, W.getAlias(),
+ W.getLocation(), LookupOrdinaryName);
+ if (Aliasee && Aliasee->hasAttr<AliasAttr>())
+ return;
+
NamedDecl *NewD = DeclClonePragmaWeak(ND, W.getAlias(), W.getLocation());
NewD->addAttr(::new (Context) AliasAttr(W.getLocation(), Context,
NDId->getName()));
OpenPOWER on IntegriCloud