This broke CI on platforms such as PPC64LE and AIX due to _Float16 not being supported.
We will reintroduce the changes later with proper platform guards and tests.
This reverts commit 7ca7bcb7d8dcf26fc0281697fe47aa6cdb3884c0.
As can be seen through the docs
(7e1fa09ce2/clang/docs/LanguageExtensions.rst (c-keywords-supported-in-all-language-modes)),
Clang supports certain C keywords in all language modes — this patch
ensures clang-repl handles them consistently.
Here's an example testing all the above keywords. We have everything in
place except `_Imaginary` (_Complex works but _Imaginary doesn't which
was weird) and `_Noreturn`
This adds a warning when applying the `pure` attribute along with the `const` attribute, or when applying the `pure` attribute to a function with a `void` return type (including constructors and destructors).
Fixes https://github.com/llvm/llvm-project/issues/77482
Member functions and static variable definitions may use typedefs that
are private in the global context, but fine in the class context.
Differential Revision: https://reviews.llvm.org/D157838
A double colon starts an identifier name in the global namespace and
must be tentatively parsed as such.
Differential Revision: https://reviews.llvm.org/D157480
This test case was fixed in commit 2c4620c1 ("Consider the scope spec
in template lookups for deduction guides."), but it is worth having a
dedicated test case with a templated struct and a using declaration.
Differential Revision: https://reviews.llvm.org/D157477
isDeductionGuideName looks up the underlying template and if the template name
is qualified we miss that qualification resulting in an error. This issue
resurfaced in clang-repl where we call isDeductionGuideName more often to
distinguish between if we had a statement or declaration.
This patch passes the CXXScopeSpec information down to LookupTemplateName to
make the lookup more precise.
Differential revision: https://reviews.llvm.org/D147319
This patch teaches clang to parse statements on the global scope to allow:
```
./bin/clang-repl
clang-repl> int i = 12;
clang-repl> ++i;
clang-repl> extern "C" int printf(const char*,...);
clang-repl> printf("%d\n", i);
13
clang-repl> %quit
```
Generally, disambiguating between statements and declarations is a non-trivial
task for a C++ parser. The challenge is to allow both standard C++ to be
translated as if this patch does not exist and in the cases where the user typed
a statement to be executed as if it were in a function body.
Clang's Parser does pretty well in disambiguating between declarations and
expressions. We have added DisambiguatingWithExpression flag which allows us to
preserve the existing and optimized behavior where needed and implement the
extra rules for disambiguating. Only few cases require additional attention:
* Constructors/destructors -- Parser::isConstructorDeclarator was used in to
disambiguate between ctor-looking declarations and statements on the global
scope(eg. `Ns::f()`).
* The template keyword -- the template keyword can appear in both declarations
and statements. This patch considers the template keyword to be a declaration
starter which breaks a few cases in incremental mode which will be tackled
later.
* The inline (and similar) keyword -- looking at the first token in many cases
allows us to classify what is a declaration.
* Other language keywords and specifiers -- ObjC/ObjC++/OpenCL/OpenMP rely on
pragmas or special tokens which will be handled in subsequent patches.
The patch conceptually models a "top-level" statement into a TopLevelStmtDecl.
The TopLevelStmtDecl is lowered into a void function with no arguments.
We attach this function to the global initializer list to execute the statement
blocks in the correct order.
Differential revision: https://reviews.llvm.org/D127284