r173788 - Downgrade 'attribute ignored when parsing type' from error to warning, to match
Richard Smith
richard-llvm at metafoo.co.uk
Tue Jan 29 02:02:16 PST 2013
Author: rsmith
Date: Tue Jan 29 04:02:16 2013
New Revision: 173788
URL: http://llvm.org/viewvc/llvm-project?rev=173788&view=rev
Log:
Downgrade 'attribute ignored when parsing type' from error to warning, to match
the diagnostic's warn_ name. Switch some places (notably C++11 attributes)
which really wanted an error over to a different diagnostic. Finally, suppress
the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing
diagnostics in important system headers.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.c
cfe/trunk/test/Parser/cxx0x-attributes.cpp
cfe/trunk/test/Sema/callingconv.c
cfe/trunk/test/Sema/types.c
cfe/trunk/test/SemaCXX/attr-cxx0x.cpp
cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Tue Jan 29 04:02:16 2013
@@ -77,6 +77,8 @@ def err_module_cycle : Error<"cyclic dep
def note_pragma_entered_here : Note<"#pragma entered here">;
def note_decl_hiding_tag_type : Note<
"%1 %0 is hidden by a non-type declaration of %0 here">;
+def err_attribute_not_type_attr : Error<
+ "%0 attribute cannot be applied to types">;
// Sema && Lex
def ext_c99_longlong : Extension<
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 29 04:02:16 2013
@@ -1857,8 +1857,6 @@ def err_attribute_wrong_decl_type : Erro
"functions, methods, and parameters|classes|variables|methods|"
"variables, functions and labels|fields and global variables|structs|"
"variables, functions and tag types|thread-local variables}1">;
-def err_attribute_not_type_attr : Error<
- "'%0' attribute cannot be applied to types">;
def warn_function_attribute_wrong_type : Warning<
"'%0' only applies to function types; type here is %1">,
InGroup<IgnoredAttributes>;
@@ -1899,11 +1897,11 @@ def err_objc_precise_lifetime_bad_type :
def warn_objc_precise_lifetime_meaningless : Error<
"objc_precise_lifetime is not meaningful for "
"%select{__unsafe_unretained|__autoreleasing}0 objects">;
-def err_invalid_pcs : Error<"Invalid PCS type">;
+def err_invalid_pcs : Error<"invalid PCS type">;
def err_attribute_can_be_applied_only_to_value_decl : Error<
"%0 attribute can only be applied to value declarations">;
-def warn_attribute_not_on_decl : Error<
- "%0 attribute ignored when parsing type">;
+def warn_attribute_not_on_decl : Warning<
+ "%0 attribute ignored when parsing type">, InGroup<IgnoredAttributes>;
// Availability attribute
def warn_availability_unknown_platform : Warning<
Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Jan 29 04:02:16 2013
@@ -229,8 +229,15 @@ public:
IdentifierInfo *getParameterName() const { return ParmName; }
SourceLocation getParameterLoc() const { return ParmLoc; }
+ bool isAlignasAttribute() const {
+ // FIXME: Use a better mechanism to determine this.
+ return getKind() == AT_Aligned && SyntaxUsed == AS_Keyword;
+ }
+
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
- bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11; }
+ bool isCXX11Attribute() const {
+ return SyntaxUsed == AS_CXX11 || isAlignasAttribute();
+ }
bool isKeywordAttribute() const { return SyntaxUsed == AS_Keyword; }
bool isInvalid() const { return Invalid; }
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Jan 29 04:02:16 2013
@@ -1151,7 +1151,7 @@ void Parser::ProhibitCXX11Attributes(Par
AttributeList *AttrList = attrs.getList();
while (AttrList) {
if (AttrList->isCXX11Attribute()) {
- Diag(AttrList->getLoc(), diag::warn_attribute_no_decl)
+ Diag(AttrList->getLoc(), diag::err_attribute_not_type_attr)
<< AttrList->getName();
AttrList->setInvalid();
}
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Jan 29 04:02:16 2013
@@ -439,8 +439,8 @@ Decl *Parser::ParseUsingDirective(unsign
/// unqualified-id
/// 'using' :: unqualified-id
///
-/// alias-declaration: C++0x [decl.typedef]p2
-/// 'using' identifier = type-id ;
+/// alias-declaration: C++11 [dcl.dcl]p1
+/// 'using' identifier attribute-specifier-seq[opt] = type-id ;
///
Decl *Parser::ParseUsingDeclaration(unsigned Context,
const ParsedTemplateInfo &TemplateInfo,
@@ -564,7 +564,7 @@ Decl *Parser::ParseUsingDeclaration(unsi
tok::semi);
// Diagnose an attempt to declare a templated using-declaration.
- // In C++0x, alias-declarations can be templates:
+ // In C++11, alias-declarations can be templates:
// template <...> using id = type;
if (TemplateInfo.Kind && !IsAliasDecl) {
SourceRange R = TemplateInfo.getSourceRange();
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jan 29 04:02:16 2013
@@ -4851,7 +4851,7 @@ bool Sema::ProcessAccessDeclAttributeLis
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A) {
for ( ; A; A = A->getNext()) {
// Only warn if the attribute is an unignored, non-type attribute.
- if (A->isUsedAsTypeAttr()) continue;
+ if (A->isUsedAsTypeAttr() || A->isInvalid()) continue;
if (A->getKind() == AttributeList::IgnoredAttribute) continue;
if (A->getKind() == AttributeList::UnknownAttribute) {
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jan 29 04:02:16 2013
@@ -4283,9 +4283,11 @@ static void processTypeAttrs(TypeProcess
switch (attr.getKind()) {
default:
// A C++11 attribute on a declarator chunk must appertain to a type.
- if (attr.isCXX11Attribute() && TAL == TAL_DeclChunk)
+ if (attr.isCXX11Attribute() && TAL == TAL_DeclChunk) {
state.getSema().Diag(attr.getLoc(), diag::err_attribute_not_type_attr)
- << attr.getName()->getName();
+ << attr.getName();
+ attr.setUsedAsTypeAttr();
+ }
break;
case AttributeList::UnknownAttribute:
@@ -4336,6 +4338,14 @@ static void processTypeAttrs(TypeProcess
attr.setUsedAsTypeAttr();
break;
+ case AttributeList::AT_Win64:
+ case AttributeList::AT_Ptr32:
+ case AttributeList::AT_Ptr64:
+ // FIXME: Don't ignore these. We have partial handling for them as
+ // declaration attributes in SemaDeclAttr.cpp; that should be moved here.
+ attr.setUsedAsTypeAttr();
+ break;
+
case AttributeList::AT_NSReturnsRetained:
if (!state.getSema().getLangOpts().ObjCAutoRefCount)
break;
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Tue Jan 29 04:02:16 2013
@@ -1,4 +1,3 @@
-// REQUIRES: disabled
// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s
__stdcall int func0();
int __stdcall func();
@@ -21,12 +20,15 @@ void * __ptr32 PtrToPtr32(const void *p)
void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
{
+ // FIXME: Re-enable this once MS inline asm stabilizes.
+#if 0
__asm {
mov eax, Bit
mov ecx, Base
lock bts [ecx], eax
setc al
};
+#endif
}
_inline int foo99() { return 99; }
Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Tue Jan 29 04:02:16 2013
@@ -255,11 +255,11 @@ namespace arguments {
}
// Forbid attributes on decl specifiers.
-unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-warning {{attribute 'unused' ignored, because it is not attached to a declaration}} \
+unsigned [[gnu::used]] static int [[gnu::unused]] v1; // expected-error {{'unused' attribute cannot be applied to types}} \
expected-error {{an attribute list cannot appear here}}
-typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-warning {{attribute 'unused' ignored, because it is not attached to a declaration}} \
+typedef [[gnu::used]] unsigned long [[gnu::unused]] v2; // expected-error {{'unused' attribute cannot be applied to types}} \
expected-error {{an attribute list cannot appear here}}
-int [[carries_dependency]] foo(int [[carries_dependency]] x); // expected-warning 2{{attribute 'carries_dependency' ignored, because it is not attached to a declaration}}
+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}}
Modified: cfe/trunk/test/Sema/callingconv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv.c?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/Sema/callingconv.c (original)
+++ cfe/trunk/test/Sema/callingconv.c Tue Jan 29 04:02:16 2013
@@ -43,7 +43,7 @@ int __attribute__((pcs(0))) pcs4(void);
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
-int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{Invalid PCS type}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
// PR6361
void ctest3();
Modified: cfe/trunk/test/Sema/types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/types.c?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/Sema/types.c (original)
+++ cfe/trunk/test/Sema/types.c Tue Jan 29 04:02:16 2013
@@ -53,7 +53,7 @@ _Decimal32 x; // expected-error {{GNU d
int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector element type}}
void test(int i) {
- char c = (char __attribute__((align(8)))) i; // expected-error {{'align' attribute ignored when parsing type}}
+ char c = (char __attribute__((align(8)))) i; // expected-warning {{'align' attribute ignored when parsing type}}
}
// http://llvm.org/PR11082
Modified: cfe/trunk/test/SemaCXX/attr-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-cxx0x.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-cxx0x.cpp Tue Jan 29 04:02:16 2013
@@ -26,7 +26,7 @@ template <typename... T> alignas(T...) s
template <unsigned... A> alignas(A...) struct align_class_temp_pack_expr {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
typedef char align_typedef alignas(8); // expected-error {{'alignas' attribute only applies to variables, functions and tag types}}
-template<typename T> using align_alias_template = align_typedef alignas(8); // expected-error {{'alignas' attribute ignored when parsing type}};
+template<typename T> using align_alias_template = align_typedef alignas(8); // expected-error {{'alignas' attribute cannot be applied to types}}
static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong");
static_assert(alignof(align_small) == 1, "j's alignment is wrong");
Modified: cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp?rev=173788&r1=173787&r2=173788&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp Tue Jan 29 04:02:16 2013
@@ -5,7 +5,7 @@
[[gnu::this_attribute_does_not_exist]] int unknown_attr;
// expected-warning at -1 {{unknown attribute 'this_attribute_does_not_exist' ignored}}
int [[gnu::unused]] attr_on_type;
-// expected-warning at -1 {{attribute 'unused' ignored, because it is not attached to a declaration}}
+// expected-error at -1 {{'unused' attribute cannot be applied to types}}
int *[[gnu::unused]] attr_on_ptr;
// expected-warning at -1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
More information about the cfe-commits
mailing list