aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2012-06-19 13:49:26 +0000
committerAaron Ballman <aaron@aaronballman.com>2012-06-19 13:49:26 +0000
commited35fd1c6db1680b4526ba64c94e5da6ec203be7 (patch)
tree18ac8c2240de3141ff98114ea78325435b42ab93 /include
parentc20c4e79ae1957ec5a88d7653a0aeda24b67ae3a (diff)
Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158717 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/Attr.td2
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td4
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td5
-rw-r--r--include/clang/Parse/Parser.h9
-rw-r--r--include/clang/Sema/AttributeList.h11
-rw-r--r--include/clang/Sema/Sema.h6
6 files changed, 31 insertions, 6 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
index 22d6b3862e..f44f8689ff 100644
--- a/include/clang/Basic/Attr.td
+++ b/include/clang/Basic/Attr.td
@@ -143,7 +143,7 @@ def Alias : InheritableAttr {
def Aligned : InheritableAttr {
let Spellings = [GNU<"aligned">, GNU<"align">];
let Subjects = [NonBitField, NormalVar, Tag];
- let Args = [AlignedArgument<"Alignment">];
+ let Args = [AlignedArgument<"Alignment">, BoolArgument<"IsMSDeclSpec">];
}
def AlignMac68k : InheritableAttr {
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index 3908a37b1c..ab3bf7ed45 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -481,6 +481,10 @@ def err_l_square_l_square_not_attribute : Error<
"introducing an attribute">;
def err_alignas_pack_exp_unsupported : Error<
"pack expansions in alignment specifiers are not supported yet">;
+def err_ms_declspec_type : Error<
+ "__declspec attributes must be an identifier or string literal">;
+def warn_ms_declspec_unknown : Warning<
+ "unknown __declspec attribute %0 ignored">, InGroup<UnknownAttributes>;
/// C++ Templates
def err_expected_template : Error<"expected template">;
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 6381221015..9ca078d1bd 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1617,11 +1617,16 @@ def warn_mismatched_section : Warning<
def err_attribute_aligned_not_power_of_two : Error<
"requested alignment is not a power of 2">;
+def err_attribute_aligned_greater_than_8192 : Error<
+ "requested alignment must be 8192 bytes or smaller">;
def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
"'%0' redeclared without %1 attribute: previous %1 ignored">;
def warn_attribute_ignored : Warning<"%0 attribute ignored">;
def warn_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
+def warn_unhandled_ms_attribute_ignored : Warning<
+ "__declspec attribute %0 is not supported">,
+ InGroup<IgnoredAttributes>;
def warn_attribute_invalid_on_stmt : Warning<
"attribute %0 cannot be specified on a statement">,
InGroup<IgnoredAttributes>;
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index b977e7f834..cf308327f3 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -1790,7 +1790,14 @@ private:
}
void ParseMicrosoftAttributes(ParsedAttributes &attrs,
SourceLocation *endLoc = 0);
- void ParseMicrosoftDeclSpec(ParsedAttributes &attrs);
+ void ParseMicrosoftDeclSpec(ParsedAttributes &Attrs);
+ bool IsSimpleMicrosoftDeclSpec(IdentifierInfo *Ident);
+ void ParseComplexMicrosoftDeclSpec(IdentifierInfo *Ident,
+ SourceLocation Loc,
+ ParsedAttributes &Attrs);
+ void ParseMicrosoftDeclSpecWithSingleArg(IdentifierInfo *AttrName,
+ SourceLocation AttrNameLoc,
+ ParsedAttributes &Attrs);
void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h
index 5de2cce976..5239044e67 100644
--- a/include/clang/Sema/AttributeList.h
+++ b/include/clang/Sema/AttributeList.h
@@ -57,7 +57,10 @@ public:
enum Syntax {
AS_GNU,
AS_CXX11,
- AS_Declspec
+ AS_Declspec,
+ // eg) __w64, __ptr32, etc. It is implied that an MSTypespec is also
+ // a declspec.
+ AS_MSTypespec
};
private:
IdentifierInfo *AttrName;
@@ -181,8 +184,12 @@ public:
IdentifierInfo *getParameterName() const { return ParmName; }
SourceLocation getParameterLoc() const { return ParmLoc; }
- bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
+ /// Returns true if the attribute is a pure __declspec or a synthesized
+ /// declspec representing a type specification (like __w64 or __ptr32).
+ bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec ||
+ SyntaxUsed == AS_MSTypespec; }
bool isCXX0XAttribute() const { return SyntaxUsed == AS_CXX11; }
+ bool isMSTypespecAttribute() const { return SyntaxUsed == AS_MSTypespec; }
bool isInvalid() const { return Invalid; }
void setInvalid(bool b = true) const { Invalid = b; }
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index c6af1d861a..408763f5cf 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -6338,8 +6338,10 @@ public:
void AddCFAuditedAttribute(Decl *D);
/// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
- void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E);
- void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T);
+ void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
+ bool isDeclSpec);
+ void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
+ bool isDeclSpec);
/// \brief The kind of conversion being performed.
enum CheckedConversionKind {