diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-02-25 00:05:02 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-02-25 00:05:02 +0000 |
commit | 4322a2864e866e3cbc3f65bfbef5315acf66c56f (patch) | |
tree | 50c467d522acb9eab53c9dd3ce2c36979b55ec10 /clang/test/SemaCXX/linkage.cpp | |
parent | dfdca1a14db80a508bfec8062d670a9ed9853cb1 (diff) | |
download | bcm5719-llvm-4322a2864e866e3cbc3f65bfbef5315acf66c56f.tar.gz bcm5719-llvm-4322a2864e866e3cbc3f65bfbef5315acf66c56f.zip |
Fix the rest of PR9316 along with some other bugs spotted by inspection.
I tried to add test cases for these, but I can't because variables
aren't warned on the way functions are and the codegen layer appears to
use different logic for determining that 'a' and 'g' in the test case
should receive C mangling. I've included the test so that if we ever
switch the codegen layer to use these functions, we won't regress due to
latent bugs.
llvm-svn: 126453
Diffstat (limited to 'clang/test/SemaCXX/linkage.cpp')
-rw-r--r-- | clang/test/SemaCXX/linkage.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/linkage.cpp b/clang/test/SemaCXX/linkage.cpp index b93a310b00f..6b73d596e01 100644 --- a/clang/test/SemaCXX/linkage.cpp +++ b/clang/test/SemaCXX/linkage.cpp @@ -3,7 +3,7 @@ // compared against the earlier cached value. If we had a way of // testing linkage directly in Sema, that would be better. -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -Werror -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s // PR8926 namespace test0 { @@ -69,5 +69,28 @@ namespace { extern "C" void test4(void) {} } +// PR9316: Ensure that even non-namespace-scope function declarations in +// a C declaration context respect that over the anonymous namespace. +extern "C" { + namespace { + struct X { + int f() { + extern int g(); + extern int a; + + // Test both for mangling in the code generation and warnings from use + // of internal, undefined names via -Werror. + // CHECK: call i32 @g( + // CHECK: load i32* @a, + return g() + a; + } + }; + } + // Force the above function to be emitted by codegen. + int test(X& x) { + return x.f(); + } +} + // CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv( // CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv( |