forked from OSchip/llvm-project
Disallow extern decls of type void in C++ mode
C++ and C differ with respect to the handling of extern void declarations. Enforce the C++ behavior in C++ mode. llvm-svn: 182814
This commit is contained in:
parent
0e46dbd119
commit
0ffa331789
|
@ -5271,11 +5271,15 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
|
|||
NewVD->setTypeSourceInfo(FixedTInfo);
|
||||
}
|
||||
|
||||
if (T->isVoidType() && NewVD->isThisDeclarationADefinition()) {
|
||||
Diag(NewVD->getLocation(), diag::err_typecheck_decl_incomplete_type)
|
||||
<< T;
|
||||
NewVD->setInvalidDecl();
|
||||
return;
|
||||
if (T->isVoidType()) {
|
||||
// C++98 [dcl.stc]p5: The extern specifier can be applied only to the names
|
||||
// of objects and functions.
|
||||
if (NewVD->isThisDeclarationADefinition() || getLangOpts().CPlusPlus) {
|
||||
Diag(NewVD->getLocation(), diag::err_typecheck_decl_incomplete_type)
|
||||
<< T;
|
||||
NewVD->setInvalidDecl();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NewVD->hasLocalStorage() && NewVD->hasAttr<BlocksAttr>()) {
|
||||
|
|
|
@ -114,3 +114,5 @@ namespace pr14958 {
|
|||
}
|
||||
int js::ObjectClass;
|
||||
}
|
||||
|
||||
extern "C" void PR16167; // expected-error {{variable has incomplete type 'void'}}
|
||||
|
|
|
@ -149,6 +149,6 @@ namespace PR6830 {
|
|||
}
|
||||
|
||||
namespace pr12339 {
|
||||
extern "C" void i;
|
||||
extern "C" void i; // expected-error{{variable has incomplete type 'void'}}
|
||||
pr12339::FOO // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
|
||||
} // expected-error{{expected unqualified-id}}
|
||||
|
|
Loading…
Reference in New Issue