[cfe-commits] r62397 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDecl.cpp test/Sema/enum.c
Douglas Gregor
dgregor at apple.com
Fri Jan 16 18:55:50 PST 2009
Author: dgregor
Date: Fri Jan 16 20:55:50 2009
New Revision: 62397
URL: http://llvm.org/viewvc/llvm-project?rev=62397&view=rev
Log:
Warn about typedefs of enums without any declarator name. Fixes rdar://problem/6503878
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=62397&r1=62396&r2=62397&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Jan 16 20:55:50 2009
@@ -599,8 +599,8 @@
"expected unqualified-id")
DIAG(err_no_declarators, ERROR,
"declaration does not declare anything")
-DIAG(ext_no_declarators, EXTENSION,
- "typedef without a name is a Microsoft extension")
+DIAG(warn_no_declarators, WARNING,
+ "typedef requires a name")
DIAG(err_func_def_no_params, ERROR,
"function definition does not declare parameters")
DIAG(err_expected_lparen_after_type, ERROR,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=62397&r1=62396&r2=62397&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 16 20:55:50 2009
@@ -741,9 +741,9 @@
// Permit typedefs without declarators as a Microsoft extension.
if (!DS.isMissingDeclaratorOk()) {
- if (getLangOptions().Microsoft &&
- DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
- Diag(DS.getSourceRange().getBegin(), diag::ext_no_declarators)
+ if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef &&
+ Tag && isa<EnumDecl>(Tag)) {
+ Diag(DS.getSourceRange().getBegin(), diag::warn_no_declarators)
<< DS.getSourceRange();
return Tag;
}
Modified: cfe/trunk/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=62397&r1=62396&r2=62397&view=diff
==============================================================================
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Fri Jan 16 20:55:50 2009
@@ -63,3 +63,6 @@
enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
}
+
+// <rdar://problem/6503878>
+typedef enum { X = 0 }; // expected-warning{{typedef requires a name}}
More information about the cfe-commits
mailing list