]> granicus.if.org Git - clang/commitdiff
Butcher a perfectly reasonable diagnostic to pacify old versions of SWIG.
authorChandler Carruth <chandlerc@gmail.com>
Fri, 16 Jul 2010 04:32:28 +0000 (04:32 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 16 Jul 2010 04:32:28 +0000 (04:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108505 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/SemaCXX/nested-name-spec.cpp

index 49077513c137e21f00ee41f9ee0d0d41b19493cb..8e4a389f4afdeaa9917984f0f08c2f3d9300e114 100644 (file)
@@ -72,6 +72,7 @@ def NonNull : DiagGroup<"nonnull">;
 def : DiagGroup<"nonportable-cfstrings">;
 def : DiagGroup<"non-virtual-dtor">;
 def : DiagGroup<"old-style-definition">;
+def OutOfLineDeclaration : DiagGroup<"out-of-line-declaration">;
 def : DiagGroup<"overflow">;
 def : DiagGroup<"overloaded-virtual">;
 def : DiagGroup<"packed">;
index e854674750deec83e68c7acbbb53efd988c54207..1105204436fd45e237de6b4f334bde3fe845c9d1 100644 (file)
@@ -2048,8 +2048,9 @@ def err_qualified_typedef_declarator : Error<
   "typedef declarator cannot be qualified">;
 def err_qualified_param_declarator : Error<
   "parameter declarator cannot be qualified">;
-def err_out_of_line_declaration : Error<
-  "out-of-line declaration of a member must be a definition">;
+def ext_out_of_line_declaration : ExtWarn<
+  "out-of-line declaration of a member must be a definition">,
+  InGroup<OutOfLineDeclaration>;
 def note_member_def_close_match : Note<"member declaration nearly matches">;
 def err_typecheck_ivar_variable_size : Error<
   "instance variables must have a constant size">;
index 76cb90565b384853bae6635d70bba1b295921cae..538d56470fdabdc5ba338f7887e9764208c866e0 100644 (file)
@@ -3479,14 +3479,14 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
     // definition (C++ [dcl.meaning]p1).
     // Note that this is not the case for explicit specializations of
     // function templates or member functions of class templates, per
-    // C++ [temp.expl.spec]p2.
+    // C++ [temp.expl.spec]p2. We also allow these declarations as an extension
+    // for compatibility with old SWIG code which likes to generate them.
     if (!IsFunctionDefinition && !isFriend &&
         !isFunctionTemplateSpecialization && !isExplicitSpecialization) {
-      Diag(NewFD->getLocation(), diag::err_out_of_line_declaration)
+      Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration)
         << D.getCXXScopeSpec().getRange();
-      NewFD->setInvalidDecl();
-    } else if (!Redeclaration && 
-               !(isFriend && CurContext->isDependentContext())) {
+    }
+    if (!Redeclaration && !(isFriend && CurContext->isDependentContext())) {
       // The user tried to provide an out-of-line definition for a
       // function that is a member of a class or namespace, but there
       // was no such member function declared (C++ [class.mfct]p2,
index 0dc1097e3867a737738a82d63c197f12cc0c2544..acdec6183ed84d9e396aa3668f1430c5a2edabb8 100644 (file)
@@ -102,7 +102,7 @@ void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualif
 
 int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
 
-void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}
+void A2::CC::NC::m(); // expected-warning{{out-of-line declaration of a member must be a definition}}
 
 
 namespace E {