aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-12-07 15:23:23 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-12-07 15:23:23 +0000
commitf5fe2925b87cf382f2f13983c81679e38067122b (patch)
tree61a8591e8f0a6836c027e8c0d010e14eb2b99bd0
parent9f71a8f4c7a182a5236da9e747d57cc1d1bd24c2 (diff)
Fix PR8720 by printing an error message with a substring that the gcc testsuite searches for.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121137 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaDeclAttr.cpp5
-rw-r--r--test/CodeGen/2008-07-29-override-alias-decl.c2
-rw-r--r--test/CodeGen/pragma-weak.c2
-rw-r--r--test/CodeGenCXX/attr.cpp2
-rw-r--r--test/Sema/attr-alias.c8
-rw-r--r--test/SemaCXX/attr-weakref.cpp2
7 files changed, 19 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index d3c1a50a66..34354ce4fd 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1001,6 +1001,8 @@ def err_attribute_weakref_not_global_context : Error<
"weakref declaration of '%0' must be in a global context">;
def err_attribute_weakref_without_alias : Error<
"weakref declaration of '%0' must also have an alias attribute">;
+def err_alias_not_supported_on_darwin : Error <
+ "only weak aliases are supported on darwin">;
def warn_attribute_wrong_decl_type : Warning<
"%0 attribute only applies to %select{function|union|"
"variable and function|function or method|parameter|"
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 3c4bd8ffc4..e5f27fcfbb 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -675,6 +675,11 @@ static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) {
return;
}
+ if (S.Context.Target.getTriple().getOS() == llvm::Triple::Darwin) {
+ S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin);
+ return;
+ }
+
// FIXME: check if target symbol exists in current file
d->addAttr(::new (S.Context) AliasAttr(Attr.getLoc(), S.Context,
diff --git a/test/CodeGen/2008-07-29-override-alias-decl.c b/test/CodeGen/2008-07-29-override-alias-decl.c
index dbe10b395f..0c2d0c6ca5 100644
--- a/test/CodeGen/2008-07-29-override-alias-decl.c
+++ b/test/CodeGen/2008-07-29-override-alias-decl.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
int x() { return 1; }
diff --git a/test/CodeGen/pragma-weak.c b/test/CodeGen/pragma-weak.c
index 5c2866e3d3..1de60e106a 100644
--- a/test/CodeGen/pragma-weak.c
+++ b/test/CodeGen/pragma-weak.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -verify | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm %s -o - -verify | FileCheck %s
// CHECK: @weakvar = weak global
// CHECK: @__weakvar_alias = common global
diff --git a/test/CodeGenCXX/attr.cpp b/test/CodeGenCXX/attr.cpp
index d689a4fdf4..9e8740e547 100644
--- a/test/CodeGenCXX/attr.cpp
+++ b/test/CodeGenCXX/attr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
// CHECK: @test2 = alias i32 ()* @_Z5test1v
diff --git a/test/Sema/attr-alias.c b/test/Sema/attr-alias.c
new file mode 100644
index 0000000000..151052f89e
--- /dev/null
+++ b/test/Sema/attr-alias.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
+
+void g() {}
+
+// It is important that the following string be in the error message. The gcc
+// testsuite looks for it to decide if a target supports aliases.
+
+void f() __attribute__((alias("g"))); //expected-error {{only weak aliases are supported}}
diff --git a/test/SemaCXX/attr-weakref.cpp b/test/SemaCXX/attr-weakref.cpp
index 5773acc1ab..11368d9399 100644
--- a/test/SemaCXX/attr-weakref.cpp
+++ b/test/SemaCXX/attr-weakref.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
// GCC will accept anything as the argument of weakref. Should we
// check for an existing decl?