aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-06-02 10:47:58 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:48 -0700
commit96d59197279db28ec9c61ae95c83780b25d0fe96 (patch)
treefd03ee04f71d93bae4d55ef249a5b47f16ba0b85
parent9a13de1b8f559799413532bcbd9cb994db6caf4f (diff)
downloadsparse-96d59197279db28ec9c61ae95c83780b25d0fe96.tar.gz
sparse-96d59197279db28ec9c61ae95c83780b25d0fe96.tar.xz
sparse-96d59197279db28ec9c61ae95c83780b25d0fe96.zip
Peter Jones informs about the gcc "attribute((aligned))" behaviour:
"The compiler automatically sets the alignment for the declared variable or field to the largest alignment which is ever used for any data type on the target machine you are compiling for" So add the proper define to "target.h" and make it so.
-rw-r--r--parse.c8
-rw-r--r--show-parse.c5
-rw-r--r--target.h5
3 files changed, 14 insertions, 4 deletions
diff --git a/parse.c b/parse.c
index bd0dd6f..5a13b28 100644
--- a/parse.c
+++ b/parse.c
@@ -22,6 +22,7 @@
#include "symbol.h"
#include "scope.h"
#include "expression.h"
+#include "target.h"
static struct token *statement(struct token *token, struct statement **tree);
static struct token *external_declaration(struct token *token, struct symbol_list **list);
@@ -170,9 +171,10 @@ static const char * handle_attribute(struct ctype *ctype, struct ident *attribut
return NULL;
}
if (match_string_ident(attribute, "aligned")) {
- if (!expr)
- return "expected alignment expression";
- ctype->alignment = get_expression_value(expr);
+ int alignment = MAX_ALIGNMENT;
+ if (expr)
+ alignment = get_expression_value(expr);
+ ctype->alignment = alignment;
return NULL;
}
if (match_string_ident(attribute, "nocast")) {
diff --git a/show-parse.c b/show-parse.c
index a689205..897b0e6 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -284,7 +284,10 @@ void show_symbol(struct symbol *sym)
if (!sym)
return;
-
+
+ if (sym->ctype.alignment)
+ printf(".align %d\n", sym->ctype.alignment);
+
show_type(sym);
type = sym->ctype.base_type;
if (!type)
diff --git a/target.h b/target.h
index b68c704..7346325 100644
--- a/target.h
+++ b/target.h
@@ -5,6 +5,11 @@
#define ssize_t_ctype (&long_ctype)
/*
+ * For "__attribute__((aligned))"
+ */
+#define MAX_ALIGNMENT 16
+
+/*
* Integer data types
*/
#define BITS_IN_CHAR 8