From: Aaron Ballman Date: Sun, 25 Feb 2018 14:43:45 +0000 (+0000) Subject: Add a C2x spelling for the external_source_symbol and internal_linkage attributes... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8bcd374906876895558fd71e90e922fcf153241;p=clang Add a C2x spelling for the external_source_symbol and internal_linkage 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 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index aa3cc6944b..e14ce0da91 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -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>]; @@ -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]; } diff --git a/test/Sema/attr-external-source-symbol.c b/test/Sema/attr-external-source-symbol.c index af6e6bc79e..dfed609c8e 100644 --- a/test/Sema/attr-external-source-symbol.c +++ b/test/Sema/attr-external-source-symbol.c @@ -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))); @@ -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}} diff --git a/test/Sema/internal_linkage.c b/test/Sema/internal_linkage.c index 37090a3333..57315d826e 100644 --- a/test/Sema/internal_linkage.c +++ b/test/Sema/internal_linkage.c @@ -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}} \ @@ -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}}