[PATCH] D30032: Process attributes 'ifunc' and 'alias' when checking for redefinition
Serge Pavlov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 17 22:15:52 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295541: Process attributes 'ifunc' and 'alias' when checking for redefinition (authored by sepavloff).
Changed prior to commit:
https://reviews.llvm.org/D30032?vs=88700&id=89017#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30032
Files:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/alias-redefinition.c
cfe/trunk/test/Sema/attr-ifunc.c
Index: cfe/trunk/test/Sema/alias-redefinition.c
===================================================================
--- cfe/trunk/test/Sema/alias-redefinition.c
+++ cfe/trunk/test/Sema/alias-redefinition.c
@@ -19,9 +19,8 @@
void fun4(void) __attribute((alias("f4")));
void fun4(void);
-// FIXME: We should produce a special case error for this.
void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 'fun5' cannot also be an alias}}
int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
Index: cfe/trunk/test/Sema/attr-ifunc.c
===================================================================
--- cfe/trunk/test/Sema/attr-ifunc.c
+++ cfe/trunk/test/Sema/attr-ifunc.c
@@ -39,5 +39,9 @@
//expected-error at -1 {{definition with same mangled name as another definition}}
void* f1_ifunc() { return 0; }
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error at -1 {{definition 'f6' cannot also be an ifunc}}
+
#endif
#endif
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -11786,6 +11786,18 @@
else
FD = cast<FunctionDecl>(D);
+ // Check for defining attributes before the check for redefinition.
+ if (const auto *Attr = FD->getAttr<AliasAttr>()) {
+ Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+ FD->dropAttr<AliasAttr>();
+ FD->setInvalidDecl();
+ }
+ if (const auto *Attr = FD->getAttr<IFuncAttr>()) {
+ Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+ FD->dropAttr<IFuncAttr>();
+ FD->setInvalidDecl();
+ }
+
// See if this is a redefinition.
if (!FD->isLateTemplateParsed()) {
CheckForFunctionRedefinition(FD, nullptr, SkipBody);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30032.89017.patch
Type: text/x-patch
Size: 2132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170218/907c4301/attachment.bin>
More information about the cfe-commits
mailing list