summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-05-03 03:16:07 +0000
committerNico Weber <nicolasweber@gmx.de>2019-05-03 03:16:07 +0000
commitecefe8a46344839f5272956a045e6f500f0a927e (patch)
treea31ccf9a048be3edaffd2f157bc00f95c8af64b4
parent6aecacbb8d3d7322d588b528a34a0425444dfafd (diff)
Revert r359814 "[Sema] Emit warning for visibility attribute on internal-linkage declaration"
See cfe-commits thread for r359814. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359858 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--lib/Sema/SemaDeclAttr.cpp8
-rw-r--r--test/Sema/attr-visibility.c6
-rw-r--r--test/SemaCXX/ast-print.cpp2
-rw-r--r--test/SemaCXX/attr-visibility.cpp6
5 files changed, 2 insertions, 23 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 229df8f25f..cccc9e4aa0 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2778,9 +2778,6 @@ def warn_attribute_ignored : Warning<"%0 attribute ignored">,
def warn_attribute_ignored_on_inline :
Warning<"%0 attribute ignored on inline function">,
InGroup<IgnoredAttributes>;
-def warn_attribute_ignored_on_non_external :
- Warning<"%0 attribute is ignored on a non-external symbol">,
- InGroup<IgnoredAttributes>;
def warn_nocf_check_attribute_ignored :
Warning<"'nocf_check' attribute ignored; use -fcf-protection to enable the attribute">,
InGroup<IgnoredAttributes>;
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 1da852e7d4..f8a34573f3 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -2615,14 +2615,6 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL,
return;
}
- // Visibility attributes have no effect on symbols with internal linkage.
- if (const auto *ND = dyn_cast<NamedDecl>(D)) {
- if (!ND->isExternallyVisible())
- S.Diag(AL.getRange().getBegin(),
- diag::warn_attribute_ignored_on_non_external)
- << AL;
- }
-
// Check that the argument is a string literal.
StringRef TypeStr;
SourceLocation LiteralLoc;
diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c
index 792721a1ac..798d6dcd78 100644
--- a/test/Sema/attr-visibility.c
+++ b/test/Sema/attr-visibility.c
@@ -26,9 +26,3 @@ typedef int __attribute__((visibility("default"))) bar; // expected-warning {{'v
int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
int PR17105 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}}
-
-static int test8 __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
-static int test9 __attribute__((visibility("hidden"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
-static int test10 __attribute__((visibility("internal"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
-
-static int test11() __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp
index 6d53e60420..fd1d3fe84f 100644
--- a/test/SemaCXX/ast-print.cpp
+++ b/test/SemaCXX/ast-print.cpp
@@ -209,8 +209,10 @@ void test(int i) {
}
}
+namespace {
// CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
struct [[gnu::visibility("hidden")]] S;
+}
// CHECK: struct CXXFunctionalCastExprPrint {
// CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
diff --git a/test/SemaCXX/attr-visibility.cpp b/test/SemaCXX/attr-visibility.cpp
index 1610631a71..05aa5a33c7 100644
--- a/test/SemaCXX/attr-visibility.cpp
+++ b/test/SemaCXX/attr-visibility.cpp
@@ -18,9 +18,3 @@ void foo<int>() {
struct x3 {
static int y;
} __attribute((visibility("default"))); // expected-warning {{attribute 'visibility' after definition is ignored}}
-
-const int test4 __attribute__((visibility("default"))) = 0; // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
-
-namespace {
- int test5 __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
-};