diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-16 23:11:15 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-16 23:11:15 +0000 |
| commit | f1d2f0ea21a5a66864da5cd8d39404df5b3fd652 (patch) | |
| tree | fce2167eb760cedd2d50ac60a7b518cae65912ac /clang/test | |
| parent | 3302f2bd466930e094f0197e35835525dcfe7437 (diff) | |
| download | bcm5719-llvm-f1d2f0ea21a5a66864da5cd8d39404df5b3fd652.tar.gz bcm5719-llvm-f1d2f0ea21a5a66864da5cd8d39404df5b3fd652.zip | |
Check for internal weak decls after merging.
This fixes pr14946. The problem was that the linkage computation was done too
early, so things like "extern int a;" would be given external linkage, even if
a previous declaration was static.
llvm-svn: 172667
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/attr-weak.c | 6 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-weak.cpp | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Sema/attr-weak.c b/clang/test/Sema/attr-weak.c index adedf1231f9..df74554487e 100644 --- a/clang/test/Sema/attr-weak.c +++ b/clang/test/Sema/attr-weak.c @@ -16,3 +16,9 @@ static int x __attribute__((weak)); // expected-error {{weak declaration cannot // rdar://9538608 int C; // expected-note {{previous definition is here}} extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}} + +static int pr14946_x; +extern int pr14946_x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} + +static void pr14946_f(); +void pr14946_f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} diff --git a/clang/test/SemaCXX/attr-weak.cpp b/clang/test/SemaCXX/attr-weak.cpp index b6a9e0aa840..8939a28d75e 100644 --- a/clang/test/SemaCXX/attr-weak.cpp +++ b/clang/test/SemaCXX/attr-weak.cpp @@ -21,9 +21,16 @@ namespace { }; } +// GCC rejects the instantiation with the internal type, but some existing +// code expects it. It is also not that different from giving hidden visibility +// to parts of a template that have explicit default visibility, so we accept +// this. template <class T> struct Test7 { void test7() __attribute__((weak)) {} + static int var __attribute__((weak)); }; +template <class T> +int Test7<T>::var; namespace { class Internal; } template struct Test7<Internal>; template struct Test7<int>; |

