-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sema: diagnose PMFs passed through registers to inline assembly
The itanium ABI represents the PMF as a pair of pointers. As such the structure cannot be passed through a single register. Diagnose such cases in the frontend rather than trying to generate IR to perform this operation. Fixes: 59033 Differential Revision: https://reviews.llvm.org/D13851 Reviewed By: aaron.ballman
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -std=c++2b -fsyntax-only %s -verify | ||
// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -std=c++2b -fsyntax-only %s -verify | ||
|
||
struct S { | ||
void operator()(); | ||
}; | ||
|
||
struct T { | ||
virtual void operator()(); | ||
}; | ||
|
||
struct U { | ||
static void operator()(); | ||
}; | ||
|
||
struct V: virtual T { | ||
virtual void f(); | ||
}; | ||
|
||
struct W : virtual V { | ||
int i; | ||
}; | ||
|
||
struct X { | ||
__UINTPTR_TYPE__ ptr; | ||
__UINTPTR_TYPE__ adj; | ||
}; | ||
|
||
auto L = [](){}; | ||
|
||
void f() { | ||
auto pmf = &S::operator(); | ||
|
||
__asm__ __volatile__ ("" : : "r"(&decltype(L)::operator())); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
__asm__ __volatile__ ("" : : "r"(&S::operator())); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
__asm__ __volatile__ ("" : : "r"(&T::operator())); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
__asm__ __volatile__ ("" : : "r"(pmf)); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
__asm__ __volatile__ ("" : : "r"(&W::f)); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
__asm__ __volatile__ ("" : : "r"(&W::i)); | ||
// expected-error@-1{{cannot pass a pointer-to-member through register-constrained inline assembly parameter}} | ||
|
||
__asm__ __volatile__ ("" : : "r"(X{0,0})); | ||
__asm__ __volatile__ ("" : : "r"(&U::operator())); | ||
} |