]> granicus.if.org Git - clang/commitdiff
Permitting typedefs without a name is a Microsoft/GNU extension
authorDouglas Gregor <dgregor@apple.com>
Tue, 13 Jan 2009 23:10:51 +0000 (23:10 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 13 Jan 2009 23:10:51 +0000 (23:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62192 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDecl.cpp

index a9f60d2d630675a08e8ce6b187d927837ef33bc6..52c6cbf2fa681a46d91c064216560cae4720e0f5 100644 (file)
@@ -593,6 +593,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(err_func_def_no_params, ERROR,
      "function definition does not declare parameters")
 DIAG(err_expected_lparen_after_type, ERROR,
index 9b419e5b63c81a3f6e91dff1c9c6d289ed94de89..8d2e5590b98e29bc517a8a2e5f8b2dfb66c04b1a 100644 (file)
@@ -875,7 +875,15 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
       return Tag;
   }
 
+  // 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)
+        << DS.getSourceRange();
+      return Tag;
+    }
+
     // FIXME: This diagnostic is emitted even when various previous
     // errors occurred (see e.g. test/Sema/decl-invalid.c). However,
     // DeclSpec has no means of communicating this information, and the