brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 9a11a3e Raw
102 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s -DSILENCE2// RUN: %clang_cc1 -fsyntax-only -verify %s -Wlogical-op-parentheses3// RUN: %clang_cc1 -fsyntax-only -verify %s -Wparentheses4// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -Wlogical-op-parentheses 2>&1 | FileCheck %s5 6#ifdef SILENCE7// expected-no-diagnostics8#endif9 10void logical_op_parentheses(unsigned i) {11	const unsigned t = 1;12  (void)(i ||13             i && i);14#ifndef SILENCE15  // expected-warning@-2 {{'&&' within '||'}}16  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}17#endif18  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("19  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:20-[[@LINE-6]]:20}:")"20 21  (void)(t ||22             t && t);23#ifndef SILENCE24  // expected-warning@-2 {{'&&' within '||'}}25  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}26#endif27  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("28  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:20-[[@LINE-6]]:20}:")"29 30  (void)(t && 31             t || t);32#ifndef SILENCE33  // expected-warning@-3 {{'&&' within '||'}}34  // expected-note@-4 {{place parentheses around the '&&' expression to silence this warning}}35#endif36  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:10-[[@LINE-6]]:10}:"("37  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"38	39	(void)(i || i && "w00t");40  (void)("w00t" && i || i);41  (void)("w00t" && t || t);42  (void)(t && t || 0);43#ifndef SILENCE44  // expected-warning@-2 {{'&&' within '||'}}45  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}46#endif47  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("48  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:")"49  (void)(1 && t || t);50#ifndef SILENCE51  // expected-warning@-2 {{'&&' within '||'}}52  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}53#endif54  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("55  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:")"56  (void)(0 || t && t);57#ifndef SILENCE58  // expected-warning@-2 {{'&&' within '||'}}59  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}60#endif61  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("62  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"63  (void)(t || t && 1);64#ifndef SILENCE65  // expected-warning@-2 {{'&&' within '||'}}66  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}67#endif68  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("69  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"70 71  (void)(i || i && "w00t" || i);72#ifndef SILENCE73  // expected-warning@-2 {{'&&' within '||'}}74  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}75#endif76  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("77  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"78 79  (void)(i || "w00t" && i || i);80#ifndef SILENCE81  // expected-warning@-2 {{'&&' within '||'}}82  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}83#endif84  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("85  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"86 87  (void)(i && i || 0);88#ifndef SILENCE89  // expected-warning@-2 {{'&&' within '||'}}90  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}91#endif92  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("93  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:16-[[@LINE-6]]:16}:")"94  (void)(0 || i && i);95#ifndef SILENCE96  // expected-warning@-2 {{'&&' within '||'}}97  // expected-note@-3 {{place parentheses around the '&&' expression to silence this warning}}98#endif99  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("100  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"101}102