summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-16 20:35:21 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-16 20:35:21 +0000
commita021a5a651999cf512165dedb8de3fef5377890d (patch)
tree1956edd1a7728d948fb52e28f45a268e9d0f1b4d
parent952159483d7efd13f85c16189481bc1ec5808b46 (diff)
downloadgcc-a021a5a651999cf512165dedb8de3fef5377890d.tar.gz
* c-decl.c (grokdeclarator): Allow for function definition where
innermost declarator has attributes. testsuite: * gcc.dg/funcdef-attr-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86075 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-decl.c15
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/funcdef-attr-1.c14
4 files changed, 33 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85d5500d36b..991177702ab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-16 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ * c-decl.c (grokdeclarator): Allow for function definition where
+ innermost declarator has attributes.
+
2004-08-16 Fariborz Jahanian <fjahanian@apple.com>
* except.c (get_exception_filter, build_post_landing_pads,
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index c7ba8d20268..e867ebb6c72 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -4176,12 +4176,17 @@ grokdeclarator (tree declarator, tree declspecs,
}
else if (TREE_CODE (declarator) == CALL_EXPR)
{
- /* Say it's a definition only for the CALL_EXPR closest to
- the identifier. */
- bool really_funcdef = (funcdef_flag
- && (TREE_CODE (TREE_OPERAND (declarator, 0))
- == IDENTIFIER_NODE));
+ /* Say it's a definition only for the declarator closest to
+ the identifier, apart possibly from some attributes. */
+ bool really_funcdef = false;
tree arg_types;
+ if (funcdef_flag)
+ {
+ tree t = TREE_OPERAND (declarator, 0);
+ while (TREE_CODE (t) == TREE_LIST)
+ t = TREE_VALUE (t);
+ really_funcdef = (TREE_CODE (t) == IDENTIFIER_NODE);
+ }
/* Declaring a function type.
Make sure we have a valid type for the function to return. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b7d51b16f37..80561d3ad0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-08-16 Joseph S. Myers <jsm@polyomino.org.uk>
+
+ * gcc.dg/funcdef-attr-1.c: New test.
+
2004-08-16 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/altivec-17.c: New test.
diff --git a/gcc/testsuite/gcc.dg/funcdef-attr-1.c b/gcc/testsuite/gcc.dg/funcdef-attr-1.c
new file mode 100644
index 00000000000..17249a0cb9e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/funcdef-attr-1.c
@@ -0,0 +1,14 @@
+/* The declarator in a function definition should be able to take the
+ form of an attributed function declarator, not just a plain
+ function declarator. This was formerly allowed by some of the code
+ but then the wrong constraint checks were made because other code
+ didn't recognise the declarator as being that of the function
+ definition. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk>. */
+
+int (__attribute__((const)) x) (a, b)
+ int a;
+ int b;
+{
+ return a + b;
+}