]> granicus.if.org Git - clang/commitdiff
Warn about typedefs of enums without any declarator name. Fixes rdar://problem/6503878
authorDouglas Gregor <dgregor@apple.com>
Sat, 17 Jan 2009 02:55:50 +0000 (02:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 17 Jan 2009 02:55:50 +0000 (02:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62397 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDecl.cpp
test/Sema/enum.c

index 040e36b5c40514df503fe2d17dbd8d69165a9a7e..e1f0685d7422ba4f43746c221fca85ba4ed45184 100644 (file)
@@ -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,
index 734652626596a20174dcd02f67be83de688ee463..82c8ea099d19ec760064e7145d994fbacf19528a 100644 (file)
@@ -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;
     }
index b42036dc02ed1deb9007c7c0ff7e8ee5b78fca7d..ea66c27aeff1ebee99785297d216a8deaca2a869 100644 (file)
@@ -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}}