]> granicus.if.org Git - clang/commitdiff
Don't claim exception related arguments when looking at RTTIMode
authorFilipe Cabecinhas <me@filcab.net>
Fri, 20 Mar 2015 23:33:23 +0000 (23:33 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Fri, 20 Mar 2015 23:33:23 +0000 (23:33 +0000)
Summary:
We were claiming the -f*exceptions arguments when looking for the
RTTIMode. This makes us not warn about unused arguments if compiling a C
file with -fcxx-exceptions.

This patch fixes it by not claiming the exception-related arguments at
that point.

Reviewers: rsmith, samsonov

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8507

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232860 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChain.cpp
test/Driver/rtti-options.cpp

index d71b903ead5079c5a29d4c31c3abab4bc2ab8f30..52e8603851b10ad56ea69aa345446c51b8199b22 100644 (file)
@@ -48,7 +48,7 @@ static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
 
   // On the PS4, turning on c++ exceptions turns on rtti.
   // We're assuming that, if we see -fexceptions, rtti gets turned on.
-  Arg *Exceptions = Args.getLastArg(
+  Arg *Exceptions = Args.getLastArgNoClaim(
       options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions,
       options::OPT_fexceptions, options::OPT_fno_exceptions);
   if (Exceptions &&
index a14953ebfbd5843747c17f8aed3addbafd7d6504..087ee2162365d6b1f359a3230ad4a07c756bbb10 100644 (file)
@@ -3,6 +3,10 @@
 // No warnings/errors should be emitted for unknown, except if combining
 // the vptr sanitizer with -fno-rtti
 
+// Special case: -fcxx-exceptions in C code should warn about unused arguments
+// RUN: %clang -x c -### -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED %s
+// CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions'
+
 // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s
 // RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s