Skip to content

Commit

Permalink
Add a C2x spelling for the external_source_symbol and internal_linkag…
Browse files Browse the repository at this point in the history
…e attributes in the clang vendor namespace.

Both of these attributes have existing meaning in C code, so there was no reason to exclude them from using the new spelling.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326053 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AaronBallman committed Feb 25, 2018
1 parent d925bc6 commit b8bcd37
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
}

def ExternalSourceSymbol : InheritableAttr {
let Spellings = [Clang<"external_source_symbol">];
let Spellings = [Clang<"external_source_symbol", 1>];
let Args = [StringArgument<"language", 1>,
StringArgument<"definedIn", 1>,
BoolArgument<"generatedDeclaration", 1>];
Expand Down Expand Up @@ -2817,7 +2817,7 @@ def OMPDeclareTargetDecl : Attr {
}

def InternalLinkage : InheritableAttr {
let Spellings = [Clang<"internal_linkage">];
let Spellings = [Clang<"internal_linkage", 1>];
let Subjects = SubjectList<[Var, Function, CXXRecord]>;
let Documentation = [InternalLinkageDocs];
}
14 changes: 13 additions & 1 deletion test/Sema/attr-external-source-symbol.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s

void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));

Expand All @@ -17,3 +17,15 @@ void namedDeclsOnly() {
return 1;
};
}

void threeClauses2() [[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration)]];

void twoClauses2() [[clang::external_source_symbol(language="Swift", defined_in="module")]];

void fourClauses2()
[[clang::external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration)]]; // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}

void oneClause2() [[clang::external_source_symbol(generated_declaration)]];

void noArguments2()
[[clang::external_source_symbol]]; // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
8 changes: 7 additions & 1 deletion test/Sema/internal_linkage.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -fdouble-square-bracket-attributes %s

int var __attribute__((internal_linkage));
int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
Expand All @@ -19,3 +19,9 @@ struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_link
};

__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}

int var6 [[clang::internal_linkage]];
int var7 [[clang::internal_linkage]] __attribute__((common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}
__attribute__((common)) int var8 [[clang::internal_linkage]]; // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}

0 comments on commit b8bcd37

Please sign in to comment.