[cfe-commits] r113716 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaCXX/MicrosoftExtensions.cpp
Francois Pichet
pichet2000 at gmail.com
Sat Sep 11 22:06:55 PDT 2010
Author: fpichet
Date: Sun Sep 12 00:06:55 2010
New Revision: 113716
URL: http://llvm.org/viewvc/llvm-project?rev=113716&view=rev
Log:
Add basic support for Microsoft enum forward declaration.
Assigning an underlying integral type to an enum forward declaration will come in a next patch.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=113716&r1=113715&r2=113716&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Sep 12 00:06:55 2010
@@ -1780,6 +1780,8 @@
"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>;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=113716&r1=113715&r2=113716&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Sep 12 00:06:55 2010
@@ -5755,9 +5755,12 @@
<< 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 {
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=113716&r1=113715&r2=113716&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Sun Sep 12 00:06:55 2010
@@ -84,3 +84,7 @@
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;
More information about the cfe-commits
mailing list