tbaeder created this revision.
tbaeder added a reviewer: dang.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

-ansi is documented as being the "same as -std=c89", but there are differences 
when passing it to a link:

  clang -c test.c -o test.o
  
  clang test.o -o test -std=c89   # Works, no problem
  
  clang test.o -o test -ansi  # Warning about unused -ansi option

`-std=` is claimed in this case in `clang/lib/Driver/Driver.cpp` at the end of 
`handleArguments()` via `Args.ClaimAllArgs(options::OPT_CompileOnly_Group)`. 
This does not include `-ansi` right now however, since it does not belong to 
the `CompileOnly` group.

Adding `-ansi` to said group makes sense since it's supposed to be an alias for 
`-std=c89` and resolves this inconsistency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93375

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -809,7 +809,7 @@
 def Z_Joined : Joined<["-"], "Z">;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
-def ansi : Flag<["-", "--"], "ansi">;
+def ansi : Flag<["-", "--"], "ansi">, Group<CompileOnly_Group>;
 def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
 def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
 def arch__only : Separate<["-"], "arch_only">;


Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -809,7 +809,7 @@
 def Z_Joined : Joined<["-"], "Z">;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
-def ansi : Flag<["-", "--"], "ansi">;
+def ansi : Flag<["-", "--"], "ansi">, Group<CompileOnly_Group>;
 def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
 def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
 def arch__only : Separate<["-"], "arch_only">;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to