forked from OSchip/llvm-project
Sema: Don't crash on visibility attributes with an identifier argument.
PR17105. llvm-svn: 190312
This commit is contained in:
parent
60509af49a
commit
7037021e78
|
@ -2438,9 +2438,10 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr,
|
|||
if (!checkAttributeNumArgs(S, Attr, 1))
|
||||
return;
|
||||
|
||||
Expr *Arg = Attr.getArgAsExpr(0);
|
||||
Arg = Arg->IgnoreParenCasts();
|
||||
StringLiteral *Str = dyn_cast<StringLiteral>(Arg);
|
||||
// Check that the argument is a string literal.
|
||||
StringLiteral *Str = 0;
|
||||
if (Attr.isArgExpr(0))
|
||||
Str = dyn_cast<StringLiteral>(Attr.getArgAsExpr(0)->IgnoreParenCasts());
|
||||
|
||||
if (!Str || !Str->isAscii()) {
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
|
||||
|
|
|
@ -24,3 +24,5 @@ extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visi
|
|||
typedef int __attribute__((visibility("default"))) bar; // expected-warning {{'visibility' attribute ignored}}
|
||||
|
||||
int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
|
||||
|
||||
int PR17105 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}}
|
||||
|
|
Loading…
Reference in New Issue