[cfe-commits] r140522 - /cfe/trunk/test/Misc/show-diag-options.c

Chandler Carruth chandlerc at gmail.com
Mon Sep 26 03:42:40 PDT 2011


Author: chandlerc
Date: Mon Sep 26 05:42:40 2011
New Revision: 140522

URL: http://llvm.org/viewvc/llvm-project?rev=140522&view=rev
Log:
Add a test for the display of diagnostic options and categories. This
would have caught a bug I introduced during refactoring. Silly me
thinking this was all well tested already...

If any of this is already covered by other tests, let me know. I looked
around and didn't see any.

Added:
    cfe/trunk/test/Misc/show-diag-options.c

Added: cfe/trunk/test/Misc/show-diag-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/show-diag-options.c?rev=140522&view=auto
==============================================================================
--- cfe/trunk/test/Misc/show-diag-options.c (added)
+++ cfe/trunk/test/Misc/show-diag-options.c Mon Sep 26 05:42:40 2011
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=BASE
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=OPTION
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Werror %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=OPTION_ERROR
+// RUN: %clang_cc1 -fsyntax-only -std=c89 -pedantic -fdiagnostics-show-option %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=OPTION_PEDANTIC
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-category id %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CATEGORY_ID
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-category name %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CATEGORY_NAME
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -fdiagnostics-show-category name -Werror %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=OPTION_ERROR_CATEGORY
+
+void test(int x, int y) {
+  if (x = y) ++x;
+  // BASE: {{.*}}: warning: {{[a-z ]+$}}
+  // OPTION: {{.*}}: warning: {{[a-z ]+}} [-Wparentheses]
+  // OPTION_ERROR: {{.*}}: error: {{[a-z ]+}} [-Werror,-Wparentheses]
+  // CATEGORY_ID: {{.*}}: warning: {{[a-z ]+}} [2]
+  // CATEGORY_NAME: {{.*}}: warning: {{[a-z ]+}} [Semantic Issue]
+  // OPTION_ERROR_CATEGORY: {{.*}}: error: {{[a-z ]+}} [-Werror,-Wparentheses,Semantic Issue]
+
+  // Leverage the fact that all these '//'s get warned about in C89 pedantic.
+  // OPTION_PEDANTIC: {{.*}}: warning: {{[/a-z ]+}} [-pedantic,-Wcomment]
+}





More information about the cfe-commits mailing list