[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-12-05 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
   Target Milestone|--- |14.0

--- Comment #23 from Jakub Jelinek  ---
.

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-12-05 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #22 from Jakub Jelinek  ---
DR now implemented for GCC 12 (but gnu::no_reorder support for namespace scope
asms would be more work; I think we don't reorder toplevel asms anyway).

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-12-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #21 from GCC Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:e5153e7d63b4cd9a3df490809c4f3fe1e94d3d37

commit r14-6187-ge5153e7d63b4cd9a3df490809c4f3fe1e94d3d37
Author: Jakub Jelinek 
Date:   Tue Dec 5 17:38:46 2023 +0100

c++: Implement C++ DR 2262 - Attributes for asm-definition [PR110734]

Seems in 2017 attribute-specifier-seq[opt] was added to asm-declaration
and the change was voted in as a DR.

The following patch implements it by parsing the attributes and warning
about them.

I found one attribute parsing bug I'll send a fix for momentarily.

And there is another thing I wonder about: with -Wno-attributes= we are
supposed to ignore the attributes altogether, but we are actually still
warning about them when we emit these generic warnings about ignoring
all attributes which appertain to this and that (perhaps with some
exceptions we first remove from the attribute chain), like:
void foo () { [[foo::bar]]; }
with -Wattributes -Wno-attributes=foo::bar
Shouldn't we call some helper function in cases like this and warn
not when std_attrs (or how the attribute chain var is called) is non-NULL,
but if it is non-NULL and contains at least one non-attribute_ignored_p
attribute?  cp_parser_declaration at least tries:
  if (std_attrs != NULL_TREE && !attribute_ignored_p (std_attrs))
warning_at (make_location (attrs_loc, attrs_loc, parser->lexer),
OPT_Wattributes, "attribute ignored");
but attribute_ignored_p here checks the first attribute rather than the
whole chain.  So it will incorrectly not warn if there is an ignored
attribute followed by non-ignored.

2023-12-05  Jakub Jelinek  

PR c++/110734
* parser.cc (cp_parser_block_declaration): Implement C++ DR 2262
- Attributes for asm-definition.  Call cp_parser_asm_definition
even if RID_ASM token is only seen after sequence of standard
attributes.
(cp_parser_asm_definition): Parse standard attributes before
RID_ASM token and warn for them with -Wattributes.

* g++.dg/DRs/dr2262.C: New test.
* g++.dg/cpp0x/gen-attrs-76.C (foo, bar): Don't expect errors
on attributes on asm definitions.
* g++.dg/gomp/attrs-11.C: Remove 2 expected errors.

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-12-02 Thread tanksherman27 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #20 from Julian Waters  ---
cppreference at least seems to indicate it retroactively applies to C++11
https://en.cppreference.com/w/cpp/language/asm

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-11-30 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org

--- Comment #19 from Jakub Jelinek  ---
Attributes have been allowed on asm in C++ only since 2017's
https://cplusplus.github.io/CWG/issues/2262.html
which we apparently don't implement.  See
https://gcc.gnu.org/projects/cxx-dr-status.html
It is not clear whether that change has been effectively applied as a DR and
thus whether it should apply to earlier standards as well (guess starting with
C++11) or not.

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-11-30 Thread tanksherman27 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #18 from Julian Waters  ---
Oops, I meant warning: 'no_reorder' attribute ignored [-Wattributes] in my
above comment

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-11-30 Thread tanksherman27 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #17 from Julian Waters  ---
Looking at the source of the C++ parser it doesn't seem like asm (""); is
considered a statement but rather is correctly parsed as a declaration, see
cp_parser_block_declaration and cp_parser_declaration_statement. The no_reorder
attribute is just a demonstration, I am aware it is not meant for asm
declarations, rather the error is in how the error message is formed, eg error:
expected primary-expression before 'asm' instead of error: expected
primary-expression before 'asm'

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-11-30 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

--- Comment #16 from Xi Ruoyao  ---
(In reply to Xi Ruoyao from comment #15)
> Alright, this is a C++ issue and I mistakenly assumed it was C.

Note that in C++ we have some inconsistency with the standard.  In the standard
asm(...) are "declarations" but in GNU C++ asm(...) are always "statements".

[Bug c++/110734] Attributes cannot be applied to asm declaration

2023-11-30 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110734

Xi Ruoyao  changed:

   What|Removed |Added

Summary|Attributes cannot be|Attributes cannot be
   |applied to asm statements   |applied to asm declaration
 Status|WAITING |NEW

--- Comment #15 from Xi Ruoyao  ---
Alright, this is a C++ issue and I mistakenly assumed it was C.