Add basic support for Microsoft enum forward declaration.

Assigning an underlying integral type to an enum forward declaration will come in a next patch.

llvm-svn: 113716
This commit is contained in:
Francois Pichet 2010-09-12 05:06:55 +00:00
parent 86ddae50f6
commit 488b4a7d94
3 changed files with 12 additions and 3 deletions

View File

@ -1780,6 +1780,8 @@ def ext_forward_ref_enum : Extension<
"ISO C forbids forward references to 'enum' types">;
def err_forward_ref_enum : Error<
"ISO C++ forbids forward references to 'enum' types">;
def ext_ms_forward_ref_enum : Extension<
"forward references to 'enum' types are a Microsoft extension">, InGroup<Microsoft>;
def ext_forward_ref_enum_def : Extension<
"redeclaration of already-defined enum %0 is a GNU extension">, InGroup<GNU>;

View File

@ -5755,9 +5755,12 @@ CreateNewDecl:
<< New;
Diag(Def->getLocation(), diag::note_previous_definition);
} else {
Diag(Loc,
getLangOptions().CPlusPlus? diag::err_forward_ref_enum
: diag::ext_forward_ref_enum);
unsigned DiagID = diag::ext_forward_ref_enum;
if (getLangOptions().Microsoft)
DiagID = diag::ext_ms_forward_ref_enum;
else if (getLangOptions().CPlusPlus)
DiagID = diag::err_forward_ref_enum;
Diag(Loc, DiagID);
}
}
} else {

View File

@ -84,3 +84,7 @@ void m1() {
h1<int>(&M::addP);
h1(&M::subtractP);
}
//MSVC allows forward enum declaration
enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
ENUM *var;