Skip to content

Commit

Permalink
Fix PR8720 by printing an error message with a substring that the gcc…
Browse files Browse the repository at this point in the history
… testsuite searches for.

llvm-svn: 121137
  • Loading branch information
espindola committed Dec 7, 2010
1 parent d2f4b09 commit 0017c5f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Expand Up @@ -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|"
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaDeclAttr.cpp
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion clang/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; }

Expand Down
2 changes: 1 addition & 1 deletion clang/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
Expand Down
2 changes: 1 addition & 1 deletion clang/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

Expand Down
8 changes: 8 additions & 0 deletions clang/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}}
2 changes: 1 addition & 1 deletion clang/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?
Expand Down

0 comments on commit 0017c5f

Please sign in to comment.