From 0fad0d7724339d9397ad55ec6c9580a9236dad17 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 22 Oct 2013 13:51:06 +0000 Subject: 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 --- clang/lib/Sema/SemaDeclAttr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/Sema/SemaDeclAttr.cpp') 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()) + return; + NamedDecl *NewD = DeclClonePragmaWeak(ND, W.getAlias(), W.getLocation()); NewD->addAttr(::new (Context) AliasAttr(W.getLocation(), Context, NDId->getName())); -- cgit v1.2.3