mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 04:06:07 +00:00
Parse vector bool when stdbool.h and altivec.h are included
Currently when including stdbool.h and altivec.h declaration of `vector bool` leads to errors due to `bool` being expanded to '_Bool`. This patch allows the parser to recognize `_Bool`. Reviewed By: hubert.reinterpretcast, Everybody0523 Differential Revision: https://reviews.llvm.org/D102064
This commit is contained in:
parent
b1a074951f
commit
8fa168fc50
@ -118,10 +118,12 @@ class Parser : public CodeCompletionHandler {
|
|||||||
/// Ident_super - IdentifierInfo for "super", to support fast
|
/// Ident_super - IdentifierInfo for "super", to support fast
|
||||||
/// comparison.
|
/// comparison.
|
||||||
IdentifierInfo *Ident_super;
|
IdentifierInfo *Ident_super;
|
||||||
/// Ident_vector, Ident_bool - cached IdentifierInfos for "vector" and
|
/// Ident_vector, Ident_bool, Ident_Bool - cached IdentifierInfos for "vector"
|
||||||
/// "bool" fast comparison. Only present if AltiVec or ZVector are enabled.
|
/// and "bool" fast comparison. Only present if AltiVec or ZVector are
|
||||||
|
/// enabled.
|
||||||
IdentifierInfo *Ident_vector;
|
IdentifierInfo *Ident_vector;
|
||||||
IdentifierInfo *Ident_bool;
|
IdentifierInfo *Ident_bool;
|
||||||
|
IdentifierInfo *Ident_Bool;
|
||||||
/// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
|
/// Ident_pixel - cached IdentifierInfos for "pixel" fast comparison.
|
||||||
/// Only present if AltiVec enabled.
|
/// Only present if AltiVec enabled.
|
||||||
IdentifierInfo *Ident_pixel;
|
IdentifierInfo *Ident_pixel;
|
||||||
@ -879,6 +881,7 @@ private:
|
|||||||
|
|
||||||
if (Tok.getIdentifierInfo() != Ident_vector &&
|
if (Tok.getIdentifierInfo() != Ident_vector &&
|
||||||
Tok.getIdentifierInfo() != Ident_bool &&
|
Tok.getIdentifierInfo() != Ident_bool &&
|
||||||
|
Tok.getIdentifierInfo() != Ident_Bool &&
|
||||||
(!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
|
(!getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -7334,6 +7334,7 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() {
|
|||||||
case tok::kw_float:
|
case tok::kw_float:
|
||||||
case tok::kw_double:
|
case tok::kw_double:
|
||||||
case tok::kw_bool:
|
case tok::kw_bool:
|
||||||
|
case tok::kw__Bool:
|
||||||
case tok::kw___bool:
|
case tok::kw___bool:
|
||||||
case tok::kw___pixel:
|
case tok::kw___pixel:
|
||||||
Tok.setKind(tok::kw___vector);
|
Tok.setKind(tok::kw___vector);
|
||||||
@ -7343,7 +7344,8 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() {
|
|||||||
Tok.setKind(tok::kw___vector);
|
Tok.setKind(tok::kw___vector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Next.getIdentifierInfo() == Ident_bool) {
|
if (Next.getIdentifierInfo() == Ident_bool ||
|
||||||
|
Next.getIdentifierInfo() == Ident_Bool) {
|
||||||
Tok.setKind(tok::kw___vector);
|
Tok.setKind(tok::kw___vector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -7368,6 +7370,7 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
|
|||||||
case tok::kw_float:
|
case tok::kw_float:
|
||||||
case tok::kw_double:
|
case tok::kw_double:
|
||||||
case tok::kw_bool:
|
case tok::kw_bool:
|
||||||
|
case tok::kw__Bool:
|
||||||
case tok::kw___bool:
|
case tok::kw___bool:
|
||||||
case tok::kw___pixel:
|
case tok::kw___pixel:
|
||||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
|
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
|
||||||
@ -7377,8 +7380,10 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
|
|||||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
|
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Next.getIdentifierInfo() == Ident_bool) {
|
if (Next.getIdentifierInfo() == Ident_bool ||
|
||||||
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID,Policy);
|
Next.getIdentifierInfo() == Ident_Bool) {
|
||||||
|
isInvalid =
|
||||||
|
DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -503,10 +503,12 @@ void Parser::Initialize() {
|
|||||||
|
|
||||||
Ident_vector = nullptr;
|
Ident_vector = nullptr;
|
||||||
Ident_bool = nullptr;
|
Ident_bool = nullptr;
|
||||||
|
Ident_Bool = nullptr;
|
||||||
Ident_pixel = nullptr;
|
Ident_pixel = nullptr;
|
||||||
if (getLangOpts().AltiVec || getLangOpts().ZVector) {
|
if (getLangOpts().AltiVec || getLangOpts().ZVector) {
|
||||||
Ident_vector = &PP.getIdentifierTable().get("vector");
|
Ident_vector = &PP.getIdentifierTable().get("vector");
|
||||||
Ident_bool = &PP.getIdentifierTable().get("bool");
|
Ident_bool = &PP.getIdentifierTable().get("bool");
|
||||||
|
Ident_Bool = &PP.getIdentifierTable().get("_Bool");
|
||||||
}
|
}
|
||||||
if (getLangOpts().AltiVec)
|
if (getLangOpts().AltiVec)
|
||||||
Ident_pixel = &PP.getIdentifierTable().get("pixel");
|
Ident_pixel = &PP.getIdentifierTable().get("pixel");
|
||||||
|
23
clang/test/Parser/altivec-zvector-bool.c
Normal file
23
clang/test/Parser/altivec-zvector-bool.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
|
||||||
|
// RUN: -target-feature +altivec -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
|
||||||
|
// RUN: -target-feature +altivec -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff \
|
||||||
|
// RUN: -target-feature +altivec -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff \
|
||||||
|
// RUN: -target-feature +altivec -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=powerpc-unknown-linux-gnu \
|
||||||
|
// RUN: -target-feature +altivec -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=s390x-linux-gnu -target-cpu arch11 \
|
||||||
|
// RUN: -fzvector -fsyntax-only %s
|
||||||
|
// RUN: %clang_cc1 -triple=s390x-ibm-zos -target-cpu arch11 \
|
||||||
|
// RUN: -fzvector -fsyntax-only %s
|
||||||
|
|
||||||
|
__vector bool char bc;
|
||||||
|
__vector bool short bsh;
|
||||||
|
__vector bool short int bshi;
|
||||||
|
__vector bool int bi;
|
||||||
|
__vector _Bool char bc;
|
||||||
|
__vector _Bool short bsh;
|
||||||
|
__vector _Bool short int bshi;
|
||||||
|
__vector _Bool int bi;
|
Loading…
x
Reference in New Issue
Block a user