From 709619d9162fade06265038534bb20276d770708 Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@redhat.com>
Date: Thu, 24 Jan 2002 01:32:12 +0000
Subject: [PATCH] c-parse.in (parmlist_or_identifiers): Add maybe_attribute.

2002-01-16  Aldy Hernandez  <aldyh@redhat.com>

        * c-parse.in (parmlist_or_identifiers): Add maybe_attribute.
        (parmlist_or_identifiers_1): Verify that only a parmlist follows
        an attribute.

        * gcc.dg/20020115-1.c: New.

From-SVN: r49161
---
 gcc/ChangeLog                     |  6 ++++++
 gcc/c-parse.in                    | 13 +++++++++++--
 gcc/testsuite/ChangeLog           |  4 ++++
 gcc/testsuite/gcc.dg/20020115-1.c | 15 +++++++++++++++
 4 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/20020115-1.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c411ccc65eca..b0aeeae6160e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2002-01-23  Aldy Hernandez  <aldyh@redhat.com>
+
+        * c-parse.in (parmlist_or_identifiers): Add maybe_attribute.
+        (parmlist_or_identifiers_1): Verify that only a parmlist follows
+        an attribute.
+
 2002-01-23  Richard Henderson  <rth@redhat.com>
 
 	* expr.c (move_by_pieces_1): Extend size before negation.
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 9434a2fa9ff5..524d407e801b 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -2605,11 +2605,12 @@ setspecs_fp:
    where either a parmlist or an identifier list is ok.
    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
 parmlist_or_identifiers:
+	  maybe_attribute
 		{ pushlevel (0);
 		  clear_parm_order ();
 		  declare_parm_level (1); }
 	  parmlist_or_identifiers_1
-		{ $$ = $2;
+		{ $$ = $3;
 		  parmlist_tags_warning ();
 		  poplevel (0, 0, 0); }
 	;
@@ -2621,7 +2622,15 @@ parmlist_or_identifiers_1:
 		  for (t = $1; t; t = TREE_CHAIN (t))
 		    if (TREE_VALUE (t) == NULL_TREE)
 		      error ("`...' in old-style identifier list");
-		  $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
+		  $$ = tree_cons (NULL_TREE, NULL_TREE, $1);
+
+		  /* Make sure we have a parmlist after attributes.  */
+		  if ($<ttype>-1 != 0
+		      && (TREE_CODE ($$) != TREE_LIST
+			  || TREE_PURPOSE ($$) == 0
+			  || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL))
+		    YYERROR1;
+		}
 	;
 
 /* A nonempty list of identifiers.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eb918c3eaecd..dafeb903c679 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-01-23  Aldy Hernandez  <aldyh@redhat.com>
+
+        * gcc.dg/20020115-1.c: New.
+
 2002-01-23  Bob Wilson  <bob.wilson@acm.org>
 
 	* gcc.c-torture/compile/20001226-1.x: xfail for Xtensa.
diff --git a/gcc/testsuite/gcc.dg/20020115-1.c b/gcc/testsuite/gcc.dg/20020115-1.c
new file mode 100644
index 000000000000..9d4ea5491f5c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20020115-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+/* Test attributes in function arguments.  */
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+
+#define blah __attribute__((__mode__(QI)))
+
+extern void bar(int *);
+
+void foo (blah int abc)
+{
+
+	int b[sizeof(abc) == 1 ? 1 : -1];
+	bar (b);
+}
-- 
GitLab