r212631 - Sema: Allow aliases to have incomplete type
David Majnemer
david.majnemer at gmail.com
Wed Jul 9 10:15:52 PDT 2014
Author: majnemer
Date: Wed Jul 9 12:15:52 2014
New Revision: 212631
URL: http://llvm.org/viewvc/llvm-project?rev=212631&view=rev
Log:
Sema: Allow aliases to have incomplete type
gcc supports this behavior and it is pervasively used inside the Linux
kernel.
Note that both gcc and clang will reject code that attempts to do this
in a C++ language mode.
This fixes PR17998.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/attr-alias-elf.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=212631&r1=212630&r2=212631&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 9 12:15:52 2014
@@ -8897,11 +8897,13 @@ void Sema::ActOnUninitializedDecl(Decl *
if (Var->isInvalidDecl())
return;
- if (RequireCompleteType(Var->getLocation(),
- Context.getBaseElementType(Type),
- diag::err_typecheck_decl_incomplete_type)) {
- Var->setInvalidDecl();
- return;
+ if (!Var->hasAttr<AliasAttr>()) {
+ if (RequireCompleteType(Var->getLocation(),
+ Context.getBaseElementType(Type),
+ diag::err_typecheck_decl_incomplete_type)) {
+ Var->setInvalidDecl();
+ return;
+ }
}
// The variable can not have an abstract class type.
Modified: cfe/trunk/test/Sema/attr-alias-elf.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-alias-elf.c?rev=212631&r1=212630&r2=212631&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-alias-elf.c (original)
+++ cfe/trunk/test/Sema/attr-alias-elf.c Wed Jul 9 12:15:52 2014
@@ -64,3 +64,6 @@ void test3_foo() __attribute__((alias("t
__attribute__((section("test"))) void test4_bar() { }
void test4_foo() __attribute__((section("test")));
void test4_foo() __attribute__((alias("test4_bar")));
+
+int test5_bar = 0;
+extern struct incomplete_type test5_foo __attribute__((alias("test5_bar")));
More information about the cfe-commits
mailing list