]> granicus.if.org Git - clang/commitdiff
Fix PR15845: apparently MSVC does not support implicit int in C++ mode.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 30 Apr 2013 22:43:51 +0000 (22:43 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 30 Apr 2013 22:43:51 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180822 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
lib/Sema/DeclSpec.cpp
lib/Sema/SemaType.cpp
test/Rewriter/rewrite-byref-in-nested-blocks.mm
test/Sema/MicrosoftCompatibility.cpp [new file with mode: 0644]

index d786ce23d00c9386dc4d0b9dc24895293cd7da21..2f0c1a3b8da70186ab29ebde776a811ab7dd9872 100644 (file)
@@ -2038,10 +2038,9 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
   // error, do lookahead to try to do better recovery. This never applies
   // within a type specifier. Outside of C++, we allow this even if the
   // language doesn't "officially" support implicit int -- we support
-  // implicit int as an extension in C99 and C11. Allegedly, MS also
-  // supports implicit int in C++ mode.
+  // implicit int as an extension in C99 and C11.
   if (DSC != DSC_type_specifier && DSC != DSC_trailing &&
-      (!getLangOpts().CPlusPlus || getLangOpts().MicrosoftExt) &&
+      !getLangOpts().CPlusPlus &&
       isValidAfterIdentifierInDeclarator(NextToken())) {
     // If this token is valid for implicit int, e.g. "static x = 4", then
     // we just avoid eating the identifier, so it will be parsed as the
index 124f50cabda1c853387c6ce38319cdfbc6419497..3b3ab2c27b4ab6afec4b7188ef8aa51628bd6d46 100644 (file)
@@ -1003,8 +1003,7 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) {
   // the type specifier is not optional, but we got 'auto' as a storage
   // class specifier, then assume this is an attempt to use C++0x's 'auto'
   // type specifier.
-  // FIXME: Does Microsoft really support implicit int in C++?
-  if (PP.getLangOpts().CPlusPlus && !PP.getLangOpts().MicrosoftExt &&
+  if (PP.getLangOpts().CPlusPlus &&
       TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
     TypeSpecType = TST_auto;
     StorageClassSpec = SCS_unspecified;
index 7ed16878dbad3273924d54305c2153255b79dfc1..2503b49a6164b070012cd7f1c1ca6ce51e28cdd8 100644 (file)
@@ -793,9 +793,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
       // "At least one type specifier shall be given in the declaration
       // specifiers in each declaration, and in the specifier-qualifier list in
       // each struct declaration and type name."
-      // FIXME: Does Microsoft really have the implicit int extension in C++?
-      if (S.getLangOpts().CPlusPlus &&
-          !S.getLangOpts().MicrosoftExt) {
+      if (S.getLangOpts().CPlusPlus) {
         S.Diag(DeclLoc, diag::err_missing_type_specifier)
           << DS.getSourceRange();
 
index 022bb5f4e357d302b7a4234b3a006f545cc705e6..f416b6622f455ba7fa538d21eee641b97ffe6493 100644 (file)
@@ -19,7 +19,7 @@ void f(void (^block)(void));
 - (void)foo {
         __block int kerfluffle;
         // radar 7692183
-        __block x; 
+        __block int x;
         f(^{
                 f(^{
                                 y = 42;
diff --git a/test/Sema/MicrosoftCompatibility.cpp b/test/Sema/MicrosoftCompatibility.cpp
new file mode 100644 (file)
index 0000000..15c2558
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+
+// PR15845
+int foo(xxx); // expected-error{{unknown type name}}