r326053 - Add a C2x spelling for the external_source_symbol and internal_linkage attributes in the clang vendor namespace.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 25 06:43:45 PST 2018
Author: aaronballman
Date: Sun Feb 25 06:43:45 2018
New Revision: 326053
URL: http://llvm.org/viewvc/llvm-project?rev=326053&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Sema/attr-external-source-symbol.c
cfe/trunk/test/Sema/internal_linkage.c
Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=326053&r1=326052&r2=326053&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sun Feb 25 06:43:45 2018
@@ -723,7 +723,7 @@ static llvm::StringRef canonicalizePlatf
}
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];
}
Modified: cfe/trunk/test/Sema/attr-external-source-symbol.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-external-source-symbol.c?rev=326053&r1=326052&r2=326053&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-external-source-symbol.c (original)
+++ cfe/trunk/test/Sema/attr-external-source-symbol.c Sun Feb 25 06:43:45 2018
@@ -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}}
Modified: cfe/trunk/test/Sema/internal_linkage.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/internal_linkage.c?rev=326053&r1=326052&r2=326053&view=diff
==============================================================================
--- cfe/trunk/test/Sema/internal_linkage.c (original)
+++ cfe/trunk/test/Sema/internal_linkage.c Sun Feb 25 06:43:45 2018
@@ -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))
};
__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}}
More information about the cfe-commits
mailing list