summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-07-09 17:15:52 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-07-09 17:15:52 +0000
commit837d5de330389df3dbadb68c1e339e634081dc74 (patch)
tree7c853b3e4ccc39ef23f722757b3cddf2469536eb
parent3ddcd314f25060dafefcf6c5142f1fe49d37f9fb (diff)
downloadbcm5719-llvm-837d5de330389df3dbadb68c1e339e634081dc74.tar.gz
bcm5719-llvm-837d5de330389df3dbadb68c1e339e634081dc74.zip
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. llvm-svn: 212631
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
-rw-r--r--clang/test/Sema/attr-alias-elf.c3
2 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 82d28fa0827..13a77f15eb2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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<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.
diff --git a/clang/test/Sema/attr-alias-elf.c b/clang/test/Sema/attr-alias-elf.c
index 04d13924ac1..f14514dccd2 100644
--- a/clang/test/Sema/attr-alias-elf.c
+++ b/clang/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")));
OpenPOWER on IntegriCloud