[Clang] include attribute scope in diagnostics (#144619)

This patch updates diagnostics to print fully qualified attribute names,
including scope when present.
This commit is contained in:
Oleksandr T. 2025-07-08 11:36:52 +03:00 committed by GitHub
parent 763131ba7f
commit 2e8e254d18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
96 changed files with 505 additions and 493 deletions

View File

@ -15,6 +15,7 @@
#define LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
#include "clang/Basic/AttributeScopeInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TokenKinds.h"
@ -175,6 +176,10 @@ public:
: AttributeCommonInfo(nullptr, AttributeScopeInfo(), AttrRange, K,
FormUsed) {}
AttributeCommonInfo(SourceRange AttrRange, AttributeScopeInfo AttrScope,
Kind K, Form FormUsed)
: AttributeCommonInfo(nullptr, AttrScope, AttrRange, K, FormUsed) {}
AttributeCommonInfo(AttributeCommonInfo &&) = default;
AttributeCommonInfo(const AttributeCommonInfo &) = default;
@ -292,6 +297,18 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind) {
}
}
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const AttributeCommonInfo *CI) {
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI),
DiagnosticsEngine::ak_attr_info);
return DB;
}
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const AttributeCommonInfo &CI) {
return DB << &CI;
}
} // namespace clang
#endif // LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H

View File

@ -289,6 +289,9 @@ public:
/// Expr *
ak_expr,
/// AttributeCommonInfo *
ak_attr_info,
};
/// Represents on argument value, which is a union discriminated

View File

@ -3290,10 +3290,11 @@ def err_attribute_wrong_number_arguments : Error<
def err_attribute_wrong_number_arguments_for : Error <
"%0 attribute references function %1, which %plural{0:takes no arguments|1:takes one argument|"
":takes exactly %2 arguments}2">;
def err_callback_attribute_wrong_arg_count : Error<
"'callback' attribute references function of type %0 which expects %1 "
"%plural{1:argument|:arguments}1 but attribute specifies %2 parameter index "
"%plural{1:argument|:arguments}2">;
def err_attribute_wrong_arg_count_for_func
: Error<"%0 attribute references function of type %1 which expects %2 "
"%plural{1:argument|:arguments}2 but attribute specifies %3 "
"parameter index "
"%plural{1:argument|:arguments}3">;
def err_attribute_bounds_for_function : Error<
"%0 attribute references parameter %1, but the function %2 has only %3 parameters">;
def err_attribute_no_member_function : Error<
@ -4712,9 +4713,9 @@ def note_protocol_decl : Note<
"protocol is declared here">;
def note_protocol_decl_undefined : Note<
"protocol %0 has no definition">;
def err_attribute_preferred_name_arg_invalid : Error<
"argument %0 to 'preferred_name' attribute is not a typedef for "
"a specialization of %1">;
def err_attribute_not_typedef_for_specialization
: Error<"argument %0 to %1 attribute is not a typedef for "
"a specialization of %2">;
def err_attribute_builtin_alias : Error<
"%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">;

View File

@ -1094,45 +1094,6 @@ enum AttributeDeclKind {
ExpectedTypedef,
};
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const ParsedAttr &At) {
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At.getAttrName()),
DiagnosticsEngine::ak_identifierinfo);
return DB;
}
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const ParsedAttr *At) {
DB.AddTaggedVal(reinterpret_cast<uint64_t>(At->getAttrName()),
DiagnosticsEngine::ak_identifierinfo);
return DB;
}
/// AttributeCommonInfo has a non-explicit constructor which takes an
/// SourceRange as its only argument, this constructor has many uses so making
/// it explicit is hard. This constructor causes ambiguity with
/// DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, SourceRange R).
/// We use SFINAE to disable any conversion and remove any ambiguity.
template <
typename ACI,
std::enable_if_t<std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const ACI &CI) {
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI.getAttrName()),
DiagnosticsEngine::ak_identifierinfo);
return DB;
}
template <
typename ACI,
std::enable_if_t<std::is_same<ACI, AttributeCommonInfo>::value, int> = 0>
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const ACI *CI) {
DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI->getAttrName()),
DiagnosticsEngine::ak_identifierinfo);
return DB;
}
} // namespace clang
#endif // LLVM_CLANG_SEMA_PARSEDATTR_H

View File

@ -506,7 +506,15 @@ void clang::FormatASTNodeDiagnosticArgument(
case DiagnosticsEngine::ak_attr: {
const Attr *At = reinterpret_cast<Attr *>(Val);
assert(At && "Received null Attr object!");
OS << '\'' << At->getSpelling() << '\'';
OS << '\'';
if (At->hasScope()) {
OS << At->getNormalizedFullName(At->getScopeName()->getName(),
At->getSpelling());
} else {
OS << At->getSpelling();
}
OS << '\'';
NeedQuotes = false;
break;
}
@ -516,6 +524,20 @@ void clang::FormatASTNodeDiagnosticArgument(
E->printPretty(OS, /*Helper=*/nullptr, Context.getPrintingPolicy());
break;
}
case DiagnosticsEngine::ak_attr_info: {
AttributeCommonInfo *AT = reinterpret_cast<AttributeCommonInfo *>(Val);
assert(AT && "Received null AttributeCommonInfo object!");
OS << '\'';
if (AT->isStandardAttributeSyntax()) {
OS << AT->getNormalizedFullName();
} else {
OS << AT->getAttrName()->getName();
}
OS << '\'';
NeedQuotes = false;
break;
}
}
if (NeedQuotes) {

View File

@ -1348,6 +1348,7 @@ void Diagnostic::FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
case DiagnosticsEngine::ak_declcontext:
case DiagnosticsEngine::ak_attr:
case DiagnosticsEngine::ak_expr:
case DiagnosticsEngine::ak_attr_info:
getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
StringRef(Modifier, ModifierLen),
StringRef(Argument, ArgumentLen),

View File

@ -1226,8 +1226,8 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) {
}
}
S.Diag(AL.getLoc(), diag::err_attribute_preferred_name_arg_invalid)
<< T << CTD;
S.Diag(AL.getLoc(), diag::err_attribute_not_typedef_for_specialization)
<< T << AL << CTD;
if (const auto *TT = T->getAs<TypedefType>())
S.Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
<< TT->getDecl();
@ -4194,8 +4194,9 @@ static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
}
if (CalleeFnProtoType->getNumParams() != EncodingIndices.size() - 1) {
S.Diag(AL.getLoc(), diag::err_callback_attribute_wrong_arg_count)
<< QualType{CalleeFnProtoType, 0} << CalleeFnProtoType->getNumParams()
S.Diag(AL.getLoc(), diag::err_attribute_wrong_arg_count_for_func)
<< AL << QualType{CalleeFnProtoType, 0}
<< CalleeFnProtoType->getNumParams()
<< (unsigned)(EncodingIndices.size() - 1);
return;
}
@ -8020,9 +8021,7 @@ void Sema::checkUnusedDeclAttributes(Declarator &D) {
}
void Sema::DiagnoseUnknownAttribute(const ParsedAttr &AL) {
std::string NormalizedFullName = '\'' + AL.getNormalizedFullName() + '\'';
SourceRange NR = AL.getNormalizedRange();
StringRef ScopeName = AL.getNormalizedScopeName();
std::optional<StringRef> CorrectedScopeName =
AL.tryGetCorrectedScopeName(ScopeName);
@ -8044,7 +8043,7 @@ void Sema::DiagnoseUnknownAttribute(const ParsedAttr &AL) {
Diag(CorrectedScopeName ? NR.getBegin() : AL.getRange().getBegin(),
diag::warn_unknown_attribute_ignored_suggestion);
D << NormalizedFullName << CorrectedFullName;
D << AL << CorrectedFullName;
if (AL.isExplicitScope()) {
D << FixItHint::CreateReplacement(NR, CorrectedFullName) << NR;
@ -8058,8 +8057,7 @@ void Sema::DiagnoseUnknownAttribute(const ParsedAttr &AL) {
}
}
} else {
Diag(NR.getBegin(), diag::warn_unknown_attribute_ignored)
<< NormalizedFullName << NR;
Diag(NR.getBegin(), diag::warn_unknown_attribute_ignored) << AL << NR;
}
}

View File

@ -1640,6 +1640,15 @@ bool SemaHLSL::handleResourceTypeAttr(QualType T, const ParsedAttr &AL) {
return false;
Attr *A = nullptr;
AttributeCommonInfo ACI(
AL.getLoc(), AttributeScopeInfo(AL.getScopeName(), AL.getScopeLoc()),
AttributeCommonInfo::NoSemaHandlerAttribute,
{
AttributeCommonInfo::AS_CXX11, 0, false /*IsAlignas*/,
false /*IsRegularKeywordAttribute*/
});
switch (AL.getKind()) {
case ParsedAttr::AT_HLSLResourceClass: {
if (!AL.isArgIdent(0)) {
@ -1659,16 +1668,16 @@ bool SemaHLSL::handleResourceTypeAttr(QualType T, const ParsedAttr &AL) {
<< "ResourceClass" << Identifier;
return false;
}
A = HLSLResourceClassAttr::Create(getASTContext(), RC, AL.getLoc());
A = HLSLResourceClassAttr::Create(getASTContext(), RC, ACI);
break;
}
case ParsedAttr::AT_HLSLROV:
A = HLSLROVAttr::Create(getASTContext(), AL.getLoc());
A = HLSLROVAttr::Create(getASTContext(), ACI);
break;
case ParsedAttr::AT_HLSLRawBuffer:
A = HLSLRawBufferAttr::Create(getASTContext(), AL.getLoc());
A = HLSLRawBufferAttr::Create(getASTContext(), ACI);
break;
case ParsedAttr::AT_HLSLContainedType: {
@ -1683,7 +1692,7 @@ bool SemaHLSL::handleResourceTypeAttr(QualType T, const ParsedAttr &AL) {
if (SemaRef.RequireCompleteType(TSI->getTypeLoc().getBeginLoc(), QT,
diag::err_incomplete_type))
return false;
A = HLSLContainedTypeAttr::Create(getASTContext(), TSI, AL.getLoc());
A = HLSLContainedTypeAttr::Create(getASTContext(), TSI, ACI);
break;
}

View File

@ -637,7 +637,7 @@ namespace {
namespace {
/// The InitListExpr here is of void type.
void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // both-error {{'annotate' attribute requires parameter 1 to be a constant expression}} \
void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // both-error {{'clang::annotate' attribute requires parameter 1 to be a constant expression}} \
// both-note {{subexpression not valid in a constant expression}}
}

View File

@ -60,7 +60,7 @@ union purr { float y; int x; }; // c23-error {{type 'union purr' has incompatibl
// The presence of an attribute makes two types not compatible.
struct [[gnu::packed]] attr_test { // c17-note {{previous definition is here}} \
c23-note {{attribute 'packed' here}}
c23-note {{attribute 'gnu::packed' here}}
int x;
};
@ -75,26 +75,26 @@ struct attr_test_2 { // c17-note {{previous definition is here}}
struct [[gnu::packed]] attr_test_2 { // c17-error {{redefinition of 'attr_test_2'}} \
c23-error {{type 'struct attr_test_2' has an attribute which currently causes the types to be treated as though they are incompatible}} \
c23-note {{attribute 'packed' here}}
c23-note {{attribute 'gnu::packed' here}}
int x;
};
// This includes the same attribute on both types.
struct [[gnu::packed]] attr_test_3 { // c17-note {{previous definition is here}} \
c23-note {{attribute 'packed' here}}
c23-note {{attribute 'gnu::packed' here}}
int x;
};
struct [[gnu::packed]] attr_test_3 { // c17-error {{redefinition of 'attr_test_3'}} \
c23-error {{type 'struct attr_test_3' has an attribute which currently causes the types to be treated as though they are incompatible}} \
c23-note {{attribute 'packed' here}}
c23-note {{attribute 'gnu::packed' here}}
int x;
};
// Everything which applies to the tag itself also applies to fields.
struct field_attr_test_1 { // c17-note {{previous definition is here}}
int x;
[[gnu::packed]] int y; // c23-note {{attribute 'packed' here}}
[[gnu::packed]] int y; // c23-note {{attribute 'gnu::packed' here}}
};
struct field_attr_test_1 { // c17-error {{redefinition of 'field_attr_test_1'}} \
@ -104,7 +104,7 @@ struct field_attr_test_1 { // c17-error {{redefinition of 'field_attr_test_1'}}
};
struct field_attr_test_2 { // c17-note {{previous definition is here}}
[[gnu::packed]] int x; // c23-note {{attribute 'packed' here}}
[[gnu::packed]] int x; // c23-note {{attribute 'gnu::packed' here}}
int y;
};
@ -115,13 +115,13 @@ struct field_attr_test_2 { // c17-error {{redefinition of 'field_attr_test_2'}}
};
struct field_attr_test_3 { // c17-note {{previous definition is here}}
[[gnu::packed]] int x; // c23-note {{attribute 'packed' here}}
[[gnu::packed]] int x; // c23-note {{attribute 'gnu::packed' here}}
int y;
};
struct field_attr_test_3 { // c17-error {{redefinition of 'field_attr_test_3'}} \
c23-error {{type 'struct field_attr_test_3' has a member with an attribute which currently causes the types to be treated as though they are incompatible}}
int x [[gnu::packed]]; // c23-note {{attribute 'packed' here}}
int x [[gnu::packed]]; // c23-note {{attribute 'gnu::packed' here}}
int y;
};

View File

@ -6,7 +6,7 @@ void test_attributes() {
auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-error{{non-void lambda does not return a value in all control paths}}
// FIXME: GCC accepts the [[gnu::noreturn]] attribute here.
auto nrl2 = []() [[gnu::noreturn]] { return; }; // expected-warning{{attribute 'noreturn' ignored}}
auto nrl2 = []() [[gnu::noreturn]] { return; }; // expected-warning{{attribute 'gnu::noreturn' ignored}}
}
template<typename T>

View File

@ -3,7 +3,7 @@
template<typename T>
void test_attributes() {
// FIXME: GCC accepts [[gnu::noreturn]] here.
auto nrl = []() [[gnu::noreturn]] {}; // expected-warning{{attribute 'noreturn' ignored}}
auto nrl = []() [[gnu::noreturn]] {}; // expected-warning{{attribute 'gnu::noreturn' ignored}}
}
template void test_attributes<int>();

View File

@ -11,7 +11,7 @@ void __attribute__((riscv_vector_cc)) test_no_attribute(int x) { } // expected-e
[[riscv::vector_cc]] int var2; // expected-warning {{'vector_cc' only applies to function types; type here is 'int'}}
[[riscv::vector_cc]] void func2();
[[riscv::vector_cc(1)]] void func_invalid2(); // expected-error {{'vector_cc' attribute takes no arguments}}
[[riscv::vector_cc(1)]] void func_invalid2(); // expected-error {{'riscv::vector_cc' attribute takes no arguments}}
void test_no_attribute2(int); // expected-note {{previous declaration is here}}
[[riscv::vector_cc]] void test_no_attribute2(int x) { } // expected-error {{function declared 'riscv_vector_cc' here was previously declared without calling convention}}

View File

@ -20,7 +20,7 @@ void test_lambda() {
[[riscv::vector_cc]] int var2; // expected-warning {{'vector_cc' only applies to function types; type here is 'int'}}
[[riscv::vector_cc]] void func2();
[[riscv::vector_cc(1)]] void func_invalid2(); // expected-error {{'vector_cc' attribute takes no arguments}}
[[riscv::vector_cc(1)]] void func_invalid2(); // expected-error {{'riscv::vector_cc' attribute takes no arguments}}
void test_no_attribute2(int); // expected-note {{previous declaration is here}}
[[riscv::vector_cc]] void test_no_attribute2(int x) { } // expected-error {{function declared 'riscv_vector_cc' here was previously declared without calling convention}}

View File

@ -227,18 +227,18 @@ int test(void) {
// ignored.
// For details see https://github.com/llvm/llvm-project/issues/55790
void test_standard_syntax() {
[[clang::noderef]] int i; // expected-warning {{'noderef' attribute ignored}}
[[clang::noderef]] int i; // expected-warning {{'clang::noderef' attribute ignored}}
[[clang::noderef]] int *p1; // expected-warning {{'noderef' attribute ignored}}
[[clang::noderef]] int *p1; // expected-warning {{'clang::noderef' attribute ignored}}
*p1;
int *p2 [[clang::noderef]]; // expected-warning {{'noderef' attribute ignored}}
int *p2 [[clang::noderef]]; // expected-warning {{'clang::noderef' attribute ignored}}
*p2;
int * [[clang::noderef]] p3; // expected-warning {{'noderef' attribute ignored}}
int * [[clang::noderef]] p3; // expected-warning {{'clang::noderef' attribute ignored}}
*p3;
typedef int* IntPtr;
[[clang::noderef]] IntPtr p4; // expected-warning {{'noderef' attribute ignored}}
[[clang::noderef]] IntPtr p4; // expected-warning {{'clang::noderef' attribute ignored}}
*p4;
}

View File

@ -7,8 +7,8 @@
[[omp::assume("omp_noopenmp")]] void f6(); // expected-warning {{unknown assumption string 'omp_noopenmp' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
[[omp::assume("omp_no_openmp_routine")]] void f7(); // expected-warning {{unknown assumption string 'omp_no_openmp_routine' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp_routines'?}}
[[omp::assume("omp_no_openmp1")]] void f8(); // expected-warning {{unknown assumption string 'omp_no_openmp1' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp'?}}
[[omp::assume("omp_no_openmp", "omp_no_openmp")]] void f9(); // expected-error {{'assume' attribute takes one argument}}
[[omp::assume("omp_no_openmp", "omp_no_openmp")]] void f9(); // expected-error {{'omp::assume' attribute takes one argument}}
[[omp::assume("omp_no_openmp_construct")]] void f10(); // expected-warning {{unknown assumption string 'omp_no_openmp_construct' may be misspelled; attribute is potentially ignored, did you mean 'omp_no_openmp_constructs'?}}
[[omp::assume(3)]] int g1; // expected-error {{expected string literal as argument of 'assume' attribute}}
[[omp::assume("omp_no_openmp")]] int g2; // expected-warning {{'assume' attribute only applies to functions and Objective-C methods}}
[[omp::assume("omp_no_openmp")]] int g2; // expected-warning {{'omp::assume' attribute only applies to functions and Objective-C methods}}

View File

@ -20,9 +20,9 @@ void bad() {
{}
#pragma omp target ompx_attribute(__attribute__((amdgpu_flat_work_group_size(1, 2, 3,)))) // expected-error {{expected expression}}
{}
#pragma omp target ompx_attribute([[clang::amdgpu_waves_per_eu(1, 2, 3)]]) // expected-error {{'amdgpu_waves_per_eu' attribute takes no more than 2 arguments}}
#pragma omp target ompx_attribute([[clang::amdgpu_waves_per_eu(1, 2, 3)]]) // expected-error {{'clang::amdgpu_waves_per_eu' attribute takes no more than 2 arguments}}
{}
#pragma omp target ompx_attribute([[clang::unknown]]) // expected-warning {{'ompx_attribute' clause only allows 'amdgpu_flat_work_group_size', 'amdgpu_waves_per_eu', and 'launch_bounds'; 'unknown' is ignored}}
#pragma omp target ompx_attribute([[clang::unknown]]) // expected-warning {{'ompx_attribute' clause only allows 'amdgpu_flat_work_group_size', 'amdgpu_waves_per_eu', and 'launch_bounds'; 'clang::unknown' is ignored}}
{}
#pragma omp target ompx_attribute(baz) // expected-error {{expected ')'}} expected-note {{to match this '('}}
{}

View File

@ -14,7 +14,7 @@ void f2(void) {
asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
[[]] asm("");
[[gnu::deprecated]] asm(""); // expected-warning {{'deprecated' attribute ignored}}
[[gnu::deprecated]] asm(""); // expected-warning {{'gnu::deprecated' attribute ignored}}
}
void a(void) __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}

View File

@ -10,7 +10,7 @@ int foo6 asm ("" L"bar7"); // expected-error {{cannot use wide string literal in
void f() {
[[]] asm("");
[[gnu::deprecated]] asm(""); // expected-warning {{'deprecated' attribute ignored}}
[[gnu::deprecated]] asm(""); // expected-warning {{'gnu::deprecated' attribute ignored}}
}

View File

@ -33,13 +33,13 @@ __device__ __host__ void test_invalid_format(float *a) {
}
}
[[clang::atomic(no_remote_memory)]] // expected-error {{'atomic' attribute cannot be applied to a declaration}}
[[clang::atomic(no_remote_memory)]] // expected-error {{'clang::atomic' attribute cannot be applied to a declaration}}
__device__ __host__ void test_not_compound_stmt(float *a) {
__scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
}
__device__ __host__ void test_quoted(float *a) {
[[clang::atomic("no_remote_memory", "remote_memory")]] { // expected-error {{'atomic' attribute requires an identifier}}
[[clang::atomic("no_remote_memory", "remote_memory")]] { // expected-error {{'clang::atomic' attribute requires an identifier}}
__scoped_atomic_fetch_add(a, 1, __ATOMIC_RELAXED, __MEMORY_SCOPE_SYSTEM);
}
}

View File

@ -292,7 +292,7 @@ template <int... Is> void variadic_nttp() {
void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
void baz [[clang::no_sanitize(Is...)]] (); // expected-error {{expected string literal as argument of 'no_sanitize' attribute}}
void bor [[clang::annotate("A", "V" ...)]] (); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // expected-error {{'annotate' attribute requires parameter 1 to be a constant expression}} expected-note {{subexpression not valid in a constant expression}}
void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // expected-error {{'clang::annotate' attribute requires parameter 1 to be a constant expression}} expected-note {{subexpression not valid in a constant expression}}
void boo [[unknown::foo(Is...)]] (); // expected-warning {{unknown attribute 'unknown::foo' ignored}}
void faz [[clang::annotate("C", (Is + ...))]] (); // expected-warning {{pack fold expression is a C++17 extension}}
void far [[clang::annotate("D", Is...)]] ();
@ -306,8 +306,8 @@ void bar () {
// FIXME: GCC accepts [[gnu::noreturn]] on a lambda, even though it appertains
// to the operator()'s type, and GCC does not otherwise accept attributes
// applied to types. Use that to test this.
[] () [[gnu::noreturn]] { return; } (); // expected-warning {{attribute 'noreturn' ignored}} FIXME-error {{should not return}}
[] () [[gnu::noreturn]] { throw; } (); // expected-warning {{attribute 'noreturn' ignored}}
[] () [[gnu::noreturn]] { return; } (); // expected-warning {{attribute 'gnu::noreturn' ignored}} FIXME-error {{should not return}}
[] () [[gnu::noreturn]] { throw; } (); // expected-warning {{attribute 'gnu::noreturn' ignored}}
new int[42][[]][5][[]]{};
}
@ -350,16 +350,16 @@ namespace arguments {
}
// Forbid attributes on decl specifiers.
unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-error {{'unused' attribute cannot be applied to types}} \
unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-error {{'gnu::unused' attribute cannot be applied to types}} \
expected-error {{an attribute list cannot appear here}}
typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-error {{'unused' attribute cannot be applied to types}} \
typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-error {{'gnu::unused' attribute cannot be applied to types}} \
expected-error {{an attribute list cannot appear here}}
int [[carries_dependency]] foo(int [[carries_dependency]] x); // expected-error 2{{'carries_dependency' attribute cannot be applied to types}}
// Forbid [[gnu::...]] attributes on declarator chunks.
int *[[gnu::unused]] v3; // expected-warning {{attribute 'unused' ignored}}
int v4[2][[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
int v5()[[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
int *[[gnu::unused]] v3; // expected-warning {{attribute 'gnu::unused' ignored}}
int v4[2][[gnu::unused]]; // expected-warning {{attribute 'gnu::unused' ignored}}
int v5()[[gnu::unused]]; // expected-warning {{attribute 'gnu::unused' ignored}}
[[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}}
[[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}}

View File

@ -147,7 +147,7 @@ namespace UsingDeclAttrs {
static_assert(alignof(T) == 1, "");
using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}}
using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}}
using T = int [[gnu::aligned(1)]]; // expected-error {{'gnu::aligned' attribute cannot be applied to types}}
}
namespace DuplicateSpecifier {

View File

@ -158,7 +158,7 @@ _Pragma("clang attribute pop");
#pragma clang attribute pop
#pragma clang attribute push ([[fallthrough]], apply_to=function) // expected-error {{attribute 'fallthrough' is not supported by '#pragma clang attribute'}}
#pragma clang attribute push ([[clang::fallthrough]], apply_to=function) // expected-error {{attribute 'fallthrough' is not supported by '#pragma clang attribute'}}
#pragma clang attribute push ([[clang::fallthrough]], apply_to=function) // expected-error {{attribute 'clang::fallthrough' is not supported by '#pragma clang attribute'}}
#pragma clang attribute push ([[]], apply_to = function) // A noop
@ -182,15 +182,15 @@ _Pragma("clang attribute pop");
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_local))
#pragma clang attribute pop
#pragma clang attribute push([[clang::uninitialized]], apply_to = function) // expected-error {{attribute 'uninitialized' cannot be applied to 'function'}}
#pragma clang attribute push([[clang::uninitialized]], apply_to = function) // expected-error {{attribute 'clang::uninitialized' cannot be applied to 'function'}}
#pragma clang attribute pop
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable) // expected-error {{attribute 'uninitialized' cannot be applied to 'variable'}}
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable) // expected-error {{attribute 'clang::uninitialized' cannot be applied to 'variable'}}
#pragma clang attribute pop
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_thread_local)) // expected-error {{attribute 'uninitialized' cannot be applied to 'variable(is_thread_local)'}}
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_thread_local)) // expected-error {{attribute 'clang::uninitialized' cannot be applied to 'variable(is_thread_local)'}}
#pragma clang attribute pop
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_global)) // expected-error {{attribute 'uninitialized' cannot be applied to 'variable(is_global)'}}
#pragma clang attribute push([[clang::uninitialized]], apply_to = variable(is_global)) // expected-error {{attribute 'clang::uninitialized' cannot be applied to 'variable(is_global)'}}
#pragma clang attribute pop
#pragma clang attribute push([[clang::uninitialized]], apply_to = any(variable(is_parameter), variable(unless(is_parameter)))) // expected-error {{attribute 'uninitialized' cannot be applied to 'variable(is_parameter)', and 'variable(unless(is_parameter))'}}
#pragma clang attribute push([[clang::uninitialized]], apply_to = any(variable(is_parameter), variable(unless(is_parameter)))) // expected-error {{attribute 'clang::uninitialized' cannot be applied to 'variable(is_parameter)', and 'variable(unless(is_parameter))'}}
#pragma clang attribute pop
// We're allowed to apply attributes to subsets of allowed subjects.
#pragma clang attribute push([[clang::no_destroy]], apply_to = variable)

View File

@ -2,10 +2,10 @@
typedef vector<float, 4> float4;
// expected-error@+1{{'contained_type' attribute cannot be applied to a declaration}}
// expected-error@+1{{'hlsl::contained_type' attribute cannot be applied to a declaration}}
[[hlsl::contained_type(float4)]] __hlsl_resource_t h1;
// expected-error@+1{{'contained_type' attribute takes one argument}}
// expected-error@+1{{'hlsl::contained_type' attribute takes one argument}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type()]] h3;
// expected-error@+1{{expected a type}}
@ -17,12 +17,12 @@ __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(a)]] h5;
// expected-error@+1{{expected a type}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type("b", c)]] h6;
// expected-warning@+1{{attribute 'contained_type' is already applied}}
// expected-warning@+1{{attribute 'hlsl::contained_type' is already applied}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]] [[hlsl::contained_type(float)]] h7;
// expected-warning@+1{{attribute 'contained_type' is already applied with different arguments}}
// expected-warning@+1{{attribute 'hlsl::contained_type' is already applied with different arguments}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]] [[hlsl::contained_type(int)]] h8;
// expected-error@+2{{attribute 'resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'contained_type' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+2{{attribute 'hlsl::resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'hlsl::contained_type' can be used only on HLSL intangible type '__hlsl_resource_t'}}
float [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]] res5;

View File

@ -1,20 +1,20 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
// expected-error@+1{{'is_rov' attribute cannot be applied to a declaration}}
// expected-error@+1{{'hlsl::is_rov' attribute cannot be applied to a declaration}}
[[hlsl::is_rov]] __hlsl_resource_t res0;
// expected-error@+1{{HLSL resource needs to have [[hlsl::resource_class()]] attribute}}
__hlsl_resource_t [[hlsl::is_rov]] res1;
// expected-error@+1{{'is_rov' attribute takes no arguments}}
// expected-error@+1{{'hlsl::is_rov' attribute takes no arguments}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::is_rov(3)]] res2;
// expected-error@+1{{use of undeclared identifier 'gibberish'}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::is_rov(gibberish)]] res3;
// expected-warning@+1{{attribute 'is_rov' is already applied}}
// expected-warning@+1{{attribute 'hlsl::is_rov' is already applied}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::is_rov]] [[hlsl::is_rov]] res4;
// expected-error@+2{{attribute 'resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'is_rov' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+2{{attribute 'hlsl::resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'hlsl::is_rov' can be used only on HLSL intangible type '__hlsl_resource_t'}}
float [[hlsl::resource_class(UAV)]] [[hlsl::is_rov]] res5;

View File

@ -1,17 +1,17 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
// expected-error@+1{{'raw_buffer' attribute cannot be applied to a declaration}}
// expected-error@+1{{'hlsl::raw_buffer' attribute cannot be applied to a declaration}}
[[hlsl::raw_buffer]] __hlsl_resource_t res0;
// expected-error@+1{{'raw_buffer' attribute takes no arguments}}
// expected-error@+1{{'hlsl::raw_buffer' attribute takes no arguments}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer(3)]] res2;
// expected-error@+1{{use of undeclared identifier 'gibberish'}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer(gibberish)]] res3;
// expected-warning@+1{{attribute 'raw_buffer' is already applied}}
// expected-warning@+1{{attribute 'hlsl::raw_buffer' is already applied}}
__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer]] [[hlsl::raw_buffer]] res4;
// expected-error@+2{{attribute 'resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'raw_buffer' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+2{{attribute 'hlsl::resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'hlsl::raw_buffer' can be used only on HLSL intangible type '__hlsl_resource_t'}}
float [[hlsl::resource_class(UAV)]] [[hlsl::raw_buffer]] res5;

View File

@ -1,22 +1,22 @@
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
// expected-error@+1{{'resource_class' attribute cannot be applied to a declaration}}
// expected-error@+1{{'hlsl::resource_class' attribute cannot be applied to a declaration}}
[[hlsl::resource_class(UAV)]] __hlsl_resource_t e0;
// expected-error@+1{{'resource_class' attribute takes one argument}}
// expected-error@+1{{'hlsl::resource_class' attribute takes one argument}}
__hlsl_resource_t [[hlsl::resource_class()]] e1;
// expected-warning@+1{{ResourceClass attribute argument not supported: gibberish}}
__hlsl_resource_t [[hlsl::resource_class(gibberish)]] e2;
// expected-warning@+1{{attribute 'resource_class' is already applied with different arguments}}
// expected-warning@+1{{attribute 'hlsl::resource_class' is already applied with different arguments}}
__hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::resource_class(UAV)]] e3;
// expected-warning@+1{{attribute 'resource_class' is already applied}}
// expected-warning@+1{{attribute 'hlsl::resource_class' is already applied}}
__hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::resource_class(SRV)]] e4;
// expected-error@+1{{'resource_class' attribute takes one argument}}
// expected-error@+1{{'hlsl::resource_class' attribute takes one argument}}
__hlsl_resource_t [[hlsl::resource_class(SRV, "aa")]] e5;
// expected-error@+1{{attribute 'resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
// expected-error@+1{{attribute 'hlsl::resource_class' can be used only on HLSL intangible type '__hlsl_resource_t'}}
float [[hlsl::resource_class(UAV)]] e6;

View File

@ -18,25 +18,25 @@ void foo(float *[[clang::annotate_type("foo")]] a) {
int *__attribute__((annotate_type("bar"))) y2; // expected-warning {{unknown attribute 'annotate_type' ignored}}
// Various error cases
[[clang::annotate_type("bar")]] int *z1; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
int *z2 [[clang::annotate_type("bar")]]; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("bar")]]; // expected-error {{'annotate_type' attribute cannot be applied to a statement}}
[[clang::annotate_type("bar")]] int *z1; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
int *z2 [[clang::annotate_type("bar")]]; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("bar")]]; // expected-error {{'clang::annotate_type' attribute cannot be applied to a statement}}
int *[[clang::annotate_type(1)]] z3; // expected-error {{expected string literal as argument of 'annotate_type' attribute}}
int *[[clang::annotate_type()]] z4; // expected-error {{'annotate_type' attribute takes at least 1 argument}}
int *[[clang::annotate_type]] z5; // expected-error {{'annotate_type' attribute takes at least 1 argument}}
int *[[clang::annotate_type()]] z4; // expected-error {{'clang::annotate_type' attribute takes at least 1 argument}}
int *[[clang::annotate_type]] z5; // expected-error {{'clang::annotate_type' attribute takes at least 1 argument}}
int *[[clang::annotate_type(some_function())]] z6; // expected-error {{expected string literal as argument of 'annotate_type' attribute}}
int *[[clang::annotate_type("bar", some_function())]] z7; // expected-error {{'annotate_type' attribute requires parameter 1 to be a constant expression}} expected-note{{subexpression not valid in a constant expression}}
int *[[clang::annotate_type("bar", z7)]] z8; // expected-error {{'annotate_type' attribute requires parameter 1 to be a constant expression}} expected-note{{subexpression not valid in a constant expression}}
int *[[clang::annotate_type("bar", some_function())]] z7; // expected-error {{'clang::annotate_type' attribute requires parameter 1 to be a constant expression}} expected-note{{subexpression not valid in a constant expression}}
int *[[clang::annotate_type("bar", z7)]] z8; // expected-error {{'clang::annotate_type' attribute requires parameter 1 to be a constant expression}} expected-note{{subexpression not valid in a constant expression}}
int *[[clang::annotate_type("bar", int)]] z9; // expected-error {{expected expression}}
}
// More error cases: Prohibit adding the attribute to declarations.
// Different declarations hit different code paths, so they need separate tests.
[[clang::annotate_type("bar")]] int *global; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("bar")]] void annotated_function(); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
void g([[clang::annotate_type("bar")]] int); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S{ // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] int member; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("bar")]] int *global; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("bar")]] void annotated_function(); // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
void g([[clang::annotate_type("bar")]] int); // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S{ // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] int member; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] union { // expected-error {{an attribute list cannot appear here}}
int i;
float f;

View File

@ -16,6 +16,6 @@ void __attribute__((annotate("foo"))) foo(float *a) {
float b = __builtin_annotation(*a, "foo"); // expected-error {{first argument to __builtin_annotation must be an integer}}
__attribute__((annotate())) int c; // expected-error {{'annotate' attribute takes at least 1 argument}}
[[clang::annotate()]] int c2; // expected-error {{'annotate' attribute takes at least 1 argument}}
[[clang::annotate()]] c2 += 1; // expected-error {{'annotate' attribute takes at least 1 argument}}
[[clang::annotate()]] int c2; // expected-error {{'clang::annotate' attribute takes at least 1 argument}}
[[clang::annotate()]] c2 += 1; // expected-error {{'clang::annotate' attribute takes at least 1 argument}}
}

View File

@ -19,7 +19,7 @@ void test(int n) {
__attribute__((assume(n++))); // expected-warning {{assumption is ignored because it contains (potential) side-effects}}
[[clang::assume(n++)]]; // expected-warning {{assumption is ignored because it contains (potential) side-effects}}
[[clang::assume(true)]] int x; // expected-error {{'assume' attribute cannot be applied to a declaration}}
[[clang::assume(true)]] int x; // expected-error {{'clang::assume' attribute cannot be applied to a declaration}}
__attribute__((assume(true))) int y; // expected-error {{'assume' attribute cannot be applied to a declaration}}
}

View File

@ -10,22 +10,22 @@ int bar();
void foo() {
[[clang::always_inline]] bar();
[[clang::always_inline(0)]] bar(); // expected-error {{'always_inline' attribute takes no arguments}}
[[clang::always_inline(0)]] bar(); // expected-error {{'clang::always_inline' attribute takes no arguments}}
int x;
[[clang::always_inline]] int i = bar(); // expected-warning {{'always_inline' attribute only applies to functions and statements}}
[[clang::always_inline]] x = 0; // expected-warning {{'always_inline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::always_inline]] { asm("nop"); } // expected-warning {{'always_inline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::always_inline]] label : x = 1; // expected-warning {{'always_inline' attribute only applies to functions and statements}}
[[clang::always_inline]] int i = bar(); // expected-warning {{'clang::always_inline' attribute only applies to functions and statements}}
[[clang::always_inline]] x = 0; // expected-warning {{'clang::always_inline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::always_inline]] { asm("nop"); } // expected-warning {{'clang::always_inline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::always_inline]] label : x = 1; // expected-warning {{'clang::always_inline' attribute only applies to functions and statements}}
[[clang::always_inline]] always_inline_fn();
[[clang::always_inline]] noinline_fn(); // expected-warning {{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
[[clang::always_inline]] flatten_fn(); // expected-warning {{statement attribute 'always_inline' has higher precedence than function attribute 'flatten'}}
[[clang::always_inline]] noinline_fn(); // expected-warning {{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
[[clang::always_inline]] flatten_fn(); // expected-warning {{statement attribute 'clang::always_inline' has higher precedence than function attribute 'flatten'}}
[[gnu::always_inline]] bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::always_inline]]' on statements}}
__attribute__((always_inline)) bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::always_inline]]' on statements}}
}
[[clang::always_inline]] static int i = bar(); // expected-warning {{'always_inline' attribute only applies to functions and statements}}
[[clang::always_inline]] static int i = bar(); // expected-warning {{'clang::always_inline' attribute only applies to functions and statements}}
// This used to crash the compiler.
template<int D>
@ -41,13 +41,13 @@ int non_dependent(int x){return x;} // #NO_DEP
template<int D> [[gnu::noinline]]
int baz(int x) { // #BAZ
// expected-warning@+2{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
// expected-warning@+2{{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
[[clang::always_inline]] non_dependent(x);
if constexpr (D>0) {
// expected-warning@+6{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
// expected-warning@+6{{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
// expected-warning@+4 3{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
// expected-warning@+4 3{{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
// expected-note@#BAZ 3{{conflicting attribute is here}}
// expected-note@#BAZ_INST 3{{in instantiation}}
// expected-note@+1 3{{in instantiation}}
@ -61,9 +61,9 @@ template<int ... D>
int variadic_baz(int x) {
// Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
// Dianoses DEP 3x, once per variadic expansion.
// expected-warning@+5 2{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
// expected-warning@+5 2{{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
// expected-note@#NO_DEP 2{{conflicting attribute is here}}
// expected-warning@+3 3{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
// expected-warning@+3 3{{statement attribute 'clang::always_inline' has higher precedence than function attribute 'noinline'}}
// expected-note@#DEP 3{{conflicting attribute is here}}
// expected-note@#VARIADIC_INST{{in instantiation}}
[[clang::always_inline]] return non_dependent(x) + (dependent<D>(x) + ...);

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
[[clang::enforce_tcb("oops")]] int wrong_subject_type; // expected-warning{{'enforce_tcb' attribute only applies to functions}}
[[clang::enforce_tcb("oops")]] int wrong_subject_type; // expected-warning{{'clang::enforce_tcb' attribute only applies to functions}}
void no_arguments() __attribute__((enforce_tcb)); // expected-error{{'enforce_tcb' attribute takes one argument}}
@ -8,7 +8,7 @@ void too_many_arguments() __attribute__((enforce_tcb("test", 12))); // expected-
void wrong_argument_type() __attribute__((enforce_tcb(12))); // expected-error{{expected string literal as argument of 'enforce_tcb' attribute}}
[[clang::enforce_tcb_leaf("oops")]] int wrong_subject_type_leaf; // expected-warning{{'enforce_tcb_leaf' attribute only applies to functions}}
[[clang::enforce_tcb_leaf("oops")]] int wrong_subject_type_leaf; // expected-warning{{'clang::enforce_tcb_leaf' attribute only applies to functions}}
void no_arguments_leaf() __attribute__((enforce_tcb_leaf)); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}}

View File

@ -29,5 +29,5 @@ void fiveClauses2(void);
[[clang::external_source_symbol(generated_declaration)]] void oneClause2(void);
[[clang::external_source_symbol]] // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
[[clang::external_source_symbol]] // expected-error {{'clang::external_source_symbol' attribute takes at least 1 argument}}
void noArguments2(void);

View File

@ -17,7 +17,7 @@ int (* __attribute__((acquire_handle("Fuchsia"))) fpt)(char *); // expected-warn
auto lambdat = [](int handle __attribute__((use_handle("Fuchsia"))))
__attribute__((acquire_handle("Fuchsia"))) -> int { return 0; };
int __attribute((acquire_handle("Fuchsia"))) ta; // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}}
int open(const char *path, int flags, ...) [[clang::acquire_handle]]; // expected-error {{'acquire_handle' attribute takes one argument}}
int open(const char *path, int flags, ...) [[clang::acquire_handle]]; // expected-error {{'clang::acquire_handle' attribute takes one argument}}
// Typedefs.
typedef int callback(char *) __attribute__((acquire_handle("Fuchsia")));

View File

@ -5,7 +5,7 @@ void g(void) {
[[clang::likely]] {}
}
void m(void) {
[[clang::likely]] int x = 42; // expected-error {{'likely' attribute cannot be applied to a declaration}}
[[clang::likely]] int x = 42; // expected-error {{'clang::likely' attribute cannot be applied to a declaration}}
if (x)
[[clang::unlikely]] {}
@ -44,7 +44,7 @@ void m(void) {
goto lbl;
// FIXME: allow the attribute on the label
[[clang::unlikely]] lbl : // expected-error {{'unlikely' attribute cannot be applied to a declaration}}
[[clang::unlikely]] lbl : // expected-error {{'clang::unlikely' attribute cannot be applied to a declaration}}
[[clang::likely]] x = x + 1;
[[clang::likely]]++ x;

View File

@ -11,7 +11,7 @@ public:
virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
[[clang::mig_server_routine]] virtual IOReturn cppAnnotatedMethod();
[[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
[[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'clang::mig_server_routine' attribute takes no arguments}}
[[clang::mig_server_routine]] virtual int cppInvalidAnnotatedMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
};

View File

@ -9,8 +9,8 @@ typedef void (*FuncPointer)(void);
void testNoCfCheck(){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
// No variable or parameter declaration
int [[gnu::nocf_check]] i; // expected-error {{'nocf_check' attribute cannot be applied to types}}
void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} // expected-warning {{'nocf_check' attribute only applies to functions and function pointers}}
int [[gnu::nocf_check]] i; // expected-error {{'gnu::nocf_check' attribute cannot be applied to types}}
void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} // expected-warning {{'gnu::nocf_check' attribute only applies to functions and function pointers}}
// Allow attributed function pointers as well as casting between attributed
// and non-attributed function pointers.
@ -20,4 +20,4 @@ void testNoCfCheckMismatch(FuncPointer f) {
}
// 'nocf_check' Attribute has no parameters.
[[gnu::nocf_check(1)]] int testNoCfCheckParams(); // expected-error {{'nocf_check' attribute takes no arguments}}
[[gnu::nocf_check(1)]] int testNoCfCheckParams(); // expected-error {{'gnu::nocf_check' attribute takes no arguments}}

View File

@ -10,15 +10,15 @@ int bar();
void foo() {
[[clang::noinline]] bar();
[[clang::noinline(0)]] bar(); // expected-error {{'noinline' attribute takes no arguments}}
[[clang::noinline(0)]] bar(); // expected-error {{'clang::noinline' attribute takes no arguments}}
int x;
[[clang::noinline]] x = 0; // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::noinline]] { asm("nop"); } // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::noinline]] label: x = 1; // expected-warning {{'noinline' attribute only applies to functions and statements}}
[[clang::noinline]] x = 0; // expected-warning {{'clang::noinline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::noinline]] { asm("nop"); } // expected-warning {{'clang::noinline' attribute is ignored because there exists no call expression inside the statement}}
[[clang::noinline]] label: x = 1; // expected-warning {{'clang::noinline' attribute only applies to functions and statements}}
[[clang::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
[[clang::noinline]] flatten_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'flatten'}}
[[clang::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
[[clang::noinline]] flatten_fn(); // expected-warning {{statement attribute 'clang::noinline' has higher precedence than function attribute 'flatten'}}
[[clang::noinline]] noinline_fn();
[[gnu::noinline]] bar(); // expected-warning {{attribute is ignored on this statement as it only applies to functions; use '[[clang::noinline]]' on statements}}
@ -27,19 +27,19 @@ void foo() {
void ms_noi_check() {
[[msvc::noinline]] bar();
[[msvc::noinline(0)]] bar(); // expected-error {{'noinline' attribute takes no arguments}}
[[msvc::noinline(0)]] bar(); // expected-error {{'msvc::noinline' attribute takes no arguments}}
int x;
[[msvc::noinline]] x = 0; // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
[[msvc::noinline]] { asm("nop"); } // expected-warning {{'noinline' attribute is ignored because there exists no call expression inside the statement}}
[[msvc::noinline]] label: x = 1; // expected-warning {{'noinline' attribute only applies to functions and statements}}
[[msvc::noinline]] x = 0; // expected-warning {{'msvc::noinline' attribute is ignored because there exists no call expression inside the statement}}
[[msvc::noinline]] { asm("nop"); } // expected-warning {{'msvc::noinline' attribute is ignored because there exists no call expression inside the statement}}
[[msvc::noinline]] label: x = 1; // expected-warning {{'msvc::noinline' attribute only applies to functions and statements}}
[[msvc::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
[[msvc::noinline]] flatten_fn(); // expected-warning {{statement attribute 'noinline' has higher precedence than function attribute 'flatten'}}
[[msvc::noinline]] always_inline_fn(); // expected-warning {{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
[[msvc::noinline]] flatten_fn(); // expected-warning {{statement attribute 'msvc::noinline' has higher precedence than function attribute 'flatten'}}
[[msvc::noinline]] noinline_fn();
}
[[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
[[msvc::noinline]] static int j = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
[[clang::noinline]] static int i = bar(); // expected-warning {{'clang::noinline' attribute only applies to functions and statements}}
[[msvc::noinline]] static int j = bar(); // expected-warning {{'msvc::noinline' attribute only applies to functions and statements}}
// This used to crash the compiler.
template<int D>
@ -55,13 +55,13 @@ int non_dependent(int x){return x;} // #NO_DEP
template<int D> [[clang::always_inline]]
int baz(int x) { // #BAZ
// expected-warning@+2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+2{{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
[[clang::noinline]] non_dependent(x);
if constexpr (D>0) {
// expected-warning@+6{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+6{{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
// expected-warning@+4 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+4 3{{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#BAZ 3{{conflicting attribute is here}}
// expected-note@#BAZ_INST 3{{in instantiation}}
// expected-note@+1 3{{in instantiation}}
@ -75,9 +75,9 @@ template<int ... D>
int variadic_baz(int x) {
// Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
// Dianoses DEP 3x, once per variadic expansion.
// expected-warning@+5 2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+5 2{{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP 2{{conflicting attribute is here}}
// expected-warning@+3 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+3 3{{statement attribute 'clang::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#DEP 3{{conflicting attribute is here}}
// expected-note@#VARIADIC_INST{{in instantiation}}
[[clang::noinline]] return non_dependent(x) + (dependent<D>(x) + ...);
@ -85,13 +85,13 @@ int variadic_baz(int x) {
template<int D> [[clang::always_inline]]
int qux(int x) { // #QUX
// expected-warning@+2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+2{{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
[[msvc::noinline]] non_dependent(x);
if constexpr (D>0) {
// expected-warning@+6{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+6{{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP{{conflicting attribute is here}}
// expected-warning@+4 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+4 3{{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#QUX 3{{conflicting attribute is here}}
// expected-note@#QUX_INST 3{{in instantiation}}
// expected-note@+1 3{{in instantiation}}
@ -105,9 +105,9 @@ template<int ... D>
int variadic_qux(int x) {
// Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
// Dianoses DEP 3x, once per variadic expansion.
// expected-warning@+5 2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+5 2{{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#NO_DEP 2{{conflicting attribute is here}}
// expected-warning@+3 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
// expected-warning@+3 3{{statement attribute 'msvc::noinline' has higher precedence than function attribute 'always_inline'}}
// expected-note@#DEP 3{{conflicting attribute is here}}
// expected-note@#QUX_VARIADIC_INST{{in instantiation}}
[[msvc::noinline]] return non_dependent(x) + (dependent<D>(x) + ...);

View File

@ -4,18 +4,18 @@ void bar();
void foo() {
[[clang::nomerge]] bar();
[[clang::nomerge(1, 2)]] bar(); // expected-error {{'nomerge' attribute takes no arguments}}
[[clang::nomerge(1, 2)]] bar(); // expected-error {{'clang::nomerge' attribute takes no arguments}}
int x;
[[clang::nomerge]] x = 10; // expected-warning {{'nomerge' attribute is ignored because there exists no call expression inside the statement}}
[[clang::nomerge]] x = 10; // expected-warning {{'clang::nomerge' attribute is ignored because there exists no call expression inside the statement}}
[[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}
[[clang::nomerge]] label: bar(); // expected-error {{'clang::nomerge' attribute only applies to functions, statements and variables}}
}
[[clang::nomerge]] int f();
[[clang::nomerge]] static int i = f(); // expected-warning {{'nomerge' attribute is ignored because 'i' is not a function pointer}}
[[clang::nomerge]] static int i = f(); // expected-warning {{'clang::nomerge' attribute is ignored because 'i' is not a function pointer}}
[[clang::nomerge]] void (*j)(void);
struct [[clang::nomerge]] buz {}; // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}
struct [[clang::nomerge]] buz {}; // expected-error {{'clang::nomerge' attribute only applies to functions, statements and variables}}

View File

@ -8,8 +8,8 @@
// --- ATTRIBUTE SYNTAX: SUBJECTS ---
int nl_var [[clang::nonblocking]]; // expected-warning {{'nonblocking' only applies to function types; type here is 'int'}}
struct nl_struct {} [[clang::nonblocking]]; // expected-warning {{attribute 'nonblocking' is ignored, place it after "struct" to apply attribute to type declaration}}
struct [[clang::nonblocking]] nl_struct2 {}; // expected-error {{'nonblocking' attribute cannot be applied to a declaration}}
struct nl_struct {} [[clang::nonblocking]]; // expected-warning {{attribute 'clang::nonblocking' is ignored, place it after "struct" to apply attribute to type declaration}}
struct [[clang::nonblocking]] nl_struct2 {}; // expected-error {{'clang::nonblocking' attribute cannot be applied to a declaration}}
// Positive case
typedef void (*fo)() [[clang::nonblocking]];
@ -19,10 +19,10 @@ void (*read_me_and_weep(
[[clang::nonblocking]];
// --- ATTRIBUTE SYNTAX: ARGUMENT COUNT ---
void nargs_1() [[clang::nonblocking(1, 2)]]; // expected-error {{'nonblocking' attribute takes no more than 1 argument}}
void nargs_2() [[clang::nonallocating(1, 2)]]; // expected-error {{'nonallocating' attribute takes no more than 1 argument}}
void nargs_3() [[clang::blocking(1)]]; // expected-error {{'blocking' attribute takes no arguments}}
void nargs_4() [[clang::allocating(1)]]; // expected-error {{'allocating' attribute takes no arguments}}
void nargs_1() [[clang::nonblocking(1, 2)]]; // expected-error {{'clang::nonblocking' attribute takes no more than 1 argument}}
void nargs_2() [[clang::nonallocating(1, 2)]]; // expected-error {{'clang::nonallocating' attribute takes no more than 1 argument}}
void nargs_3() [[clang::blocking(1)]]; // expected-error {{'clang::blocking' attribute takes no arguments}}
void nargs_4() [[clang::allocating(1)]]; // expected-error {{'clang::allocating' attribute takes no arguments}}
// --- ATTRIBUTE SYNTAX: COMBINATIONS ---
// Check invalid combinations of nonblocking/nonallocating attributes

View File

@ -6,20 +6,20 @@ using double_t __attribute__((available_only_in_default_eval_method)) = double;
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
class __attribute__((available_only_in_default_eval_method)) C1 {
};
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
// expected-error@+1{{'clang::available_only_in_default_eval_method' attribute only applies to typedefs}}
class [[clang::available_only_in_default_eval_method]] C2 {
};
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
// expected-error@+1{{'clang::available_only_in_default_eval_method' attribute only applies to typedefs}}
struct [[clang::available_only_in_default_eval_method]] S1;
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
struct __attribute__((available_only_in_default_eval_method)) S2;
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
void __attribute__((available_only_in_default_eval_method)) foo();
// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
// expected-error@+1{{'clang::available_only_in_default_eval_method' attribute cannot be applied to types}}
void [[clang::available_only_in_default_eval_method]] goo();
// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
// expected-error@+1{{'clang::available_only_in_default_eval_method' attribute cannot be applied to types}}
void bar() [[clang::available_only_in_default_eval_method]];
// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
void barz() __attribute__((available_only_in_default_eval_method));

View File

@ -9,9 +9,9 @@ struct A {
[[clang::preferred_type(bool)]] unsigned b4 : 1;
[[clang::preferred_type(bool)]] unsigned b5 : 2;
[[clang::preferred_type()]] unsigned b6 : 2;
// expected-error@-1 {{'preferred_type' attribute takes one argument}}
// expected-error@-1 {{'clang::preferred_type' attribute takes one argument}}
[[clang::preferred_type]] unsigned b7 : 2;
// expected-error@-1 {{'preferred_type' attribute takes one argument}}
// expected-error@-1 {{'clang::preferred_type' attribute takes one argument}}
[[clang::preferred_type(E, int)]] unsigned b8 : 2;
// expected-error@-1 {{expected ')'}}
// expected-error@-2 {{expected ','}}

View File

@ -14,4 +14,4 @@ void __attribute__((regparm(2))) x5(int); // expected-error{{function declared w
[[gnu::regparm(2)]] void x6(int); // expected-error{{function declared with regparm(2) attribute was previously declared with the regparm(3) attribute}}
void x6 [[gnu::regparm(3)]] (int);
void [[gnu::regparm(3)]] x6(int); // expected-warning{{'regparm' only applies to function types; type here is 'void'}}
void x6(int) [[gnu::regparm(3)]]; // expected-warning{{GCC does not allow the 'regparm' attribute to be written on a type}}
void x6(int) [[gnu::regparm(3)]]; // expected-warning{{GCC does not allow the 'gnu::regparm' attribute to be written on a type}}

View File

@ -4,7 +4,7 @@ struct A {};
typedef struct A *MPI_Datatype;
extern struct A datatype_wrong1 [[clang::type_tag_for_datatype]]; // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
extern struct A datatype_wrong1 [[clang::type_tag_for_datatype]]; // expected-error {{'clang::type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
extern struct A datatype_wrong2 [[clang::type_tag_for_datatype(mpi,1,2)]]; // expected-error {{expected a type}}
@ -22,7 +22,7 @@ extern struct A B_tag [[clang::type_tag_for_datatype(b,int)]];
static const int C_tag [[clang::type_tag_for_datatype(c,int)]] = 10;
static const int D_tag [[clang::type_tag_for_datatype(d,int)]] = 20;
[[clang::pointer_with_type_tag]] // expected-error {{'pointer_with_type_tag' attribute requires exactly 3 arguments}}
[[clang::pointer_with_type_tag]] // expected-error {{'clang::pointer_with_type_tag' attribute requires exactly 3 arguments}}
int wrong1(void *buf, MPI_Datatype datatype);
[[clang::pointer_with_type_tag(mpi,0,7)]] // expected-error {{attribute parameter 2 is out of bounds}}

View File

@ -9,14 +9,14 @@ void foo() {
for (i = 0; i < 10; ++i) { // this is OK
a[i] = b[i] = 0;
}
// expected-error@+1{{'code_align' attribute only applies to 'for', 'while', and 'do' statements}}
// expected-error@+1{{'clang::code_align' attribute only applies to 'for', 'while', and 'do' statements}}
[[clang::code_align(4)]]
i = 7;
for (i = 0; i < 10; ++i) {
a[i] = b[i] = 0;
}
// expected-error@+1{{'code_align' attribute cannot be applied to a declaration}}
// expected-error@+1{{'clang::code_align' attribute cannot be applied to a declaration}}
[[clang::code_align(12)]] int n[10];
}
@ -24,11 +24,11 @@ void bar(int);
// cpp-local-note@+1{{declared here}}
void foo1(int A)
{
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 0}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 0}}
[[clang::code_align(0)]]
for(int I=0; I<128; ++I) { bar(I); }
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -4}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -4}}
[[clang::code_align(-4)]]
for(int I=0; I<128; ++I) { bar(I); }
@ -37,11 +37,11 @@ void foo1(int A)
[[clang::code_align(64.0)]]
for(int I=0; I<128; ++I) { bar(I); }
// expected-error@+1{{'code_align' attribute takes one argument}}
// expected-error@+1{{'clang::code_align' attribute takes one argument}}
[[clang::code_align()]]
for(int I=0; I<128; ++I) { bar(I); }
// expected-error@+1{{'code_align' attribute takes one argument}}
// expected-error@+1{{'clang::code_align' attribute takes one argument}}
[[clang::code_align(4,8)]]
for(int I=0; I<128; ++I) { bar(I); }
@ -59,47 +59,47 @@ void foo1(int A)
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(8)]] // expected-note{{previous attribute is here}}
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(4)]] // expected-note{{previous attribute is here}}
[[clang::code_align(4)]] // OK
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(4)]] // expected-note 2{{previous attribute is here}}
[[clang::code_align(4)]] // OK
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'clang::code_align'}}
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 7}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 7}}
[[clang::code_align(7)]]
for(int I=0; I<128; ++I) { bar(I); }
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 5000}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 5000}}
[[clang::code_align(5000)]]
for(int I=0; I<128; ++I) { bar(I); }
// expected-warning@+2{{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -9223372036854775808}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -9223372036854775808}}
[[clang::code_align(9223372036854775808)]]
for(int I=0; I<256; ++I) { bar(I); }
#ifdef __SIZEOF_INT128__
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was '(__int128_t)1311768467294899680ULL << 64'}}
// expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was '(__int128_t)1311768467294899680ULL << 64'}}
[[clang::code_align((__int128_t)0x1234567890abcde0ULL << 64)]]
for(int I=0; I<256; ++I) { bar(I); }
#endif
// expected-error@+1 {{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -922337203685477}}
// expected-error@+1 {{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -922337203685477}}
[[clang::code_align(-922337203685477)]]
for(int I=0; I<256; ++I) { bar(I); }
#ifdef __SIZEOF_INT128__
// cpp-local-error@+3{{expression is not an integral constant expression}}
// cpp-local-note@+2{{left shift of negative value -1311768467294899680}}
// c-local-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was '-(__int128_t)1311768467294899680ULL << 64'}}
// c-local-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was '-(__int128_t)1311768467294899680ULL << 64'}}
[[clang::code_align(-(__int128_t)0x1234567890abcde0ULL << 64)]]
for(int I=0; I<256; ++I) { bar(I); }
#endif
@ -143,25 +143,25 @@ void code_align_dependent() {
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(A)]] // cpp-local-note{{previous attribute is here}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(A)]] // cpp-local-note{{previous attribute is here}}
[[clang::code_align(A)]] // OK
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
[[clang::code_align(A)]] // cpp-local-note 2{{previous attribute is here}}
[[clang::code_align(A)]] // OK
[[clang::code_align(C)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(C)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}}
for(int I=0; I<128; ++I) { bar(I); }
// cpp-local-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 23}}
// cpp-local-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 23}}
[[clang::code_align(B)]]
for(int I=0; I<128; ++I) { bar(I); }
// cpp-local-error@+2{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -10}}
// cpp-local-error@+2{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was -10}}
// cpp-local-note@#neg-instantiation{{in instantiation of function template specialization 'code_align_dependent<8, 23, 32, -10, 64>' requested here}}
[[clang::code_align(D)]]
for(int I=0; I<128; ++I) { bar(I); }
@ -170,7 +170,7 @@ void code_align_dependent() {
template<int ITMPL>
void bar3() {
[[clang::code_align(8)]] // cpp-local-note{{previous attribute is here}}
[[clang::code_align(ITMPL)]] // cpp-local-error{{conflicting loop attribute 'code_align'}} \
[[clang::code_align(ITMPL)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}} \
// cpp-local-note@#temp-instantiation{{in instantiation of function template specialization 'bar3<4>' requested here}}
for(int I=0; I<128; ++I) { bar(I); }
}
@ -178,7 +178,7 @@ void bar3() {
template<int ITMPL1>
void bar4() {
[[clang::code_align(ITMPL1)]] // cpp-local-note{{previous attribute is here}}
[[clang::code_align(32)]] // cpp-local-error{{conflicting loop attribute 'code_align'}} \
[[clang::code_align(32)]] // cpp-local-error{{conflicting loop attribute 'clang::code_align'}} \
// cpp-local-note@#temp-instantiation1{{in instantiation of function template specialization 'bar4<64>' requested here}}
for(int I=0; I<128; ++I) { bar(I); }
}

View File

@ -20,7 +20,7 @@ struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_link
__attribute__((internal_linkage("foo"))) int g(void) {} // 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}} \
int var7 [[clang::internal_linkage]] __attribute__((common)); // expected-error{{'clang::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}} \
__attribute__((common)) int var8 [[clang::internal_linkage]]; // expected-error{{'clang::internal_linkage' and 'common' attributes are not compatible}} \
// expected-note{{conflicting attribute is here}}

View File

@ -11,15 +11,15 @@ typedef unsigned ix3x3 __attribute__((matrix_type(3, 3)));
typedef float [[clang::matrix_type(5, 10)]] sx5x10_t; // expected-warning {{[[]] attributes are a C23 extension}}
typedef int [[clang::matrix_type(3, 2)]] ix3x2_t; // expected-warning {{[[]] attributes are a C23 extension}}
[[clang::matrix_type(5, 10)]] typedef float sx5x10_t; // expected-warning {{[[]] attributes are a C23 extension}}
// expected-warning@-1 {{applying attribute 'matrix_type' to a declaration is deprecated; apply it to the type instead}}
// expected-warning@-1 {{applying attribute 'clang::matrix_type' to a declaration is deprecated; apply it to the type instead}}
[[clang::matrix_type(3, 2)]] typedef int ix3x2_t; // expected-warning {{[[]] attributes are a C23 extension}}
// expected-warning@-1 {{applying attribute 'matrix_type' to a declaration is deprecated; apply it to the type instead}}
// expected-warning@-1 {{applying attribute 'clang::matrix_type' to a declaration is deprecated; apply it to the type instead}}
// Attribute may not be used outside typedefs.
[[clang::matrix_type(3, 2)]] int ix3x2_var; // expected-warning {{[[]] attributes are a C23 extension}}
// expected-error@-1 {{'matrix_type' attribute only applies to typedefs}}
// expected-error@-1 {{'clang::matrix_type' attribute only applies to typedefs}}
int [[clang::matrix_type(3, 2)]] ix3x2_var; // expected-warning {{[[]] attributes are a C23 extension}}
// expected-error@-1 {{'matrix_type' attribute only applies to typedefs}}
// expected-error@-1 {{'clang::matrix_type' attribute only applies to typedefs}}
void transpose(sx5x10_t a, ix3x2_t b, dx3x3 c, int *d, int e) {
a = __builtin_matrix_transpose(b);

View File

@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wincompatible-pointer-types -Wno-strict-prototypes
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
void bad_attr_target(int) [[clang::overloadable]]; // expected-error{{'overloadable' attribute cannot be applied to types}}
void bad_attr_target(int) [[clang::overloadable]]; // expected-error{{'clang::overloadable' attribute cannot be applied to types}}
void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}}
int *f(int) __attribute__((overloadable)); // expected-note{{previous overload of function is here}}
@ -268,4 +268,4 @@ void can_overload_2(...) __attribute__((overloadable)); // ok
[[clang::overloadable]] void can_overload_3(...); // ok, was previously rejected
void can_overload_4 [[clang::overloadable]] (...); // ok
void cannot_overload(...) [[clang::overloadable]]; // expected-error {{ISO C requires a named parameter before '...'}} \
// expected-error {{'overloadable' attribute cannot be applied to types}}
// expected-error {{'clang::overloadable' attribute cannot be applied to types}}

View File

@ -14,6 +14,6 @@
// silence-no-diagnostics
// AIX-error@+2 {{'patchable_function_entry' attribute is not yet supported on AIX}}
// AIX-error@+2 {{'gnu::patchable_function_entry' attribute is not yet supported on AIX}}
// expected-warning@+1 {{unknown attribute 'gnu::patchable_function_entry' ignored}}
[[gnu::patchable_function_entry(0)]] void f();

View File

@ -26,7 +26,7 @@ typedef int v2i32 [[gnu::vector_size(8)]]; // expected-warning{{[[]] attributes
// Check various positions where the [[]] spelling can or cannot be used.
[[gnu::vector_size(16)]] typedef long long v2i64; // expected-warning{{[[]] attributes are a C23 extension}}
typedef long long [[gnu::vector_size(16)]] v2i64_ignored;
// expected-warning@-1{{'vector_size' attribute ignored}}
// expected-warning@-1{{'gnu::vector_size' attribute ignored}}
// expected-warning@-2{{[[]] attributes are a C23 extension}}
// FIXME: Contrary to the error message that we emit, GCC does actually allow
// the attribute in the following position. Somewhat surprisingly, the attribute
@ -34,7 +34,7 @@ typedef long long [[gnu::vector_size(16)]] v2i64_ignored;
// the same effect in GCC as the other declarations for `v2i64`.
typedef long long *[[gnu::vector_size(16)]] v2i64_doesnt_work;
// expected-error@-1{{invalid vector element type 'long long *'}}
// expected-warning@-2{{GCC does not allow the 'vector_size' attribute to be written on a type}}
// expected-warning@-2{{GCC does not allow the 'gnu::vector_size' attribute to be written on a type}}
// expected-warning@-3{{[[]] attributes are a C23 extension}}
// Verify that we can use the attribute outside of a typedef.

View File

@ -1,10 +1,10 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
void foo [[clang::xray_always_instrument]] ();
struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and Objective-C methods}}
struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'clang::xray_always_instrument' attribute only applies to functions and Objective-C methods}}
class b {
void c [[clang::xray_always_instrument]] ();
};
void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'clang::xray_always_instrument' attribute takes no arguments}}

View File

@ -2,6 +2,6 @@
class Class {
[[clang::xray_always_instrument, clang::xray_log_args(1)]] void Method();
[[clang::xray_log_args(-1)]] void Invalid(); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
[[clang::xray_log_args("invalid")]] void InvalidStringArg(); // expected-error {{'xray_log_args'}}
[[clang::xray_log_args(-1)]] void Invalid(); // expected-error {{'clang::xray_log_args' attribute parameter 1 is out of bounds}}
[[clang::xray_log_args("invalid")]] void InvalidStringArg(); // expected-error {{'clang::xray_log_args'}}
};

View File

@ -1,9 +1,9 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
void foo [[clang::xray_log_args(1)]] (int);
struct [[clang::xray_log_args(1)]] a { int x; }; // expected-warning {{'xray_log_args' attribute only applies to functions and Objective-C methods}}
struct [[clang::xray_log_args(1)]] a { int x; }; // expected-warning {{'clang::xray_log_args' attribute only applies to functions and Objective-C methods}}
void fop [[clang::xray_log_args(1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
void fop [[clang::xray_log_args(1)]] (); // expected-error {{'clang::xray_log_args' attribute parameter 1 is out of bounds}}
void foq [[clang::xray_log_args(-1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
void foq [[clang::xray_log_args(-1)]] (); // expected-error {{'clang::xray_log_args' attribute parameter 1 is out of bounds}}
void fos [[clang::xray_log_args(0)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
void fos [[clang::xray_log_args(0)]] (); // expected-error {{'clang::xray_log_args' attribute parameter 1 is out of bounds}}

View File

@ -7,10 +7,10 @@ __device__ __attribute__((noconvergent)) float f1(float);
[[clang::noconvergent]] __device__ float f2(float);
__device__ [[clang::noconvergent(1)]] float f3(float);
// expected-error@-1 {{'noconvergent' attribute takes no arguments}}
// expected-error@-1 {{'clang::noconvergent' attribute takes no arguments}}
__device__ [[clang::noconvergent]] float g0;
// expected-warning@-1 {{'noconvergent' attribute only applies to functions and statements}}
// expected-warning@-1 {{'clang::noconvergent' attribute only applies to functions and statements}}
__device__ __attribute__((convergent)) __attribute__((noconvergent)) float f4(float);
// expected-error@-1 {{'noconvergent' and 'convergent' attributes are not compatible}}
@ -18,17 +18,17 @@ __device__ __attribute__((convergent)) __attribute__((noconvergent)) float f4(fl
__device__ [[clang::noconvergent]] float f5(float);
__device__ [[clang::convergent]] float f5(float);
// expected-error@-1 {{'convergent' and 'noconvergent' attributes are not compatible}}
// expected-error@-1 {{'clang::convergent' and 'clang::noconvergent' attributes are not compatible}}
// expected-note@-3 {{conflicting attribute is here}}
__device__ float f5(float x) {
[[clang::noconvergent]] float y;
// expected-warning@-1 {{'noconvergent' attribute only applies to functions and statements}}
// expected-warning@-1 {{'clang::noconvergent' attribute only applies to functions and statements}}
float z;
[[clang::noconvergent]] z = 1;
// expected-warning@-1 {{'noconvergent' attribute is ignored because there exists no call expression inside the statement}}
// expected-warning@-1 {{'clang::noconvergent' attribute is ignored because there exists no call expression inside the statement}}
[[clang::noconvergent]] z = f0(x);
}

View File

@ -5,5 +5,5 @@
}
void throw_int_wrapper() {
[[clang::musttail]] return throw_int(); // expected-error {{'musttail' attribute may not be used with no-return-attribute functions}}
[[clang::musttail]] return throw_int(); // expected-error {{'clang::musttail' attribute may not be used with no-return-attribute functions}}
}

View File

@ -4,18 +4,18 @@
// spelling of the `address_space` attribute is applied to a declaration instead
// of a type. Also check that the attribute can instead be applied to the type.
void f([[clang::address_space(1)]] int* param) { // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
[[clang::address_space(1)]] int* local1; // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
int* local2 [[clang::address_space(1)]]; // expected-error {{automatic variable qualified with an address space}} expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
void f([[clang::address_space(1)]] int* param) { // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
[[clang::address_space(1)]] int* local1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int* local2 [[clang::address_space(1)]]; // expected-error {{automatic variable qualified with an address space}} expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int [[clang::address_space(1)]] * local3;
int* [[clang::address_space(1)]] local4; // expected-error {{automatic variable qualified with an address space}}
for ([[clang::address_space(1)]] int* p = nullptr; p; ++p) {} // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
for (; [[clang::address_space(1)]] int* p = nullptr; ) {} // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
while([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
if ([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
for ([[clang::address_space(1)]] int* p = nullptr; p; ++p) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
for (; [[clang::address_space(1)]] int* p = nullptr; ) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
while([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
if ([[clang::address_space(1)]] int* p = nullptr) {} // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
try {
} catch([[clang::address_space(1)]] int& i) { // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
} catch([[clang::address_space(1)]] int& i) { // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
}
for (int [[clang::address_space(1)]] * p = nullptr; p; ++p) {}
@ -27,28 +27,28 @@ void f([[clang::address_space(1)]] int* param) { // expected-warning {{applying
}
}
[[clang::address_space(1)]] int* return_value(); // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
[[clang::address_space(1)]] int* return_value(); // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int [[clang::address_space(1)]] * return_value();
[[clang::address_space(1)]] int global1; // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
int global2 [[clang::address_space(1)]]; // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
[[clang::address_space(1)]] int global1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int global2 [[clang::address_space(1)]]; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int [[clang::address_space(1)]] global3;
int [[clang::address_space(1)]] global4;
struct [[clang::address_space(1)]] S { // expected-error {{'address_space' attribute cannot be applied to a declaration}}
[[clang::address_space(1)]] int* member_function_1(); // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
struct [[clang::address_space(1)]] S { // expected-error {{'clang::address_space' attribute cannot be applied to a declaration}}
[[clang::address_space(1)]] int* member_function_1(); // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
int [[clang::address_space(1)]] * member_function_2();
};
template <class T>
[[clang::address_space(1)]] T var_template_1; // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
[[clang::address_space(1)]] T var_template_1; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
template <class T>
T [[clang::address_space(1)]] var_template_2;
using void_ptr [[clang::address_space(1)]] = void *; // expected-warning {{applying attribute 'address_space' to a declaration is deprecated; apply it to the type instead}}
using void_ptr [[clang::address_space(1)]] = void *; // expected-warning {{applying attribute 'clang::address_space' to a declaration is deprecated; apply it to the type instead}}
// Intentionally using the same alias name to check that the aliases define the
// same type.
using void_ptr = void [[clang::address_space(1)]] *;
namespace N {}
[[clang::address_space(1)]] using namespace N; // expected-error {{'address_space' attribute cannot be applied to a declaration}}
[[clang::address_space(1)]] using namespace N; // expected-error {{'clang::address_space' attribute cannot be applied to a declaration}}

View File

@ -2,7 +2,7 @@
struct S1 {
void f() [[clang::annotate_type("foo")]];
[[clang::annotate_type("foo")]] void g(); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] void g(); // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
};
template <typename T1, typename T2> struct is_same {
@ -40,26 +40,26 @@ int f2() { variadic_func_template<1, 2, 3>(); }
// [[clang::annotate_type]] inside a template argument.
template <typename Ty> void func_template();
void f3() {
func_template<int [[clang::annotate_type()]]>(); // expected-error {{'annotate_type' attribute takes at least 1 argument}}
func_template<int [[clang::annotate_type()]]>(); // expected-error {{'clang::annotate_type' attribute takes at least 1 argument}}
}
// More error cases: Prohibit adding the attribute to declarations.
// Different declarations hit different code paths, so they need separate tests.
namespace [[clang::annotate_type("foo")]] my_namespace {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S3; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S3{ // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] int member; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
namespace [[clang::annotate_type("foo")]] my_namespace {} // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S3; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
struct [[clang::annotate_type("foo")]] S3{ // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] int member; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
};
void f4() {
for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
for (; [[clang::annotate_type("foo")]] bool b = false;) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
while ([[clang::annotate_type("foo")]] bool b = false) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
if ([[clang::annotate_type("foo")]] bool b = false) {} // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
for ([[clang::annotate_type("foo")]] int i = 0; i < 42; ++i) {} // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
for (; [[clang::annotate_type("foo")]] bool b = false;) {} // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
while ([[clang::annotate_type("foo")]] bool b = false) {} // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
if ([[clang::annotate_type("foo")]] bool b = false) {} // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
try {
} catch ([[clang::annotate_type("foo")]] int i) { // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
} catch ([[clang::annotate_type("foo")]] int i) { // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
}
}
template <class T>
[[clang::annotate_type("foo")]] T var_template; // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] T var_template; // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}
[[clang::annotate_type("foo")]] extern "C" int extern_c_func(); // expected-error {{an attribute list cannot appear here}}
extern "C" [[clang::annotate_type("foo")]] int extern_c_func(); // expected-error {{'annotate_type' attribute cannot be applied to a declaration}}
extern "C" [[clang::annotate_type("foo")]] int extern_c_func(); // expected-error {{'clang::annotate_type' attribute cannot be applied to a declaration}}

View File

@ -68,10 +68,10 @@ struct B {
// expected-note@-2 {{is not allowed in a constant expression}}
[[clang::annotate("qdwqwd", cf, cb)]] void t() {}
[[clang::annotate("qdwqwd", f, cb)]] void t1() {}
// expected-error@-1 {{'annotate' attribute requires parameter 1 to be a constant expression}}
// expected-error@-1 {{'clang::annotate' attribute requires parameter 1 to be a constant expression}}
// expected-note@-2 {{is not allowed in a constant expression}}
[[clang::annotate("jui", b, cf)]] void t2() {}
// expected-error@-1 {{'annotate' attribute requires parameter 1 to be a constant expression}}
// expected-error@-1 {{'clang::annotate' attribute requires parameter 1 to be a constant expression}}
// expected-note@-2 {{is not allowed in a constant expression}}
[[clang::annotate("jui", ((void)b, 0), cf)]] [[clang::annotate("jui", &b, cf, &foo::t2, str())]] void t3() {}
};
@ -88,7 +88,7 @@ template<int I>
int f() {
[[clang::annotate("test", I)]] int v = 0; // expected-note {{declared here}}
[[clang::annotate("test", v)]] int v2 = 0;
// expected-error@-1 {{'annotate' attribute requires parameter 1 to be a constant expression}}
// expected-error@-1 {{'clang::annotate' attribute requires parameter 1 to be a constant expression}}
// expected-note@-2 {{is not allowed in a constant expression}}
[[clang::annotate("test", rtyui)]] int v3 = 0;
// expected-error@-1 {{use of undeclared identifier 'rtyui'}}
@ -104,7 +104,7 @@ void f() {
int vla[n];
[[clang::annotate("vlas are awful", sizeof(vla))]] int i = 0; // reject, the sizeof is not unevaluated
// expected-error@-1 {{'annotate' attribute requires parameter 1 to be a constant expression}}
// expected-error@-1 {{'clang::annotate' attribute requires parameter 1 to be a constant expression}}
// expected-note@-2 {{subexpression not valid in a constant expression}}
[[clang::annotate("_Generic selection expression should be fine", _Generic(n, int : 0, default : 1))]]
int j = 0; // second arg should resolve to 0 fine
@ -126,13 +126,13 @@ constexpr int foldable_but_invalid() {
}
[[clang::annotate("", foldable_but_invalid())]] void f1() {}
// expected-error@-1 {{'annotate' attribute requires parameter 1 to be a constant expression}}
// expected-error@-1 {{'clang::annotate' attribute requires parameter 1 to be a constant expression}}
[[clang::annotate()]] void f2() {}
// expected-error@-1 {{'annotate' attribute takes at least 1 argument}}
// expected-error@-1 {{'clang::annotate' attribute takes at least 1 argument}}
template <typename T> [[clang::annotate()]] void f2() {}
// expected-error@-1 {{'annotate' attribute takes at least 1 argument}}
// expected-error@-1 {{'clang::annotate' attribute takes at least 1 argument}}
}
namespace test5 {

View File

@ -61,8 +61,8 @@ void b([[deprecated, maybe_unused]] void) {} // expected-warning {{attribute
// expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \
// expected-warning {{use of the 'deprecated' attribute is a C++14 extension}} \
// expected-warning {{use of the 'maybe_unused' attribute is a C++17 extension}}
void c([[clang::lifetimebound]] void) {} // expected-warning {{attribute 'lifetimebound' cannot be applied to a 'void' parameter}}
void d([[clang::annotate("a", "b", 1)]] void) {} // expected-warning {{attribute 'annotate' cannot be applied to a 'void' parameter}}
void c([[clang::lifetimebound]] void) {} // expected-warning {{attribute 'clang::lifetimebound' cannot be applied to a 'void' parameter}}
void d([[clang::annotate("a", "b", 1)]] void) {} // expected-warning {{attribute 'clang::annotate' cannot be applied to a 'void' parameter}}
struct S {
void e([[maybe_unused]] void) {} // expected-warning {{attribute 'maybe_unused' cannot be applied to a 'void' parameter}} \

View File

@ -33,18 +33,18 @@ namespace test1 {
// Also test [[]] attribute syntax. (On a non-nested declaration, these
// generate a hard "misplaced attributes" error, which we test for
// elsewhere.)
[[gnu::visibility("hidden")]] [[gnu::aligned]] class E; // expected-warning{{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "class" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] struct F; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] union G; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum H {H}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum class I {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum class" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "enum class" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum struct J {}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum struct" to apply attribute to type declaration}} \
// expected-warning{{attribute 'aligned' is ignored, place it after "enum struct" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] class E; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "class" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "class" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] struct F; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] union G; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "union" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum H {H}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum class I {}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum class" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum class" to apply attribute to type declaration}}
[[gnu::visibility("hidden")]] [[gnu::aligned]] enum struct J {}; // expected-warning{{attribute 'gnu::visibility' is ignored, place it after "enum struct" to apply attribute to type declaration}} \
// expected-warning{{attribute 'gnu::aligned' is ignored, place it after "enum struct" to apply attribute to type declaration}}
};
}

View File

@ -7,7 +7,7 @@
int a1 [[deprecated("warning", "fixit")]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
int a2 [[deprecated("warning", 1)]]; // expected-error{{expected string literal as argument of 'deprecated' attribute}}
int b1 [[gnu::deprecated("warning", "fixit")]]; // expected-error{{'deprecated' attribute takes no more than 1 argument}}
int b1 [[gnu::deprecated("warning", "fixit")]]; // expected-error{{'gnu::deprecated' attribute takes no more than 1 argument}}
int b2 [[gnu::deprecated("warning", 1)]]; // expected-error{{expected string literal as argument of 'deprecated' attribute}}
__declspec(deprecated("warning", "fixit")) int c1; // expected-error{{'deprecated' attribute takes no more than 1 argument}}

View File

@ -16,19 +16,19 @@ struct A {
static void mf2() __attribute__((flatten));
};
int ci [[gnu::flatten]]; // expected-error {{'flatten' attribute only applies to functions}}
int ci [[gnu::flatten]]; // expected-error {{'gnu::flatten' attribute only applies to functions}}
[[gnu::flatten]] void cf1();
[[gnu::flatten(1)]] void cf2(); // expected-error {{'flatten' attribute takes no arguments}}
[[gnu::flatten(1)]] void cf2(); // expected-error {{'gnu::flatten' attribute takes no arguments}}
template <typename T>
[[gnu::flatten]]
void ctf1();
int cf3(int c[[gnu::flatten]], int); // expected-error{{'flatten' attribute only applies to functions}}
int cf3(int c[[gnu::flatten]], int); // expected-error{{'gnu::flatten' attribute only applies to functions}}
struct CA {
int f [[gnu::flatten]]; // expected-error{{'flatten' attribute only applies to functions}}
int f [[gnu::flatten]]; // expected-error{{'gnu::flatten' attribute only applies to functions}}
[[gnu::flatten]] void mf1();
[[gnu::flatten]] static void mf2();
};

View File

@ -2,21 +2,21 @@
// RUN: FileCheck --implicit-check-not OwnerAttr --implicit-check-not PointerAttr %s
int [[gsl::Owner]] i;
// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
// expected-error@-1 {{'gsl::Owner' attribute cannot be applied to types}}
void [[gsl::Owner]] f();
// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
// expected-error@-1 {{'gsl::Owner' attribute cannot be applied to types}}
[[gsl::Owner]] void f();
// expected-warning@-1 {{'Owner' attribute only applies to structs}}
// expected-warning@-1 {{'gsl::Owner' attribute only applies to structs}}
union [[gsl::Owner(int)]] Union{};
// expected-warning@-1 {{'Owner' attribute only applies to structs}}
// expected-warning@-1 {{'gsl::Owner' attribute only applies to structs}}
struct S {
};
S [[gsl::Owner]] Instance;
// expected-error@-1 {{'Owner' attribute cannot be applied to types}}
// expected-error@-1 {{'gsl::Owner' attribute cannot be applied to types}}
class [[gsl::Owner(7)]] OwnerDerefNoType{};
// expected-error@-1 {{expected a type}}
@ -25,7 +25,7 @@ class [[gsl::Pointer("int")]] PointerDerefNoType{};
// expected-error@-1 {{expected a type}}
class [[gsl::Owner(int)]] [[gsl::Pointer(int)]] BothOwnerPointer{};
// expected-error@-1 {{'Pointer' and 'Owner' attributes are not compatible}}
// expected-error@-1 {{'gsl::Pointer' and 'gsl::Owner' attributes are not compatible}}
// expected-note@-2 {{conflicting attribute is here}}
// CHECK: CXXRecordDecl {{.*}} BothOwnerPointer
// CHECK: OwnerAttr {{.*}} int
@ -41,7 +41,7 @@ class [[gsl::Pointer(int)]] AddConflictLater{};
// CHECK: CXXRecordDecl {{.*}} AddConflictLater
// CHECK: PointerAttr {{.*}} int
class [[gsl::Owner(int)]] AddConflictLater;
// expected-error@-1 {{'Owner' and 'Pointer' attributes are not compatible}}
// expected-error@-1 {{'gsl::Owner' and 'gsl::Pointer' attributes are not compatible}}
// expected-note@-5 {{conflicting attribute is here}}
// CHECK: CXXRecordDecl {{.*}} AddConflictLater
// CHECK: PointerAttr {{.*}} Inherited int
@ -50,22 +50,22 @@ class [[gsl::Owner(int)]] AddConflictLater2{};
// CHECK: CXXRecordDecl {{.*}} AddConflictLater2
// CHECK: OwnerAttr {{.*}} int
class [[gsl::Owner(float)]] AddConflictLater2;
// expected-error@-1 {{'Owner' and 'Owner' attributes are not compatible}}
// expected-error@-1 {{'gsl::Owner' and 'gsl::Owner' attributes are not compatible}}
// expected-note@-5 {{conflicting attribute is here}}
// CHECK: CXXRecordDecl {{.*}} AddConflictLater
// CHECK: OwnerAttr {{.*}} Inherited int
class [[gsl::Owner()]] [[gsl::Owner(int)]] WithAndWithoutParameter{};
// expected-error@-1 {{'Owner' and 'Owner' attributes are not compatible}}
// expected-error@-1 {{'gsl::Owner' and 'gsl::Owner' attributes are not compatible}}
// expected-note@-2 {{conflicting attribute is here}}
// CHECK: CXXRecordDecl {{.*}} WithAndWithoutParameter
// CHECK: OwnerAttr
class [[gsl::Owner(int &)]] ReferenceType{};
// expected-error@-1 {{a reference type is an invalid argument to attribute 'Owner'}}
// expected-error@-1 {{a reference type is an invalid argument to attribute 'gsl::Owner'}}
class [[gsl::Pointer(int[])]] ArrayType{};
// expected-error@-1 {{an array type is an invalid argument to attribute 'Pointer'}}
// expected-error@-1 {{an array type is an invalid argument to attribute 'gsl::Pointer'}}
class [[gsl::Owner]] OwnerMissingParameter{};
// CHECK: CXXRecordDecl {{.*}} OwnerMissingParameter

View File

@ -8,7 +8,7 @@ struct S {
///////////////////////////
// Test for valid usages.
///////////////////////////
[[clang::lifetime_capture_by(unknown)]] // expected-error {{'lifetime_capture_by' attribute only applies to parameters and implicit object parameters}}
[[clang::lifetime_capture_by(unknown)]] // expected-error {{'clang::lifetime_capture_by' attribute only applies to parameters and implicit object parameters}}
void nonMember(
const int &x1 [[clang::lifetime_capture_by(s, t)]],
S &s,

View File

@ -10,24 +10,24 @@ namespace usage_invalid {
static int *static_class_member() [[clang::lifetimebound]]; // expected-error {{static member function has no implicit object parameter}}
int *explicit_object(this A&) [[clang::lifetimebound]]; // expected-error {{explicit object member function has no implicit object parameter}}
int attr_on_var [[clang::lifetimebound]]; // expected-error {{only applies to parameters and implicit object parameters}}
int [[clang::lifetimebound]] attr_on_int; // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int * [[clang::lifetimebound]] attr_on_int_ptr; // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int * [[clang::lifetimebound]] * attr_on_int_ptr_ptr; // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (* [[clang::lifetimebound]] attr_on_func_ptr)(); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int [[clang::lifetimebound]] attr_on_int; // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int * [[clang::lifetimebound]] attr_on_int_ptr; // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int * [[clang::lifetimebound]] * attr_on_int_ptr_ptr; // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (* [[clang::lifetimebound]] attr_on_func_ptr)(); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
void void_return_member() [[clang::lifetimebound]]; // expected-error {{'lifetimebound' attribute cannot be applied to an implicit object parameter of a function that returns void; did you mean 'lifetime_capture_by(X)'}}
};
int *attr_with_param(int &param [[clang::lifetimebound(42)]]); // expected-error {{takes no arguments}}
void attr_on_ptr_arg(int * [[clang::lifetimebound]] ptr); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
static_assert((int [[clang::lifetimebound]]) 12); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int* attr_on_unnamed_arg(const int& [[clang::lifetimebound]]); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
void attr_on_ptr_arg(int * [[clang::lifetimebound]] ptr); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
static_assert((int [[clang::lifetimebound]]) 12); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int* attr_on_unnamed_arg(const int& [[clang::lifetimebound]]); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
template <typename T>
int* attr_on_template_ptr_arg(T * [[clang::lifetimebound]] ptr); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int* attr_on_template_ptr_arg(T * [[clang::lifetimebound]] ptr); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (*func_ptr)(int) [[clang::lifetimebound]]; // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (*(*func_ptr_ptr)(int) [[clang::lifetimebound]])(int); // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (*func_ptr)(int) [[clang::lifetimebound]]; // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (*(*func_ptr_ptr)(int) [[clang::lifetimebound]])(int); // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
struct X {};
int (X::*member_func_ptr)(int) [[clang::lifetimebound]]; // expected-error {{'lifetimebound' attribute only applies to parameters and implicit object parameters}}
int (X::*member_func_ptr)(int) [[clang::lifetimebound]]; // expected-error {{'clang::lifetimebound' attribute only applies to parameters and implicit object parameters}}
}
namespace usage_ok {

View File

@ -1,14 +1,14 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
int i [[clang::lto_visibility_public]]; // expected-warning {{'lto_visibility_public' attribute only applies to structs, unions, and classes}}
typedef int t [[clang::lto_visibility_public]]; // expected-warning {{'lto_visibility_public' attribute only applies to}}
[[clang::lto_visibility_public]] void f(); // expected-warning {{'lto_visibility_public' attribute only applies to}}
void f() [[clang::lto_visibility_public]]; // expected-error {{'lto_visibility_public' attribute cannot be applied to types}}
int i [[clang::lto_visibility_public]]; // expected-warning {{'clang::lto_visibility_public' attribute only applies to structs, unions, and classes}}
typedef int t [[clang::lto_visibility_public]]; // expected-warning {{'clang::lto_visibility_public' attribute only applies to}}
[[clang::lto_visibility_public]] void f(); // expected-warning {{'clang::lto_visibility_public' attribute only applies to}}
void f() [[clang::lto_visibility_public]]; // expected-error {{'clang::lto_visibility_public' attribute cannot be applied to types}}
struct [[clang::lto_visibility_public]] s1 {
int i [[clang::lto_visibility_public]]; // expected-warning {{'lto_visibility_public' attribute only applies to}}
[[clang::lto_visibility_public]] void f(); // expected-warning {{'lto_visibility_public' attribute only applies to}}
int i [[clang::lto_visibility_public]]; // expected-warning {{'clang::lto_visibility_public' attribute only applies to}}
[[clang::lto_visibility_public]] void f(); // expected-warning {{'clang::lto_visibility_public' attribute only applies to}}
};
struct [[clang::lto_visibility_public(1)]] s2 { // expected-error {{'lto_visibility_public' attribute takes no arguments}}
struct [[clang::lto_visibility_public(1)]] s2 { // expected-error {{'clang::lto_visibility_public' attribute takes no arguments}}
};

View File

@ -2,33 +2,33 @@
int ReturnsInt1();
int Func1() {
[[clang::musttail]] ReturnsInt1(); // expected-error {{'musttail' attribute only applies to return statements}}
[[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'musttail' attribute takes no arguments}}
[[clang::musttail]] return 5; // expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
[[clang::musttail]] ReturnsInt1(); // expected-error {{'clang::musttail' attribute only applies to return statements}}
[[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'clang::musttail' attribute takes no arguments}}
[[clang::musttail]] return 5; // expected-error {{'clang::musttail' attribute requires that the return value is the result of a function call}}
[[clang::musttail]] return ReturnsInt1();
}
void NoFunctionCall() {
[[clang::musttail]] return; // expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
[[clang::musttail]] return; // expected-error {{'clang::musttail' attribute requires that the return value is the result of a function call}}
}
[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'musttail' attribute cannot be applied to a declaration}}
[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'clang::musttail' attribute cannot be applied to a declaration}}
void NoParams(); // expected-note {{target function has different number of parameters (expected 1 but has 0)}}
void TestParamArityMismatch(int x) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return NoParams(); // expected-error {{cannot perform a tail call to function 'NoParams' because its signature is incompatible with the calling function}}
}
void LongParam(long x); // expected-note {{target function has type mismatch at 1st parameter (expected 'long' but has 'int')}}
void TestParamTypeMismatch(int x) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return LongParam(x); // expected-error {{cannot perform a tail call to function 'LongParam' because its signature is incompatible with the calling function}}
}
long ReturnsLong(); // expected-note {{target function has different return type ('int' expected but has 'long')}}
int TestReturnTypeMismatch() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return ReturnsLong(); // expected-error {{cannot perform a tail call to function 'ReturnsLong' because its signature is incompatible with the calling function}}
}
@ -37,14 +37,14 @@ struct Struct1 {
};
void TestNonMemberToMember() {
Struct1 st;
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return st.MemberFunction(); // expected-error {{non-member function cannot perform a tail call to non-static member function 'MemberFunction'}}
}
void ReturnsVoid(); // expected-note {{'ReturnsVoid' declared here}}
struct Struct2 {
void TestMemberToNonMember() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return ReturnsVoid(); // expected-error{{non-static member function cannot perform a tail call to non-member function 'ReturnsVoid'}}
}
};
@ -75,7 +75,7 @@ HasNonTrivialDestructor TestReturnsNonTrivialValue() {
}
HasNonTrivialDestructor TestReturnsNonTrivialNonFunctionCall() {
[[clang::musttail]] return HasNonTrivialDestructor(); // expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
[[clang::musttail]] return HasNonTrivialDestructor(); // expected-error {{'clang::musttail' attribute requires that the return value is the result of a function call}}
}
struct UsesPointerToMember {
@ -83,7 +83,7 @@ struct UsesPointerToMember {
};
void TestUsesPointerToMember(UsesPointerToMember *foo) {
// "this" pointer cannot double as first parameter.
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return (foo->*(foo->p_mem))(); // expected-error {{non-member function cannot perform a tail call to pointer-to-member function 'p_mem'}}
}
@ -107,7 +107,7 @@ int OkTemplateFunc(int x) {
}
template <class T>
T BadTemplateFunc(T x) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return TemplateFunc<int>(x); // expected-error {{cannot perform a tail call to function 'TemplateFunc' because its signature is incompatible with the calling function}}
}
long TestBadTemplateFunc(long x) {
@ -126,17 +126,17 @@ void TestNonTrivialDestructorSubArg(int x) {
void VariadicFunction(int x, ...);
void TestVariadicFunction(int x, ...) {
[[clang::musttail]] return VariadicFunction(x); // expected-error {{'musttail' attribute may not be used with variadic functions}}
[[clang::musttail]] return VariadicFunction(x); // expected-error {{'clang::musttail' attribute may not be used with variadic functions}}
}
int TakesIntParam(int x); // expected-note {{target function has type mismatch at 1st parameter (expected 'int' but has 'short')}}
int TakesShortParam(short x); // expected-note {{target function has type mismatch at 1st parameter (expected 'short' but has 'int')}}
int TestIntParamMismatch(int x) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return TakesShortParam(x); // expected-error {{cannot perform a tail call to function 'TakesShortParam' because its signature is incompatible with the calling function}}
}
int TestIntParamMismatch2(short x) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return TakesIntParam(x); // expected-error {{cannot perform a tail call to function 'TakesIntParam' because its signature is incompatible with the calling function}}
}
@ -146,20 +146,20 @@ struct TestClassMismatch1 {
TestClassMismatch1 *tcm1;
struct TestClassMismatch2 {
void FromFunction() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return tcm1->ToFunction(); // expected-error {{cannot perform a tail call to function 'ToFunction' because its signature is incompatible with the calling function}}
}
};
__regcall int RegCallReturnsInt(); // expected-note {{target function has calling convention regcall (expected cdecl)}}
int TestMismatchCallingConvention() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return RegCallReturnsInt(); // expected-error {{cannot perform a tail call to function 'RegCallReturnsInt' because it uses an incompatible calling convention}}
}
int TestNonCapturingLambda() {
auto lambda = []() { return 12; }; // expected-note {{'operator()' declared here}}
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return lambda(); // expected-error {{non-member function cannot perform a tail call to non-static member function 'operator()'}}
// This works.
@ -171,7 +171,7 @@ int TestNonCapturingLambda() {
int TestCapturingLambda() {
int x;
auto lambda = [x]() { return 12; }; // expected-note {{'operator()' declared here}}
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return lambda(); // expected-error {{non-member function cannot perform a tail call to non-static member function 'operator()'}}
}
@ -182,14 +182,14 @@ int TestNonTrivialTemporary(int) {
void ReturnsVoid();
struct TestDestructor {
~TestDestructor() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return ReturnsVoid(); // expected-error {{destructor '~TestDestructor' must not return void expression}} // expected-error {{cannot perform a tail call from a destructor}}
}
};
struct ClassWithDestructor { // expected-note {{target destructor is declared here}}
void TestExplicitDestructorCall() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return this->~ClassWithDestructor(); // expected-error {{cannot perform a tail call to a destructor}}
}
};
@ -201,14 +201,14 @@ HasNonTrivialCopyConstructor ReturnsClassByValue();
HasNonTrivialCopyConstructor TestNonElidableCopyConstructor() {
// This is an elidable constructor, but when it is written explicitly
// we decline to elide it.
[[clang::musttail]] return HasNonTrivialCopyConstructor(ReturnsClassByValue()); // expected-error{{'musttail' attribute requires that the return value is the result of a function call}}
[[clang::musttail]] return HasNonTrivialCopyConstructor(ReturnsClassByValue()); // expected-error{{'clang::musttail' attribute requires that the return value is the result of a function call}}
}
struct ClassWithConstructor {
ClassWithConstructor() = default; // expected-note {{target constructor is declared here}}
};
void TestExplicitConstructorCall(ClassWithConstructor a) {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return a.ClassWithConstructor::ClassWithConstructor(); // expected-error{{cannot perform a tail call to a constructor}} expected-warning{{explicit constructor calls are a Microsoft extension}}
}
@ -230,14 +230,14 @@ void TestTryBlock() {
using IntFunctionType = int();
IntFunctionType *ReturnsIntFunction();
long TestRValueFunctionPointer() {
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return ReturnsIntFunction()(); // expected-error{{cannot perform a tail call to function because its signature is incompatible with the calling function}} // expected-note{{target function has different return type ('long' expected but has 'int')}}
}
void TestPseudoDestructor() {
int n;
using T = int;
[[clang::musttail]] // expected-note {{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note {{tail call required by 'clang::musttail' attribute here}}
return n.~T(); // expected-error{{cannot perform a tail call to a destructor}}
}
@ -249,7 +249,7 @@ struct StructPMF {
StructPMF *St;
StructPMF::PMF ReturnsPMF();
void StructPMF::TestReturnsPMF() {
[[clang::musttail]] // expected-note{{tail call required by 'musttail' attribute here}}
[[clang::musttail]] // expected-note{{tail call required by 'clang::musttail' attribute here}}
return (St->*ReturnsPMF())(); // expected-error{{static member function cannot perform a tail call to pointer-to-member function}}
}

View File

@ -4,15 +4,15 @@
# error
#endif
struct [[clang::no_specializations]] S {}; // expected-warning {{'no_specializations' attribute only applies to class templates, function templates, and variable templates}}
struct [[clang::no_specializations]] S {}; // expected-warning {{'clang::no_specializations' attribute only applies to class templates, function templates, and variable templates}}
template <class T, class U>
struct [[clang::no_specializations]] is_same { // expected-note 2 {{marked 'no_specializations' here}}
struct [[clang::no_specializations]] is_same { // expected-note 2 {{marked 'clang::no_specializations' here}}
static constexpr bool value = __is_same(T, U);
};
template <class T>
using alias [[clang::no_specializations]] = T; // expected-warning {{'no_specializations' attribute only applies to class templates, function templates, and variable templates}}
using alias [[clang::no_specializations]] = T; // expected-warning {{'clang::no_specializations' attribute only applies to class templates, function templates, and variable templates}}
template <>
struct is_same<int, char> {}; // expected-error {{'is_same' cannot be specialized}}
@ -26,7 +26,7 @@ struct is_same<Template<T>, Template <T>> {}; // expected-error {{'is_same' cann
bool test_instantiation1 = is_same<int, int>::value;
template <class T, class U>
[[clang::no_specializations]] inline constexpr bool is_same_v = __is_same(T, U); // expected-note 2 {{marked 'no_specializations' here}}
[[clang::no_specializations]] inline constexpr bool is_same_v = __is_same(T, U); // expected-note 2 {{marked 'clang::no_specializations' here}}
template <>
inline constexpr bool is_same_v<int, char> = false; // expected-error {{'is_same_v' cannot be specialized}}
@ -37,7 +37,7 @@ inline constexpr bool is_same_v<Template <T>, Template <T>> = true; // expected-
bool test_instantiation2 = is_same_v<int, int>;
template <class T>
struct [[clang::no_specializations("specializing type traits results in undefined behaviour")]] is_trivial { // expected-note {{marked 'no_specializations' here}}
struct [[clang::no_specializations("specializing type traits results in undefined behaviour")]] is_trivial { // expected-note {{marked 'clang::no_specializations' here}}
static constexpr bool value = __is_trivial(T);
};
@ -45,7 +45,7 @@ template <>
struct is_trivial<int> {}; // expected-error {{'is_trivial' cannot be specialized: specializing type traits results in undefined behaviour}}
template <class T>
[[clang::no_specializations("specializing type traits results in undefined behaviour")]] inline constexpr bool is_trivial_v = __is_trivial(T); // expected-note {{marked 'no_specializations' here}}
[[clang::no_specializations("specializing type traits results in undefined behaviour")]] inline constexpr bool is_trivial_v = __is_trivial(T); // expected-note {{marked 'clang::no_specializations' here}}
template <>
inline constexpr bool is_trivial_v<int> = false; // expected-error {{'is_trivial_v' cannot be specialized: specializing type traits results in undefined behaviour}}
@ -54,9 +54,9 @@ template <class T>
struct Partial {};
template <class T>
struct [[clang::no_specializations]] Partial<Template <T>> {}; // expected-warning {{'no_specializations' attribute only applies to class templates, function templates, and variable templates}}
struct [[clang::no_specializations]] Partial<Template <T>> {}; // expected-warning {{'clang::no_specializations' attribute only applies to class templates, function templates, and variable templates}}
template <class T>
[[clang::no_specializations]] void func(); // expected-note {{marked 'no_specializations' here}}
[[clang::no_specializations]] void func(); // expected-note {{marked 'clang::no_specializations' here}}
template <> void func<int>(); // expected-error {{'func' cannot be specialized}}

View File

@ -16,19 +16,19 @@ struct A {
static void mf2() __attribute__((no_speculative_load_hardening));
};
int ci [[clang::no_speculative_load_hardening]]; // expected-error {{'no_speculative_load_hardening' attribute only applies to functions}}
int ci [[clang::no_speculative_load_hardening]]; // expected-error {{'clang::no_speculative_load_hardening' attribute only applies to functions}}
[[clang::no_speculative_load_hardening]] void cf1();
[[clang::no_speculative_load_hardening(1)]] void cf2(); // expected-error {{'no_speculative_load_hardening' attribute takes no arguments}}
[[clang::no_speculative_load_hardening(1)]] void cf2(); // expected-error {{'clang::no_speculative_load_hardening' attribute takes no arguments}}
template <typename T>
[[clang::no_speculative_load_hardening]]
void ctf1();
int cf3(int c[[clang::no_speculative_load_hardening]], int); // expected-error {{'no_speculative_load_hardening' attribute only applies to functions}}
int cf3(int c[[clang::no_speculative_load_hardening]], int); // expected-error {{'clang::no_speculative_load_hardening' attribute only applies to functions}}
struct CA {
int f [[clang::no_speculative_load_hardening]]; // expected-error {{'no_speculative_load_hardening' attribute only applies to functions}}
int f [[clang::no_speculative_load_hardening]]; // expected-error {{'clang::no_speculative_load_hardening' attribute only applies to functions}}
[[clang::no_speculative_load_hardening]] void mf1();
[[clang::no_speculative_load_hardening]] static void mf2();
};

View File

@ -16,19 +16,19 @@ struct A {
static void mf2() __attribute__((no_split_stack));
};
int ci [[gnu::no_split_stack]]; // expected-error {{'no_split_stack' attribute only applies to functions}}
int ci [[gnu::no_split_stack]]; // expected-error {{'gnu::no_split_stack' attribute only applies to functions}}
[[gnu::no_split_stack]] void cf1();
[[gnu::no_split_stack(1)]] void cf2(); // expected-error {{'no_split_stack' attribute takes no arguments}}
[[gnu::no_split_stack(1)]] void cf2(); // expected-error {{'gnu::no_split_stack' attribute takes no arguments}}
template <typename T>
[[gnu::no_split_stack]]
void ctf1();
int cf3(int c[[gnu::no_split_stack]], int); // expected-error{{'no_split_stack' attribute only applies to functions}}
int cf3(int c[[gnu::no_split_stack]], int); // expected-error{{'gnu::no_split_stack' attribute only applies to functions}}
struct CA {
int f [[gnu::no_split_stack]]; // expected-error{{'no_split_stack' attribute only applies to functions}}
int f [[gnu::no_split_stack]]; // expected-error{{'gnu::no_split_stack' attribute only applies to functions}}
[[gnu::no_split_stack]] void mf1();
[[gnu::no_split_stack]] static void mf2();
};

View File

@ -58,10 +58,10 @@ int bar2() __attribute__((noinline));
[[clang::optnone]] // expected-note {{conflicting}}
int baz2() __attribute__((always_inline)); // expected-warning{{'always_inline' attribute ignored}}
[[clang::optnone]] int globalVar2; //expected-warning{{'optnone' attribute only applies to functions}}
[[clang::optnone]] int globalVar2; //expected-warning{{'clang::optnone' attribute only applies to functions}}
struct A2 {
[[clang::optnone]] int aField; // expected-warning{{'optnone' attribute only applies to functions}}
[[clang::optnone]] int aField; // expected-warning{{'clang::optnone' attribute only applies to functions}}
};
struct B2 {
@ -78,4 +78,4 @@ struct B2 {
[[clang::__optnone__]] int foo5();
[[_Clang::__optnone__]] int foo6();
[[_Clang::optnone]] int foo7; // expected-warning {{'optnone' attribute only applies to functions}}
[[_Clang::optnone]] int foo7; // expected-warning {{'clang::optnone' attribute only applies to functions}}

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
[[clang::reinitializes]] int a; // expected-error {{'reinitializes' attribute only applies to non-static non-const member functions}}
[[clang::reinitializes]] int a; // expected-error {{'clang::reinitializes' attribute only applies to non-static non-const member functions}}
[[clang::reinitializes]] void f(); // expected-error {{only applies to}}
@ -11,5 +11,5 @@ struct A {
[[clang::reinitializes]] static void baz(); // expected-error {{only applies to}}
[[clang::reinitializes]] int a; // expected-error {{only applies to}}
[[clang::reinitializes("arg")]] void qux(); // expected-error {{'reinitializes' attribute takes no arguments}}
[[clang::reinitializes("arg")]] void qux(); // expected-error {{'clang::reinitializes' attribute takes no arguments}}
};

View File

@ -26,19 +26,19 @@ void f6() __attribute__((no_speculative_load_hardening)); // expected-note {{con
void f6() __attribute__((speculative_load_hardening)); // expected-error {{'speculative_load_hardening' and 'no_speculative_load_hardening' attributes are not compatible}}
int ci [[clang::speculative_load_hardening]]; // expected-error {{'speculative_load_hardening' attribute only applies to functions}}
int ci [[clang::speculative_load_hardening]]; // expected-error {{'clang::speculative_load_hardening' attribute only applies to functions}}
[[clang::speculative_load_hardening]] void cf1();
[[clang::speculative_load_hardening(1)]] void cf2(); // expected-error {{'speculative_load_hardening' attribute takes no arguments}}
[[clang::speculative_load_hardening(1)]] void cf2(); // expected-error {{'clang::speculative_load_hardening' attribute takes no arguments}}
template <typename T>
[[clang::speculative_load_hardening]]
void ctf1();
int cf3(int c[[clang::speculative_load_hardening]], int); // expected-error {{'speculative_load_hardening' attribute only applies to functions}}
int cf3(int c[[clang::speculative_load_hardening]], int); // expected-error {{'clang::speculative_load_hardening' attribute only applies to functions}}
struct CA {
int f [[clang::speculative_load_hardening]]; // expected-error {{'speculative_load_hardening' attribute only applies to functions}}
int f [[clang::speculative_load_hardening]]; // expected-error {{'clang::speculative_load_hardening' attribute only applies to functions}}
[[clang::speculative_load_hardening]] void mf1();
[[clang::speculative_load_hardening]] static void mf2();
};
@ -53,5 +53,5 @@ struct CA {
void cf6(); // expected-note@-1 {{conflicting attribute is here}}
[[clang::no_speculative_load_hardening]]
void cf6(); // expected-error@-1 {{'no_speculative_load_hardening' and 'speculative_load_hardening' attributes are not compatible}} \
void cf6(); // expected-error@-1 {{'clang::no_speculative_load_hardening' and 'clang::speculative_load_hardening' attributes are not compatible}} \

View File

@ -12,9 +12,9 @@ namespace N {
p = reinterpret_cast<int *>(7);
}
[[gsl::suppress]] int x; // expected-error {{'suppress' attribute takes at least 1 argument}}
[[gsl::suppress()]] int y; // expected-error {{'suppress' attribute takes at least 1 argument}}
int [[gsl::suppress("r")]] z; // expected-error {{'suppress' attribute cannot be applied to types}}
[[gsl::suppress]] int x; // expected-error {{'gsl::suppress' attribute takes at least 1 argument}}
[[gsl::suppress()]] int y; // expected-error {{'gsl::suppress' attribute takes at least 1 argument}}
int [[gsl::suppress("r")]] z; // expected-error {{'gsl::suppress' attribute cannot be applied to types}}
[[gsl::suppress(f_)]] float f; // expected-error {{expected string literal as argument of 'suppress' attribute}}
}
@ -48,7 +48,7 @@ namespace N {
}
int [[clang::suppress("r")]] z;
// expected-error@-1 {{'suppress' attribute cannot be applied to types}}
// expected-error@-1 {{'clang::suppress' attribute cannot be applied to types}}
[[clang::suppress(foo)]] float f;
// expected-error@-1 {{expected string literal as argument of 'suppress' attribute}}
}
@ -60,5 +60,5 @@ class [[clang::suppress("type.1")]] V {
// FIXME: There's no good reason why we shouldn't support this case.
// But it doesn't look like clang generally supports such attributes yet.
class W : [[clang::suppress]] public V { // expected-error{{'suppress' attribute cannot be applied to a base specifier}}
class W : [[clang::suppress]] public V { // expected-error{{'clang::suppress' attribute cannot be applied to a base specifier}}
};

View File

@ -3,4 +3,4 @@
// Function annotations.
[[clang::unsafe_buffer_usage]]
void f(int *buf, int size);
void g(int *buffer [[clang::unsafe_buffer_usage("buffer")]], int size); // expected-warning {{'unsafe_buffer_usage' attribute only applies to functions}}
void g(int *buffer [[clang::unsafe_buffer_usage("buffer")]], int size); // expected-warning {{'clang::unsafe_buffer_usage' attribute only applies to functions}}

View File

@ -12,7 +12,7 @@ using NS::x [[deprecated]]; // expected-warni
using NS::x __attribute__((deprecated)); // expected-warning {{'deprecated' currently has no effect on a using declaration}}
using NS::x __attribute__((availability(macos,introduced=1))); // expected-warning {{'availability' currently has no effect on a using declaration}}
[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'availability' currently has no effect on a using declaration}} expected-warning{{ISO C++ does not allow}}
[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'clang::availability' currently has no effect on a using declaration}} expected-warning{{ISO C++ does not allow}}
// expected-warning@+1 3 {{ISO C++ does not allow an attribute list to appear here}}
[[clang::annotate("A")]] using NS::x [[clang::annotate("Y")]], NS::x [[clang::annotate("Z")]];

View File

@ -5,22 +5,22 @@
[[gnu::this_attribute_does_not_exist]] int unknown_attr;
// expected-warning@-1 {{unknown attribute 'gnu::this_attribute_does_not_exist' ignored}}
int [[gnu::unused]] attr_on_type;
// expected-error@-1 {{'unused' attribute cannot be applied to types}}
// expected-error@-1 {{'gnu::unused' attribute cannot be applied to types}}
int *[[gnu::unused]] attr_on_ptr;
// expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
// expected-warning@-1 {{attribute 'gnu::unused' ignored, because it cannot be applied to a type}}
[[gnu::fastcall]] void pr17424_1();
// expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}
[[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();
// expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
// expected-warning@-2 {{'stdcall' calling convention is not supported for this target}}
// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}
// expected-warning@-2 {{'gnu::stdcall' calling convention is not supported for this target}}
[[gnu::fastcall]] __stdcall void pr17424_3();
// expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}
// expected-warning@-2 {{'__stdcall' calling convention is not supported for this target}}
[[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];
// expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
// expected-warning@-2 {{'stdcall' calling convention is not supported for this target}}
// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}
// expected-warning@-2 {{'gnu::stdcall' calling convention is not supported for this target}}
void pr17424_5 [[gnu::fastcall]]();
// expected-warning@-1 {{'fastcall' calling convention is not supported for this target}}
// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}
// Valid cases.

View File

@ -41,7 +41,7 @@ int A::y;
void A::f1() {
}
void g(int a [[clang::internal_linkage]]) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
void g(int a [[clang::internal_linkage]]) { // expected-warning{{'clang::internal_linkage' attribute only applies to variables, functions and classes}}
int x [[clang::internal_linkage]]; // expected-warning{{'internal_linkage' attribute on a non-static local variable is ignored}}
static int y [[clang::internal_linkage]];
}

View File

@ -17,7 +17,7 @@ struct D1 : virtual B1 { // expected-note {{virtual base class declared here}}
[[msvc::constexpr]] D1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
};
struct [[msvc::constexpr]] S2{}; // expected-error {{'constexpr' attribute only applies to functions and return statements}}
struct [[msvc::constexpr]] S2{}; // expected-error {{'msvc::constexpr' attribute only applies to functions and return statements}}
// Check invalid code mixed with valid code
@ -38,10 +38,10 @@ static_assert(f7()); // expected-error {{static assertion expression is not an i
// expected-note {{in call to 'f7()'}}
constexpr bool f8() { // expected-error {{constexpr function never produces a constant expression}}
[[msvc::constexpr]] f4(32); // expected-error {{'constexpr' attribute only applies to functions and return statements}} \
[[msvc::constexpr]] f4(32); // expected-error {{'msvc::constexpr' attribute only applies to functions and return statements}} \
// expected-note {{non-constexpr function 'f4' cannot be used in a constant expression}} \
// expected-note {{non-constexpr function 'f4' cannot be used in a constant expression}}
[[msvc::constexpr]] int i5 = f4(32); // expected-error {{'constexpr' attribute only applies to functions and return statements}}
[[msvc::constexpr]] int i5 = f4(32); // expected-error {{'msvc::constexpr' attribute only applies to functions and return statements}}
return i5 == 5;
}
static_assert(f8()); // expected-error {{static assertion expression is not an integral constant expression}} \

View File

@ -3,12 +3,12 @@
// supported-no-diagnostics
[[nodiscard]]
[[msvc::constexpr]] // unsupported-warning {{unknown attribute 'constexpr' ignored}}
[[msvc::constexpr]] // unsupported-warning {{unknown attribute 'msvc::constexpr' ignored}}
inline void* operator new(decltype(sizeof(void*)), void* p) noexcept { return p; }
namespace std {
constexpr int* construct_at(int* p, int v) {
[[msvc::constexpr]] return ::new (p) int(v); // unsupported-warning {{unknown attribute 'constexpr' ignored}}
[[msvc::constexpr]] return ::new (p) int(v); // unsupported-warning {{unknown attribute 'msvc::constexpr' ignored}}
}
}
@ -16,7 +16,7 @@ constexpr bool check_std_construct_at() { int x; return *std::construct_at(&x, 4
static_assert(check_std_construct_at());
constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new (p) int(v); } // unsupported-error {{constexpr function never produces a constant expression}} \
// unsupported-warning {{unknown attribute 'constexpr' ignored}} \
// unsupported-warning {{unknown attribute 'msvc::constexpr' ignored}} \
// unsupported-note 2{{this placement new expression is not supported in constant expressions before C++2c}}
constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 42; } // unsupported-note {{in call to 'construct_at(&x, 42)'}}
static_assert(check_construct_at()); // unsupported-error {{static assertion expression is not an integral constant expression}}\

View File

@ -28,14 +28,14 @@ int main() {
[[clang::always_destroy]] static int p4;
}
[[clang::always_destroy]] [[clang::no_destroy]] int p; // expected-error{{'no_destroy' and 'always_destroy' attributes are not compatible}} // expected-note{{here}}
[[clang::no_destroy]] [[clang::always_destroy]] int p2; // expected-error{{'always_destroy' and 'no_destroy' attributes are not compatible}} // expected-note{{here}}
[[clang::always_destroy]] [[clang::no_destroy]] int p; // expected-error{{'clang::no_destroy' and 'clang::always_destroy' attributes are not compatible}} // expected-note{{here}}
[[clang::no_destroy]] [[clang::always_destroy]] int p2; // expected-error{{'clang::always_destroy' and 'clang::no_destroy' attributes are not compatible}} // expected-note{{here}}
[[clang::always_destroy]] void f() {} // expected-warning{{'always_destroy' attribute only applies to variables}}
struct [[clang::no_destroy]] DoesntApply {}; // expected-warning{{'no_destroy' attribute only applies to variables}}
[[clang::always_destroy]] void f() {} // expected-warning{{'clang::always_destroy' attribute only applies to variables}}
struct [[clang::no_destroy]] DoesntApply {}; // expected-warning{{'clang::no_destroy' attribute only applies to variables}}
[[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' attribute takes no arguments}}
[[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' attribute takes no arguments}}
[[clang::no_destroy(0)]] int no_args; // expected-error{{'clang::no_destroy' attribute takes no arguments}}
[[clang::always_destroy(0)]] int no_args2; // expected-error{{'clang::always_destroy' attribute takes no arguments}}
// expected-error@+1 {{temporary of type 'SecretDestructor' has private destructor}}
SecretDestructor arr[10];

View File

@ -326,16 +326,16 @@ int fallthrough_placement_error(int n) {
int fallthrough_targets(int n) {
[[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}}
[[clang::fallthrough]] // expected-error{{'fallthrough' attribute only applies to empty statements}}
[[clang::fallthrough]] // expected-error{{'clang::fallthrough' attribute only applies to empty statements}}
switch (n) {
case 121:
n += 400;
[[clang::fallthrough]]; // no warning here, correct target
case 123:
[[clang::fallthrough]] // expected-error{{'fallthrough' attribute only applies to empty statements}}
[[clang::fallthrough]] // expected-error{{'clang::fallthrough' attribute only applies to empty statements}}
n += 800;
break;
[[clang::fallthrough]] // expected-error{{'fallthrough' attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}}
[[clang::fallthrough]] // expected-error{{'clang::fallthrough' attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}}
case 125:
n += 1600;
}

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-pc-win32 -Wgcc-compat -std=c++11 -verify %s
void f() [[gnu::cdecl]] {} // expected-warning {{GCC does not allow the 'cdecl' attribute to be written on a type}}
void g() [[gnu::stdcall]] {} // expected-warning {{GCC does not allow the 'stdcall' attribute to be written on a type}}
void i() [[gnu::fastcall]] {} // expected-warning {{GCC does not allow the 'fastcall' attribute to be written on a type}}
void f() [[gnu::cdecl]] {} // expected-warning {{GCC does not allow the 'gnu::cdecl' attribute to be written on a type}}
void g() [[gnu::stdcall]] {} // expected-warning {{GCC does not allow the 'gnu::stdcall' attribute to be written on a type}}
void i() [[gnu::fastcall]] {} // expected-warning {{GCC does not allow the 'gnu::fastcall' attribute to be written on a type}}

View File

@ -1508,7 +1508,7 @@ struct InheritWithExplicit<Special> {
void aggregate() {
struct NonAgg {
NonAgg() { }
[[clang::require_explicit_initialization]] int na; // expected-warning {{'require_explicit_initialization' attribute is ignored in non-aggregate type 'NonAgg'}}
[[clang::require_explicit_initialization]] int na; // expected-warning {{'clang::require_explicit_initialization' attribute is ignored in non-aggregate type 'NonAgg'}}
};
NonAgg nonagg; // no-warning
(void)nonagg;
@ -1717,7 +1717,7 @@ void aggregate() {
InheritWithExplicit<> agg; // expected-warning {{field in 'InheritWithExplicit<>' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_G2 {{'g2' declared here}}
(void)agg;
InheritWithExplicit<Polymorphic> polymorphic; // expected-warning@#FIELD_G2 {{'require_explicit_initialization' attribute is ignored in non-aggregate type 'InheritWithExplicit<Polymorphic>'}}
InheritWithExplicit<Polymorphic> polymorphic; // expected-warning@#FIELD_G2 {{'clang::require_explicit_initialization' attribute is ignored in non-aggregate type 'InheritWithExplicit<Polymorphic>'}}
(void)polymorphic;
Inherit<Special> specialized_explicit; // expected-warning {{field in 'Inherit<Special>' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_G3 {{'g3' declared here}}

View File

@ -12,7 +12,7 @@ namespace basic {
}
TEST_AUTH(NoParams);
// expected-error@-1{{'ptrauth_vtable_pointer' attribute takes at least 3 arguments}}
// expected-error@-1{{'clang::ptrauth_vtable_pointer' attribute takes at least 3 arguments}}
TEST_AUTH(NoAuth, no_authentication, default_address_discrimination, default_extra_discrimination);
TEST_AUTH(InvalidKey, wat, default_address_discrimination, default_extra_discrimination);
// expected-error@-1{{invalid authentication key 'wat'}}
@ -26,7 +26,7 @@ TEST_AUTH(InvalidCustomDiscrimination, no_authentication, default_address_discri
// expected-error@-1{{invalid custom discrimination}}
TEST_AUTH(Default, default_key, default_address_discrimination, default_extra_discrimination);
TEST_AUTH(InvalidDefaultExtra, default_key, default_address_discrimination, default_extra_discrimination, 1);
// expected-error@-1{{'ptrauth_vtable_pointer' attribute takes no more than 3 arguments}}
// expected-error@-1{{'clang::ptrauth_vtable_pointer' attribute takes no more than 3 arguments}}
TEST_AUTH(ProcessDependentKey, process_dependent, default_address_discrimination, default_extra_discrimination);
TEST_AUTH(ProcessIndependentKey, process_independent, default_address_discrimination, default_extra_discrimination);
TEST_AUTH(DefaultAddressDiscrimination, process_independent, default_address_discrimination, default_extra_discrimination);

View File

@ -108,7 +108,7 @@ void lazy() {
(void)DoAnotherThing();
(void)DoYetAnotherThing();
DoSomething(); // expected-warning {{ignoring return value of type 'Status' declared with 'warn_unused_result'}}
DoSomething(); // expected-warning {{ignoring return value of type 'Status' declared with 'clang::warn_unused_result'}}
DoSomethingElse();
DoAnotherThing();
DoYetAnotherThing();
@ -120,11 +120,11 @@ class [[clang::warn_unused_result]] StatusOr {
StatusOr<int> doit();
void test() {
Foo f;
f.doStuff(); // expected-warning {{ignoring return value of type 'Status' declared with 'warn_unused_result'}}
doit(); // expected-warning {{ignoring return value of type 'StatusOr<int>' declared with 'warn_unused_result'}}
f.doStuff(); // expected-warning {{ignoring return value of type 'Status' declared with 'clang::warn_unused_result'}}
doit(); // expected-warning {{ignoring return value of type 'StatusOr<int>' declared with 'clang::warn_unused_result'}}
auto func = []() { return Status(); };
func(); // expected-warning {{ignoring return value of type 'Status' declared with 'warn_unused_result'}}
func(); // expected-warning {{ignoring return value of type 'Status' declared with 'clang::warn_unused_result'}}
}
}
@ -139,7 +139,7 @@ struct Status {};
void Bar() {
Foo f;
f.Bar(); // expected-warning {{ignoring return value of type 'Status' declared with 'warn_unused_result'}}
f.Bar(); // expected-warning {{ignoring return value of type 'Status' declared with 'clang::warn_unused_result'}}
};
}
@ -215,18 +215,18 @@ P operator--(const P &) { return {}; };
void f() {
S s;
P p;
s.DoThing(); // expected-warning {{ignoring return value of type 'S' declared with 'warn_unused_result'}}
p.DoThing(); // expected-warning {{ignoring return value of type 'P' declared with 'warn_unused_result'}}
s.DoThing(); // expected-warning {{ignoring return value of type 'S' declared with 'clang::warn_unused_result'}}
p.DoThing(); // expected-warning {{ignoring return value of type 'P' declared with 'clang::warn_unused_result'}}
// Only postfix is expected to warn when written correctly.
s++; // expected-warning {{ignoring return value of type 'S' declared with 'warn_unused_result'}}
s--; // expected-warning {{ignoring return value of type 'S' declared with 'warn_unused_result'}}
p++; // expected-warning {{ignoring return value of type 'P' declared with 'warn_unused_result'}}
p--; // expected-warning {{ignoring return value of type 'P' declared with 'warn_unused_result'}}
s++; // expected-warning {{ignoring return value of type 'S' declared with 'clang::warn_unused_result'}}
s--; // expected-warning {{ignoring return value of type 'S' declared with 'clang::warn_unused_result'}}
p++; // expected-warning {{ignoring return value of type 'P' declared with 'clang::warn_unused_result'}}
p--; // expected-warning {{ignoring return value of type 'P' declared with 'clang::warn_unused_result'}}
// Improperly written prefix operators should still warn.
++s; // expected-warning {{ignoring return value of type 'S' declared with 'warn_unused_result'}}
--s; // expected-warning {{ignoring return value of type 'S' declared with 'warn_unused_result'}}
++p; // expected-warning {{ignoring return value of type 'P' declared with 'warn_unused_result'}}
--p; // expected-warning {{ignoring return value of type 'P' declared with 'warn_unused_result'}}
++s; // expected-warning {{ignoring return value of type 'S' declared with 'clang::warn_unused_result'}}
--s; // expected-warning {{ignoring return value of type 'S' declared with 'clang::warn_unused_result'}}
++p; // expected-warning {{ignoring return value of type 'P' declared with 'clang::warn_unused_result'}}
--p; // expected-warning {{ignoring return value of type 'P' declared with 'clang::warn_unused_result'}}
// Silencing the warning by cast to void still works.
(void)s.DoThing();
@ -243,7 +243,7 @@ namespace PR39837 {
void g() {
int a[2];
for (int b : a)
f(b); // expected-warning {{ignoring return value of function declared with 'warn_unused_result'}}
f(b); // expected-warning {{ignoring return value of function declared with 'clang::warn_unused_result'}}
}
} // namespace PR39837
@ -261,12 +261,12 @@ typedef a indirect;
a af1();
indirect indirectf1();
void af2() {
af1(); // expected-warning {{ignoring return value of type 'a' declared with 'warn_unused_result'}}
af1(); // expected-warning {{ignoring return value of type 'a' declared with 'clang::warn_unused_result'}}
void *(*a1)();
a1(); // no warning
a (*a2)();
a2(); // expected-warning {{ignoring return value of type 'a' declared with 'warn_unused_result'}}
indirectf1(); // expected-warning {{ignoring return value of type 'a' declared with 'warn_unused_result'}}
a2(); // expected-warning {{ignoring return value of type 'a' declared with 'clang::warn_unused_result'}}
indirectf1(); // expected-warning {{ignoring return value of type 'a' declared with 'clang::warn_unused_result'}}
}
[[nodiscard]] typedef void *b1; // expected-warning {{'[[nodiscard]]' attribute ignored when applied to a typedef; consider using '__attribute__((warn_unused_result))' or '[[clang::warn_unused_result]]' instead}}
[[gnu::warn_unused_result]] typedef void *b2; // expected-warning {{'[[gnu::warn_unused_result]]' attribute ignored when applied to a typedef; consider using '__attribute__((warn_unused_result))' or '[[clang::warn_unused_result]]' instead}}
@ -305,7 +305,7 @@ __attribute__((warn_unused_result)) S<T> obtain3(const T&) { return {2}; }
void use() {
obtain(1.0); // no warning
obtain(1); // expected-warning {{ignoring return value of type 'S<int>' declared with 'nodiscard'}}
obtain<const double>(1); // expected-warning {{ignoring return value of type 'S<const double>' declared with 'warn_unused_result'}}
obtain<const double>(1); // expected-warning {{ignoring return value of type 'S<const double>' declared with 'clang::warn_unused_result'}}
S<double>(2); // no warning
S<int>(2); // expected-warning {{ignoring temporary of type 'S<int>' declared with 'nodiscard'}}
@ -347,7 +347,7 @@ void use2() {
// here, constructor/function should take precedence over type
G{2}; // expected-warning {{ignoring temporary of type 'G' declared with 'nodiscard'}}
G(2.0); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard'}}
G("Hello"); // expected-warning {{ignoring temporary created by a constructor declared with 'warn_unused_result'}}
G("Hello"); // expected-warning {{ignoring temporary created by a constructor declared with 'clang::warn_unused_result'}}
// no warning for explicit cast to void
(void)G(2);

View File

@ -1,24 +1,24 @@
// RUN: %clang_cc1 -triple spirv-unkown-vulkan1.3-compute -x hlsl -hlsl-entry foo -finclude-default-header -o - %s -verify
// expected-error@+1 {{'ext_builtin_input' attribute only applies to static const globals}}
// expected-error@+1 {{'vk::ext_builtin_input' attribute only applies to static const globals}}
[[vk::ext_builtin_input(/* WorkgroupId */ 26)]]
const uint3 groupid1;
// expected-error@+1 {{'ext_builtin_input' attribute only applies to static const globals}}
// expected-error@+1 {{'vk::ext_builtin_input' attribute only applies to static const globals}}
[[vk::ext_builtin_input(/* WorkgroupId */ 26)]]
static uint3 groupid2;
// expected-error@+1 {{'ext_builtin_input' attribute takes one argument}}
// expected-error@+1 {{'vk::ext_builtin_input' attribute takes one argument}}
[[vk::ext_builtin_input()]]
// expected-error@+1 {{default initialization of an object of const type 'const hlsl_private uint3' (aka 'const hlsl_private vector<uint, 3>')}}
static const uint3 groupid3;
// expected-error@+1 {{'ext_builtin_input' attribute requires an integer constant}}
// expected-error@+1 {{'vk::ext_builtin_input' attribute requires an integer constant}}
[[vk::ext_builtin_input(0.4f)]]
// expected-error@+1 {{default initialization of an object of const type 'const hlsl_private uint3' (aka 'const hlsl_private vector<uint, 3>')}}
static const uint3 groupid4;
// expected-error@+1 {{'ext_builtin_input' attribute only applies to static const globals}}
// expected-error@+1 {{'vk::ext_builtin_input' attribute only applies to static const globals}}
[[vk::ext_builtin_input(1)]]
void some_function() {
}

View File

@ -2,7 +2,7 @@
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.8-compute -verify %s
#ifndef __spirv__
// expected-warning@+2{{'constant_id' attribute ignored}}
// expected-warning@+2{{'vk::constant_id' attribute ignored}}
#endif
[[vk::constant_id(0)]]
const bool sc0 = true;
@ -12,7 +12,7 @@ const bool sc0 = true;
[[vk::constant_id(1)]]
const bool sc1 = sc0; // error
// expected-warning@+1{{'constant_id' attribute only applies to external global variables}}
// expected-warning@+1{{'vk::constant_id' attribute only applies to external global variables}}
[[vk::constant_id(2)]]
static const bool sc2 = false; // error
@ -30,7 +30,7 @@ const int2 sc5 = {0,0}; // error
[numthreads(1,1,1)]
void main() {
// expected-warning@+1{{'constant_id' attribute only applies to external global variables}}
// expected-warning@+1{{'vk::constant_id' attribute only applies to external global variables}}
[[vk::constant_id(6)]]
const bool sc6 = false; // error
}

View File

@ -19,8 +19,8 @@ static WEAK int h; // expected-warning {{'objc_ownership' only applies to Object
ak int i;
static id [[clang::objc_gc(weak)]] j;
[[clang::objc_gc(weak)]] static id k; // expected-warning {{applying attribute 'objc_gc' to a declaration is deprecated; apply it to the type instead}}
static id l [[clang::objc_gc(weak)]]; // expected-warning {{applying attribute 'objc_gc' to a declaration is deprecated; apply it to the type instead}}
[[clang::objc_gc(weak)]] static id k; // expected-warning {{applying attribute 'clang::objc_gc' to a declaration is deprecated; apply it to the type instead}}
static id l [[clang::objc_gc(weak)]]; // expected-warning {{applying attribute 'clang::objc_gc' to a declaration is deprecated; apply it to the type instead}}
void test2(id __attribute((objc_gc(strong))) *strong,
id __attribute((objc_gc(weak))) *weak) {

View File

@ -3,7 +3,7 @@
#ifndef __SYCL_DEVICE_ONLY__
// expected-warning@+7 {{'sycl_kernel' attribute ignored}}
// expected-warning@+8 {{'sycl_kernel' attribute ignored}}
// expected-warning@+8 {{'clang::sycl_kernel' attribute ignored}}
#else
// expected-no-diagnostics
#endif

View File

@ -1,17 +1,17 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
// Only function templates
[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'clang::sycl_kernel' attribute only applies to function templates}}
__attribute__((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
__attribute__((sycl_kernel)) void foo(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
[[clang::sycl_kernel]] void foo1(); // expected-warning {{'sycl_kernel' attribute only applies to function templates}}
[[clang::sycl_kernel]] void foo1(); // expected-warning {{'clang::sycl_kernel' attribute only applies to function templates}}
// Attribute takes no arguments
template <typename T, typename A>
__attribute__((sycl_kernel(1))) void foo(T P); // expected-error {{'sycl_kernel' attribute takes no arguments}}
template <typename T, typename A, int I>
[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'sycl_kernel' attribute takes no arguments}}
[[clang::sycl_kernel(1)]] void foo1(T P);// expected-error {{'clang::sycl_kernel' attribute takes no arguments}}
// At least two template parameters
template <typename T>

View File

@ -64,14 +64,14 @@ struct __attribute__((sycl_special_class)) struct7 {
};
// Only classes
[[clang::sycl_special_class]] int var1 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
[[clang::sycl_special_class]] int var1 = 0; // expected-warning {{'clang::sycl_special_class' attribute only applies to classes}}
__attribute__((sycl_special_class)) int var2 = 0; // expected-warning {{'sycl_special_class' attribute only applies to classes}}
[[clang::sycl_special_class]] void foo1(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
[[clang::sycl_special_class]] void foo1(); // expected-warning {{'clang::sycl_special_class' attribute only applies to classes}}
__attribute__((sycl_special_class)) void foo2(); // expected-warning {{'sycl_special_class' attribute only applies to classes}}
// Attribute takes no arguments
class [[clang::sycl_special_class(1)]] class9{}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
class [[clang::sycl_special_class(1)]] class9{}; // expected-error {{'clang::sycl_special_class' attribute takes no arguments}}
class __attribute__((sycl_special_class(1))) class10 {}; // expected-error {{'sycl_special_class' attribute takes no arguments}}
// __init method must be defined inside the CXXRecordDecl.

View File

@ -150,14 +150,14 @@ template<int> struct BADKN;
struct B1 {
// Non-static data member declaration.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
[[clang::sycl_kernel_entry_point(BADKN<1>)]]
int bad1;
};
struct B2 {
// Static data member declaration.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
[[clang::sycl_kernel_entry_point(BADKN<2>)]]
static int bad2;
};
@ -169,42 +169,42 @@ struct B3 {
void bad3();
};
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
namespace [[clang::sycl_kernel_entry_point(BADKN<4>)]] bad4 {}
#if __cplusplus >= 202002L
// expected-error@+2 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+2 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
template<typename>
concept bad5 [[clang::sycl_kernel_entry_point(BADKN<5>)]] = true;
#endif
// Type alias declarations.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
typedef void bad6 [[clang::sycl_kernel_entry_point(BADKN<6>)]] ();
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
using bad7 [[clang::sycl_kernel_entry_point(BADKN<7>)]] = void();
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
using bad8 [[clang::sycl_kernel_entry_point(BADKN<8>)]] = int;
// expected-error@+1 {{'sycl_kernel_entry_point' attribute cannot be applied to types}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute cannot be applied to types}}
using bad9 = int [[clang::sycl_kernel_entry_point(BADKN<9>)]];
// expected-error@+1 {{'sycl_kernel_entry_point' attribute cannot be applied to types}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute cannot be applied to types}}
using bad10 = int() [[clang::sycl_kernel_entry_point(BADKN<10>)]];
// Variable declaration.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
[[clang::sycl_kernel_entry_point(BADKN<11>)]]
int bad11;
// Class declaration.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
struct [[clang::sycl_kernel_entry_point(BADKN<12>)]] bad12;
// Enumeration declaration.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
enum [[clang::sycl_kernel_entry_point(BADKN<13>)]] bad13 {};
// Enumerator.
// expected-error@+2 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+2 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
enum {
bad14 [[clang::sycl_kernel_entry_point(BADKN<14>)]]
};
@ -222,7 +222,7 @@ void bad15();
int bad16();
// Function parameters.
// expected-error@+1 {{'sycl_kernel_entry_point' attribute only applies to functions}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute only applies to functions}}
void bad17(void (fp [[clang::sycl_kernel_entry_point(BADKN<17>)]])());
// Function template parameters.
@ -276,7 +276,7 @@ consteval void bad25() {}
[[clang::sycl_kernel_entry_point(BADKN<26>)]]
[[noreturn]] void bad26();
// expected-error@+3 {{attribute 'target' multiversioning cannot be combined with attribute 'sycl_kernel_entry_point'}}
// expected-error@+3 {{attribute 'target' multiversioning cannot be combined with attribute 'clang::sycl_kernel_entry_point'}}
__attribute__((target("avx"))) void bad27();
[[clang::sycl_kernel_entry_point(BADKN<27>)]]
__attribute__((target("sse4.2"))) void bad27();

View File

@ -74,10 +74,10 @@ void test_ok13() {
// Invalid declarations.
////////////////////////////////////////////////////////////////////////////////
// expected-error@+1 {{'sycl_kernel_entry_point' attribute takes one argument}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute takes one argument}}
[[clang::sycl_kernel_entry_point]] void bad1();
// expected-error@+1 {{'sycl_kernel_entry_point' attribute takes one argument}}
// expected-error@+1 {{'clang::sycl_kernel_entry_point' attribute takes one argument}}
[[clang::sycl_kernel_entry_point()]] void bad2();
struct B3;

View File

@ -6,11 +6,11 @@
// A unique kernel name type is required for each declared kernel entry point.
template<int> struct KN;
// expected-warning@+1 {{'sycl_kernel_entry_point' attribute ignored}}
// expected-warning@+1 {{'clang::sycl_kernel_entry_point' attribute ignored}}
[[clang::sycl_kernel_entry_point(KN<1>)]]
void ok1();
// expected-warning@+2 {{'sycl_kernel_entry_point' attribute ignored}}
// expected-warning@+2 {{'clang::sycl_kernel_entry_point' attribute ignored}}
template<typename KNT>
[[clang::sycl_kernel_entry_point(KNT)]]
void ok2() {}

View File

@ -572,14 +572,14 @@ void UseRedeclaredAnnotatedFunc() {
namespace preferred_name {
int x [[clang::preferred_name("frank")]]; // expected-error {{expected a type}}
int y [[clang::preferred_name(int)]]; // expected-warning {{'preferred_name' attribute only applies to class templates}}
struct [[clang::preferred_name(int)]] A; // expected-warning {{'preferred_name' attribute only applies to class templates}}
template<typename T> struct [[clang::preferred_name(int)]] B; // expected-error {{argument 'int' to 'preferred_name' attribute is not a typedef for a specialization of 'B'}}
int y [[clang::preferred_name(int)]]; // expected-warning {{'clang::preferred_name' attribute only applies to class templates}}
struct [[clang::preferred_name(int)]] A; // expected-warning {{'clang::preferred_name' attribute only applies to class templates}}
template<typename T> struct [[clang::preferred_name(int)]] B; // expected-error {{argument 'int' to 'clang::preferred_name' attribute is not a typedef for a specialization of 'B'}}
template<typename T> struct C;
using X = C<int>; // expected-note {{'X' declared here}}
typedef C<float> Y;
using Z = const C<double>; // expected-note {{'Z' declared here}}
template<typename T> struct [[clang::preferred_name(C<int>)]] C; // expected-error {{argument 'C<int>' to 'preferred_name' attribute is not a typedef for a specialization of 'C'}}
template<typename T> struct [[clang::preferred_name(C<int>)]] C; // expected-error {{argument 'C<int>' to 'clang::preferred_name' attribute is not a typedef for a specialization of 'C'}}
template<typename T> struct [[clang::preferred_name(X), clang::preferred_name(Y)]] C;
template<typename T> struct [[clang::preferred_name(const X)]] C; // expected-error {{argument 'const X'}}
template<typename T> struct [[clang::preferred_name(Z)]] C; // expected-error {{argument 'Z' (aka 'const C<double>')}}