summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1998-10-21 09:59:32 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1998-10-21 09:59:32 +0000
commitd91a20bc0722b9f77a8694d5194a5ed2cb6dc975 (patch)
tree3d4c0623ef92039a6f5d9f9c5606e83c0764cb62 /gcc/c-common.c
parenta5b1863e02065b553439fb9ec3984ac10ed58b76 (diff)
downloadgcc-d91a20bc0722b9f77a8694d5194a5ed2cb6dc975.tar.gz
* c-common.c (c_apply_type_quals_to_decl): Don't crash when
`restrict' is applied to a non-pointer variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23213 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 4aaeb3c7818..508a8c2e599 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3037,26 +3037,34 @@ c_apply_type_quals_to_decl (type_quals, decl)
TREE_SIDE_EFFECTS (decl) = 1;
TREE_THIS_VOLATILE (decl) = 1;
}
- if ((type_quals & TYPE_QUAL_RESTRICT) && flag_strict_aliasing)
+ if (type_quals & TYPE_QUAL_RESTRICT)
{
- /* No two restricted pointers can point at the same thing.
- However, a restricted pointer can point at the same thing as
- an unrestricted pointer, if that unrestricted pointer is
- based on the restricted pointer. So, we make the alias set
- for the restricted pointer a subset of the alias set for the
- type pointed to by the type of the decl. */
-
- int pointed_to_alias_set
- = get_alias_set (TREE_TYPE (TREE_TYPE (decl)));
-
- if (!pointed_to_alias_set)
- /* It's not legal to make a subset of alias set zero. */
- ;
- else
+ if (!TREE_TYPE (decl)
+ || !POINTER_TYPE_P (TREE_TYPE (decl))
+ || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (TREE_TYPE (decl))))
+ error ("invalid use of `restrict'");
+ else if (flag_strict_aliasing)
{
- DECL_POINTER_ALIAS_SET (decl) = new_alias_set ();
- record_alias_subset (pointed_to_alias_set,
- DECL_POINTER_ALIAS_SET (decl));
+ /* No two restricted pointers can point at the same thing.
+ However, a restricted pointer can point at the same thing
+ as an unrestricted pointer, if that unrestricted pointer
+ is based on the restricted pointer. So, we make the
+ alias set for the restricted pointer a subset of the
+ alias set for the type pointed to by the type of the
+ decl. */
+
+ int pointed_to_alias_set
+ = get_alias_set (TREE_TYPE (TREE_TYPE (decl)));
+
+ if (!pointed_to_alias_set)
+ /* It's not legal to make a subset of alias set zero. */
+ ;
+ else
+ {
+ DECL_POINTER_ALIAS_SET (decl) = new_alias_set ();
+ record_alias_subset (pointed_to_alias_set,
+ DECL_POINTER_ALIAS_SET (decl));
+ }
}
}
}