zsh-workers
 help / color / Atom feed
* [PATCH] _gcc: add some clang specific warnings
@ 2020-01-05 18:52 Eitan Adler
  2020-01-07  4:16 ` dana
  0 siblings, 1 reply; 3+ messages in thread
From: Eitan Adler @ 2020-01-05 18:52 UTC (permalink / raw)
  To: zsh-workers; +Cc: Eitan Adler

This adds some missing completions to the _gcc completer for clang.
Sadly clang does not support --help=warnings so it is not complete.

Signed-off-by: Eitan Adler <lists@eitanadler.com>
---
 Completion/Unix/Command/_gcc | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc
index 0061cfa3b..bbfbc2b9e 100644
--- a/Completion/Unix/Command/_gcc
+++ b/Completion/Unix/Command/_gcc
@@ -350,10 +350,12 @@ if [[ "$service" = clang* ]]; then
         "-nostdinc[Do not search standard system directories or compiler builtin directories for include files]"
         "-nostdlibinc[Do not search standard system directories for include files]"
         "-nobuiltininc[Do not search builtin directory for include files]"
+        "--help[Display this information]"
     )
 else
     args+=(
       '-flto=-[Enable link-time optimization]::jobs:'
+      '*--help=-[Display this information]:class:->help'
     )
 fi
 
@@ -427,7 +429,6 @@ args+=(
   '*-isystem:second include path directory (system):_files -/'
   '--sysroot=-[Use <directory> as the root directory for headers and libraries]:directory:_files -/'
   '-pass-exit-codes[Exit with highest error code from a phase]'
-  '*--help=-[Display this information]:class:->help'
   '--target-help[Display target specific command line options]'
   '-dumpspecs[Display all of the built in spec strings]'
   '-dumpversion[Display the version of the compiler]'
@@ -676,7 +677,6 @@ args+=(
   '-Wunderflow[Warn about underflow of numerical constant expressions]'
   '-Wuninitialized[Warn about uninitialized automatic variables]'
   '-Wunknown-pragmas[Warn about unrecognized pragmas]'
-  '-Wunreachable-code[Does nothing. Preserved for backward compatibility]'
   '-Wunsafe-loop-optimizations[Warn if the loop cannot be optimized due to nontrivial assumptions]'
   '-Wunsuffixed-float-constants[Warn about unsuffixed float constants]'
   '-Wunused-but-set-parameter[Warn when a function parameter is only set, otherwise unused]'
@@ -730,6 +730,20 @@ args+=(
   '-Werror=-[Treat specified warning as error (or all if none specified)]::warning:->werror'
   '-Wfatal-errors[Exit on the first error occurred]'
 )
+# clang specific warnings
+if [[ "$service" = clang* ]]; then
+  args+=(
+    '-Wunreachable-code[Warn on code that will not be executed]'
+    '-Wunreachable-code-aggressive[Controls -Wunreachable-code, -Wunreachable-code-break, -Wunreachable-code-return]'
+    '-Wunreachable-code-break[Warn when break will never be executed]'
+    '-Wunreachable-code-loop-increment[Warn when loop will be executed only once]'
+    '-Wunreachable-code-return[Warn when return will not be executed]'
+  )
+else
+  args+=(
+    '-Wunreachable-code[Does nothing. Preserved for backward compatibility]'
+  )
+fi
 # optimizers (from --help=optimizers), except for -O
 args+=(
 # --help=optimizers,^joined
-- 
2.24.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] _gcc: add some clang specific warnings
  2020-01-05 18:52 [PATCH] _gcc: add some clang specific warnings Eitan Adler
@ 2020-01-07  4:16 ` dana
  2020-01-08  4:57   ` Eitan Adler
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2020-01-07  4:16 UTC (permalink / raw)
  To: Eitan Adler; +Cc: zsh-workers

On 5 Jan 2020, at 12:52, Eitan Adler <lists@eitanadler.com> wrote:
> This adds some missing completions to the _gcc completer for clang.
> Sadly clang does not support --help=warnings so it is not complete.

Merged. It occurred to me that it won't work quite accurately on macOS,
though, because gcc is actually clang there.

I think this should address it. Or should we go even further and try to be
clever about which options to provide for CFLAGS, &al.? All we could do with
that is guess, i suppose.

dana


diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc
index bbfbc2b9e..9ec09200e 100644
--- a/Completion/Unix/Command/_gcc
+++ b/Completion/Unix/Command/_gcc
@@ -13,6 +13,11 @@ if [[ "$service" = -value-* ]]; then
     args2=()
   fi
 else
+  # On some systems (macOS), cc/gcc/g++ are actually clang; treat them accordingly
+  [[ $service != clang* ]] &&
+  _pick_variant clang=clang unix --version &&
+  service=clang-$service
+
   args2=( '*:input file:_files -g "*.([cCmisSoak]|cc|cpp|cxx|ii|k[ih])(-.)"' )
 fi
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] _gcc: add some clang specific warnings
  2020-01-07  4:16 ` dana
@ 2020-01-08  4:57   ` Eitan Adler
  0 siblings, 0 replies; 3+ messages in thread
From: Eitan Adler @ 2020-01-08  4:57 UTC (permalink / raw)
  To: dana; +Cc: Zsh hackers list

On Mon, 6 Jan 2020 at 20:16, dana <dana@dana.is> wrote:
>
> On 5 Jan 2020, at 12:52, Eitan Adler <lists@eitanadler.com> wrote:
> > This adds some missing completions to the _gcc completer for clang.
> > Sadly clang does not support --help=warnings so it is not complete.
>
> Merged. It occurred to me that it won't work quite accurately on macOS,
> though, because gcc is actually clang there.

I really wish clang would implement --help=<object>. This would
eliminate the need to list all of the options and so forth. I believe
I filed a feature request years ago but can't actually find it right
about now.

> I think this should address it.

This patch seems alright to me.

> Or should we go even further and try to be
> clever about which options to provide for CFLAGS, &al.?

CFLAGS is used in many more odd contexts - including where you don't
know what CC is. In this case I'd complete the union of the two.

> All we could do with
> that is guess, i suppose.
>

-- 
Eitan Adler

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-05 18:52 [PATCH] _gcc: add some clang specific warnings Eitan Adler
2020-01-07  4:16 ` dana
2020-01-08  4:57   ` Eitan Adler

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git