From: David Majnemer Date: Wed, 9 Jul 2014 17:15:52 +0000 (+0000) Subject: Sema: Allow aliases to have incomplete type X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48f80aa9abf55d5a2e195e2e8a58fb6e12f3887c;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212631 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 82d28fa082..13a77f15eb 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8897,11 +8897,13 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl, if (Var->isInvalidDecl()) return; - if (RequireCompleteType(Var->getLocation(), - Context.getBaseElementType(Type), - diag::err_typecheck_decl_incomplete_type)) { - Var->setInvalidDecl(); - return; + if (!Var->hasAttr()) { + 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. diff --git a/test/Sema/attr-alias-elf.c b/test/Sema/attr-alias-elf.c index 04d13924ac..f14514dccd 100644 --- a/test/Sema/attr-alias-elf.c +++ b/test/Sema/attr-alias-elf.c @@ -64,3 +64,6 @@ void test3_foo() __attribute__((alias("test3_bar"))); __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")));