On Jan 25, 2013, at 2:22 PM, Nick Lewycky <[email protected]> wrote:

> On 25 January 2013 10:18, Douglas Gregor <[email protected]> wrote:
> 
> On Jan 25, 2013, at 2:32 AM, Nick Lewycky <[email protected]> wrote:
> 
> > This patch fixes a problem where the PCH fails to faithfully represent the 
> > state of Sema, causing it to drop some -Wundefined-internal diagnostics 
> > across PCH boundaries.
> >
> > While there I noticed that KnownNamespaces was being emitted in an 
> > indeterminate order and added code to sort them deterministically.
> >
> > Please review!
> 
> (Quoting patches on a phone is awful)
> 
> Serialization bits look good.
> 
> Rather than sorting based on source location, how about just changing Sema's 
> data structures for both of these to MapVectors?
> 
> Done.
> 
> Also, I'd rather not renumber the record codes. It's fine to just append to 
> the list, because order is irrelevant.
> 
> Done.
> 
> Updated patch attached. Please review!

Index: test/PCH/undefined-internal.c
===================================================================
--- test/PCH/undefined-internal.c       (revision 0)
+++ test/PCH/undefined-internal.c       (revision 0)
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-pch %S/Inputs/undefined-internal-1.h -o %t
+// RUN: %clang_cc1 -include-pch %t %s -verify
+
+static void g() {}
+
+// expected-warning@1{{function 'f' has internal linkage but is not defined}}
+// expected-note@4{{used here}}
Index: test/PCH/Inputs/undefined-internal-1.h
===================================================================
--- test/PCH/Inputs/undefined-internal-1.h      (revision 0)
+++ test/PCH/Inputs/undefined-internal-1.h      (revision 0)
@@ -0,0 +1,6 @@
+static void f();
+static void g();
+void h() {
+  f();
+  g();
+}

You can use #define tricks to collapse this into a single .c file, rather than 
having a separate .h file, e.g.,

// RUN: %clang_cc1 -emit-pch %s -o %t
// RUN: %clang_cc1 -include-pch %t %s -verify
#ifndef HEADER_H
#define HEADER_H
static void f();
static void g();
void h() {
  f();
  g();
}
#else
static void g()

// expected-warning@NNN{{function 'f' has internal linkage but is not defined}}
// expected-note@MMM{{used here}}
#endif

With that tweak, LGTM.

        - Doug

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to