| 1 |
// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify |
| 2 |
|
| 3 |
void foo() { |
| 4 |
return foo(); |
| 5 |
} |
| 6 |
|
| 7 |
// PR6451 - C++ Jump checking |
| 8 |
struct X { |
| 9 |
X(); |
| 10 |
}; |
| 11 |
|
| 12 |
void test2() { |
| 13 |
goto later; // expected-error {{cannot jump}} |
| 14 |
X x; // expected-note {{jump bypasses variable initialization}} |
| 15 |
later: |
| 16 |
; |
| 17 |
} |
| 18 |
|
| 19 |
namespace PR6536 { |
| 20 |
struct A {}; |
| 21 |
void a() { goto out; A x; out: return; } |
| 22 |
} |
| 23 |
|
| 24 |
void test3() { |
| 25 |
__asm__ ("":"+r" (test3)); // expected-error{{invalid lvalue in asm output}} |
| 26 |
} |
| 27 |
|
| 28 |
void test4(); // expected-note{{possible target for call}} |
| 29 |
void test4(int) { // expected-note{{possible target for call}} |
| 30 |
// expected-error@+1{{overloaded function could not be resolved}} |
| 31 |
__asm__ ("":"+r" (test4)); // expected-error{{invalid lvalue in asm output}} |
| 32 |
} |
| 33 |
void test5() { |
| 34 |
char buf[1]; |
| 35 |
__asm__ ("":"+r" (buf)); |
| 36 |
} |
| 37 |
|
| 38 |
struct MMX_t {}; |
| 39 |
void test6() { __asm__("" : "=m"(*(MMX_t *)0)); } |
| 40 |
|
| 41 |
template <typename T> |
| 42 |
T test7(T v) { |
| 43 |
return ({ // expected-warning{{use of GNU statement expression extension}} |
| 44 |
T a = v; |
| 45 |
a; |
| 46 |
}); |
| 47 |
} |
| 48 |
|
| 49 |
void test8() { |
| 50 |
int a = test7(1); |
| 51 |
double b = test7(2.0); |
| 52 |
} |
| 53 |
|
| 54 |
template <typename T> |
| 55 |
T test9(T v) { |
| 56 |
return ({ // expected-warning {{use of GNU statement expression extension}} |
| 57 |
T a = v; |
| 58 |
a; // expected-warning {{expression result unused}} |
| 59 |
; |
| 60 |
; |
| 61 |
}); |
| 62 |
} |
| 63 |
|
| 64 |
void test10() { |
| 65 |
int a = test9(1); // expected-note {{in instantiation of function template specialization 'test9<int>' requested here}} |
| 66 |
// expected-error@-10 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}} |
| 67 |
} |
| 68 |
|
| 69 |
namespace GH48405 { |
| 70 |
void foo() { |
| 71 |
struct S { |
| 72 |
int i; |
| 73 |
int j = ({i;}); // expected-error {{invalid use of non-static data member 'i'}} |
| 74 |
// expected-error@-1 {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void'}} |
| 75 |
// expected-warning@-2 {{use of GNU statement expression extension}} |
| 76 |
}; |
| 77 |
} |
| 78 |
} |