]> granicus.if.org Git - clang/commitdiff
Downgrade error "static declaration of 'foo' follows non-static declaration" to a...
authorFrancois Pichet <pichet2000@gmail.com>
Fri, 22 Apr 2011 08:14:00 +0000 (08:14 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Fri, 22 Apr 2011 08:14:00 +0000 (08:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129985 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index b72ef6fed55bb74601866a8906bd23a359c287ec..6e2a50fa8aa0aa163f1de06ba03a6760eae4764c 100644 (file)
@@ -2124,6 +2124,8 @@ def err_inline_declaration_block_scope : Error<
   "inline declaration of %0 not allowed in block scope">;
 def err_static_non_static : Error<
   "static declaration of %0 follows non-static declaration">;
+def warn_static_non_static : ExtWarn<
+  "static declaration of %0 follows non-static declaration">;
 def err_non_static_static : Error<
   "non-static declaration of %0 follows static declaration">;
 def err_extern_non_extern : Error<
index 73f25a95c6d47af6e4451e06ea80bed7ff6a1d89..4e31d03e0e9f993f9d8540b8353e08cd5cff9789 100644 (file)
@@ -1258,8 +1258,10 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
       New->getStorageClass() == SC_Static &&
       Old->getStorageClass() != SC_Static &&
       !canRedefineFunction(Old, getLangOptions())) {
-    Diag(New->getLocation(), diag::err_static_non_static)
-      << New;
+    unsigned DiagID = diag::err_static_non_static;
+    if (getLangOptions().Microsoft)
+      DiagID = diag::warn_static_non_static;
+    Diag(New->getLocation(), DiagID) << New;
     Diag(Old->getLocation(), PrevDiag);
     return true;
   }
index c2a32b4c40707f81313bfd0a87046f09f26e7a42..2d620b6da62083439b5f3953e5f2adb93b7a4593 100644 (file)
@@ -167,4 +167,16 @@ public:
    Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
  };
 
+}
+
+
+
+
+extern void static_func();
+void static_func(); // expected-note {{previous declaration is here}}
+
+
+static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
+{
+
 }
\ No newline at end of file