aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-17 02:55:50 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-17 02:55:50 +0000
commit8158f692571ba5eaae19e086b76d19319ac503c5 (patch)
tree7ab66b15337277806041214102bface5293af650
parent7d791fd22efd3649f23616ba00b9e98076c27ad4 (diff)
Warn about typedefs of enums without any declarator name. Fixes rdar://problem/6503878
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62397 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticKinds.def4
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/Sema/enum.c3
3 files changed, 8 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 040e36b5c4..e1f0685d74 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -599,8 +599,8 @@ DIAG(err_expected_unqualified_id, ERROR,
"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,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 7346526265..82c8ea099d 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -741,9 +741,9 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
// 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;
}
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index b42036dc02..ea66c27aef 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -63,3 +63,6 @@ void foo() {
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}}