forked from OSchip/llvm-project
Sema: __assume with side effects shouldn't result in invalid AST nodes
We'd diagnose an __assume expression which contained a function call. This would result in us wrongly returning ExprError, causing mysterious failures later on. llvm-svn: 230597
This commit is contained in:
parent
e2008ae475
commit
5123664431
|
@ -2378,7 +2378,7 @@ bool Sema::SemaBuiltinAssume(CallExpr *TheCall) {
|
|||
if (Arg->isInstantiationDependent()) return false;
|
||||
|
||||
if (Arg->HasSideEffects(Context))
|
||||
return Diag(Arg->getLocStart(), diag::warn_assume_side_effects)
|
||||
Diag(Arg->getLocStart(), diag::warn_assume_side_effects)
|
||||
<< Arg->getSourceRange()
|
||||
<< cast<FunctionDecl>(TheCall->getCalleeDecl())->getIdentifier();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
|
||||
// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++14 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
|
||||
|
||||
/* Microsoft attribute tests */
|
||||
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
|
||||
|
@ -375,3 +375,19 @@ typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-war
|
|||
typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
|
||||
typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
|
||||
typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
|
||||
|
||||
namespace {
|
||||
bool f(int);
|
||||
template <typename T>
|
||||
struct A {
|
||||
constexpr A(T t) {
|
||||
__assume(f(t)); // expected-warning{{the argument to '__assume' has side effects that will be discarded}}
|
||||
}
|
||||
constexpr bool g() { return false; }
|
||||
};
|
||||
constexpr A<int> h() {
|
||||
A<int> b(0); // expected-note {{in instantiation of member function}}
|
||||
return b;
|
||||
}
|
||||
static_assert(h().g() == false, "");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue