Re: [clang] 246398e - [clang][Parse] properly parse asm-qualifiers, asm inline

2020-04-13 Thread Nick Desaulniers via cfe-commits
On Sun, Apr 12, 2020 at 3:45 PM Joerg Sonnenberger  wrote:
>
> On Thu, Mar 12, 2020 at 03:25:49PM -0700, Nick Desaulniers via cfe-commits 
> wrote:
> >
> > Author: Nick Desaulniers
> > Date: 2020-03-12T15:13:59-07:00
> > New Revision: 246398ece7115b57a02dbe7876d86ae8e72406ef
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef.diff
> >
> > LOG: [clang][Parse] properly parse asm-qualifiers, asm inline
> >
> > Summary:
> > The parsing of GNU C extended asm statements was a little brittle and
> > had a few issues:
>
> I find it very questionable that this change drops a warning flag making
> IMO benign code differences like marking a global asm as volatile an
> unconditional error. This strongly seems to be something that we
> shouldn't blindly follow GCC on.

We can always bring them back.  Now that we can parse asm statements
correctly, I think we could even unify asm parsing (there's one spot
that parses asm expressions again, but without looking for the asm
qualifiers (parseAsmSimple() IIRC).  Then you could pass in whether
the qualifiers should be ignored and warn on or not.

-Wasm-file-asm-volatile was certainly too specific to `volatile`, but
it makes sense to bring back `-Wasm-ignored-qualifier` for asm
qualifiers (previously it warned for unrelated type qualifiers, which
I'm quite certain wasn't very helpful).
-- 
Thanks,
~Nick Desaulniers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 246398e - [clang][Parse] properly parse asm-qualifiers, asm inline

2020-04-12 Thread Joerg Sonnenberger via cfe-commits
On Thu, Mar 12, 2020 at 03:25:49PM -0700, Nick Desaulniers via cfe-commits 
wrote:
> 
> Author: Nick Desaulniers
> Date: 2020-03-12T15:13:59-07:00
> New Revision: 246398ece7115b57a02dbe7876d86ae8e72406ef
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef
> DIFF: 
> https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef.diff
> 
> LOG: [clang][Parse] properly parse asm-qualifiers, asm inline
> 
> Summary:
> The parsing of GNU C extended asm statements was a little brittle and
> had a few issues:

I find it very questionable that this change drops a warning flag making
IMO benign code differences like marking a global asm as volatile an
unconditional error. This strongly seems to be something that we
shouldn't blindly follow GCC on.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 246398e - [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-12 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-03-12T15:13:59-07:00
New Revision: 246398ece7115b57a02dbe7876d86ae8e72406ef

URL: 
https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef
DIFF: 
https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef.diff

LOG: [clang][Parse] properly parse asm-qualifiers, asm inline

Summary:
The parsing of GNU C extended asm statements was a little brittle and
had a few issues:
- It was using Parse::ParseTypeQualifierListOpt to parse the `volatile`
  qualifier.  That parser is really meant for TypeQualifiers; an asm
  statement doesn't really have a type qualifier. This is still maybe
  nice to have, but not necessary. We now can check for the `volatile`
  token by properly expanding the grammer, rather than abusing
  Parse::ParseTypeQualifierListOpt.
- The parsing of `goto` was position dependent, so `asm goto volatile`
  wouldn't parse. The qualifiers should be position independent to one
  another. Now they are.
- We would warn on duplicate `volatile`, but the parse error for
  duplicate `goto` was a generic parse error and wasn't clear.
- We need to add support for the recent GNU C extension `asm inline`.
  Adding support to the parser with the above issues highlighted the
  need for this refactoring.

Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aheejin, jfb, nathanchance, cfe-commits, echristo, efriedma, 
rsmith, chandlerc, craig.topper, erichkeane, jyu2, void, srhines

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75563

Added: 
clang/test/Parser/asm-qualifiers.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmtAsm.cpp
clang/lib/Parse/Parser.cpp
clang/test/CodeGen/inline-asm-mixed-style.c
clang/test/Parser/asm.c
clang/test/Sema/asm.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 664ae4e4167c..710f005985da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -91,6 +91,13 @@ Modified Compiler Flags
   of a variable in a header file. In some cases, no specific translation unit
   provides a definition of the variable. The previous behavior can be restored 
by
   specifying ``-fcommon``.
+- -Wasm-ignored-qualifier (ex. `asm const ("")`) has been removed and replaced
+  with an error (this matches a recent change in GCC-9).
+- -Wasm-file-asm-volatile (ex. `asm volatile ("")` at global scope) has been
+  removed and replaced with an error (this matches GCC's behavior).
+- Duplicate qualifiers on asm statements (ex. `asm volatile volatile ("")`) no
+  longer produces a warning via -Wduplicate-decl-specifier, but now an error
+  (this matches GCC's behavior).
 
 New Pragmas in Clang
 
@@ -111,6 +118,9 @@ C Language Changes in Clang
 - The default C language standard used when `-std=` is not specified has been
   upgraded from gnu11 to gnu17.
 
+- Clang now supports the GNU C extension `asm inline`; it won't do anything
+  *yet*, but it will be parsed.
+
 - ...
 
 C++ Language Changes in Clang

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2b11298bfcfa..2c28789aac1d 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1090,9 +1090,8 @@ def ObjCSignedCharBool : 
DiagGroup<"objc-signed-char-bool",
 
 // Inline ASM warnings.
 def ASMOperandWidths : DiagGroup<"asm-operand-widths">;
-def ASMIgnoredQualifier : DiagGroup<"asm-ignored-qualifier">;
 def ASM : DiagGroup<"asm", [
-ASMOperandWidths, ASMIgnoredQualifier
+ASMOperandWidths
   ]>;
 
 // OpenMP warnings.

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index ec33a0fcfdc7..f22d3a18d254 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -12,11 +12,10 @@
 
 let Component = "Parse" in {
 
-def warn_asm_qualifier_ignored : Warning<
-  "ignored %0 qualifier on asm">, CatInlineAsm, InGroup;
-def warn_file_asm_volatile : Warning<
-  "meaningless 'volatile' on asm outside function">, CatInlineAsm,
-  InGroup;
+def err_asm_qualifier_ignored : Error<
+  "expected 'volatile', 'inline', 'goto', or '('">, CatInlineAsm;
+def err_global_asm_qualifier_ignored : Error<
+  "meaningless '%0' on asm outside function">, CatInlineAsm;
 
 let CategoryName = "Inline Assembly Issue" in {
 def err_asm_empty : Error<"__asm used with no assembly instructions">;
@@ -29,6 +28,7 @@ def err_gnu_inline_asm_disabled : Error<
   "GNU-style inline assembly is disabled">;
 def