diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-04-23 06:30:43 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-04-23 06:30:43 +0000 |
commit | 50465d1d2f5f6dd3d8e18e2cf7bad4691e5ca6a8 (patch) | |
tree | 21a8f19bcb43994f52ca72f5b51afbbbf04db994 /test/Driver/clang_f_opts.c | |
parent | 81ef3e664d8ae250fbb68b2b6ccdeebb6c13ede5 (diff) |
There were some frustrating problems with the implementation of
-Wwrite-strings. First and foremost, once the positive form of the flag
was passed, it could never be disabled by passing -Wno-write-strings.
Also, the diagnostic engine couldn't in turn use -Wwrite-strings to
control diagnostics (as GCC does) because it was essentially hijacked to
drive the language semantics.
Fix this by giving CC1 a clean '-fconst-strings' flag to enable
const-qualified strings in C and ObjC compilations. Corresponding
'-fno-const-strings' is also added. Then the driver is taught to
introduce '-fconst-strings' in the CC1 command when '-Wwrite-strings'
dominates.
This entire flag is basically GCC-bug-compatibility driven, so we also
match GCC's bug where '-w' doesn't actually disable -Wwrite-strings. I'm
open to changing this though as it seems insane.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Driver/clang_f_opts.c')
-rw-r--r-- | test/Driver/clang_f_opts.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 8e6b0fe850..8d63ca8706 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -12,3 +12,10 @@ // CHECK-OPTIONS2: -fshort-wchar // CHECK-OPTIONS2: -fno-common // CHECK-OPTIONS2: -fno-show-source-location + +// RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s +// WRITE-STRINGS1: -fconst-strings +// RUN: %clang -### -S -Wwrite-strings -Wno-write-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS2 %s +// WRITE-STRINGS2-NOT: -fconst-strings +// RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s +// WRITE-STRINGS3: -fconst-strings |