]> granicus.if.org Git - clang/commitdiff
Don't warn for undefined but used decls that are external because of a typedef.
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 29 Dec 2012 23:43:00 +0000 (23:43 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 29 Dec 2012 23:43:00 +0000 (23:43 +0000)
This fixes pr14736. It is fairly ugly, but I don't think we can do much better
as we have to wait at least until the end of the typedef to know if the
function will have external linkage or not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171240 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp
test/SemaCXX/undefined-internal.cpp

index 4b82069a62452ab6e7f78097ddf375faa4db843b..0c5e8db1aa80971f44c47fcd35951ef876d16162 100644 (file)
@@ -394,6 +394,9 @@ static void checkUndefinedInternals(Sema &S) {
     // Ignore attributes that have become invalid.
     if (decl->isInvalidDecl()) continue;
 
+    // If we found out that the decl is external, don't warn.
+    if (decl->getLinkage() == ExternalLinkage) continue;
+
     // __attribute__((weakref)) is basically a definition.
     if (decl->hasAttr<WeakRefAttr>()) continue;
 
index 154172001e76c7e0440fc524f65457696512cbaf..e8ee4c1e90702fb61212b3f0fb6c6f1d7ad5b69c 100644 (file)
@@ -181,3 +181,21 @@ namespace OverloadUse {
   template<void x(int)> void t(long*) { x(10); } // expected-note {{used here}}
   void g() { long a; t<f>(&a); }
 }
+
+namespace test7 {
+  typedef struct {
+    void bar();
+    void foo() {
+      bar();
+    }
+  } A;
+}
+
+namespace test8 {
+  typedef struct {
+    void bar(); // expected-warning {{function 'test8::<anonymous struct>::bar' has internal linkage but is not defined}}
+    void foo() {
+      bar(); // expected-note {{used here}}
+    }
+  } *A;
+}