public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/68645 (attr-simd-3.c testsuite failure)
@ 2015-12-04 18:01 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-12-04 18:01 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 369 bytes --]

The Cilk+ code bizarrely parses function-trailing attributes in a 
different place from normal operation, and tells the compiler that they 
were C++11 attributes when they were actually specified with the GNU 
syntax, which changes what they apply to.  This patch fixes the second 
issue, which is enough to fix the bug.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 68645.patch --]
[-- Type: text/x-patch, Size: 2928 bytes --]

commit 860bfe6aaf2470540a1280f127f20174d280f344
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Dec 2 23:02:28 2015 -0500

    	PR c++/68645
    
    	* parser.c (cp_parser_direct_declarator)
    	(cp_parser_late_return_type_opt): Put Cilk+ attributes on
    	declarator->attributes, not std_attributes.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1c14354..f4b23fd 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18492,6 +18492,7 @@ cp_parser_direct_declarator (cp_parser* parser,
 		  /* In here, we handle cases where attribute is used after
 		     the function declaration.  For example:
 		     void func (int x) __attribute__((vector(..)));  */
+		  tree gnu_attrs = NULL_TREE;
 		  if (flag_cilkplus
 		      && cp_next_tokens_can_be_gnu_attribute_p (parser))
 		    {
@@ -18505,7 +18506,7 @@ cp_parser_direct_declarator (cp_parser* parser,
 		      else if (!cp_parser_parse_definitely (parser))
 			;
 		      else
-			attrs = chainon (attr, attrs);
+			gnu_attrs = attr;
 		    }
 		  tree requires_clause = NULL_TREE;
 		  late_return = (cp_parser_late_return_type_opt
@@ -18526,6 +18527,7 @@ cp_parser_direct_declarator (cp_parser* parser,
 						     late_return,
 						     requires_clause);
 		  declarator->std_attributes = attrs;
+		  declarator->attributes = gnu_attrs;
 		  /* Any subsequent parameter lists are to do with
 		     return type, so are not those of the declared
 		     function.  */
@@ -19325,17 +19327,17 @@ cp_parser_late_return_type_opt (cp_parser* parser, cp_declarator *declarator,
   requires_clause = cp_parser_requires_clause_opt (parser);
 
   if (cilk_simd_fn_vector_p)
-    declarator->std_attributes
+    declarator->attributes
       = cp_parser_late_parsing_cilk_simd_fn_info (parser,
-						  declarator->std_attributes);
+						  declarator->attributes);
   if (declare_simd_p)
-    declarator->std_attributes
+    declarator->attributes
       = cp_parser_late_parsing_omp_declare_simd (parser,
-						 declarator->std_attributes);
+						 declarator->attributes);
   if (oacc_routine_p)
-    declarator->std_attributes
+    declarator->attributes
       = cp_parser_late_parsing_oacc_routine (parser,
-					     declarator->std_attributes);
+					     declarator->attributes);
 
   if (quals >= 0)
     {
diff --git a/gcc/testsuite/c-c++-common/attr-simd-3.c b/gcc/testsuite/c-c++-common/attr-simd-3.c
index 35dd4c0..d61ba82 100644
--- a/gcc/testsuite/c-c++-common/attr-simd-3.c
+++ b/gcc/testsuite/c-c++-common/attr-simd-3.c
@@ -2,4 +2,4 @@
 /* { dg-options "-fcilkplus" } */
 /* { dg-prune-output "undeclared here \\(not in a function\\)|\[^\n\r\]* was not declared in this scope" } */
 
-void f () __attribute__((__simd__, __vector__)); /* { dg-error "in the same function marked as a Cilk Plus" "PR68158" { xfail c++ } } */
+void f () __attribute__((__simd__, __vector__)); /* { dg-error "in the same function marked as a Cilk Plus" "PR68158" } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-04 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-04 18:01 C++ PATCH for c++/68645 (attr-simd-3.c testsuite failure) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).