Skip to content

Commit daced85

Browse files
AaronBallmantru
authored andcommitted
No longer hang on typeof of a function type
We were calling `isFunctionProtoType()` on a `ParsedType` rather than creating a valid semantic type first and calling the function on that. The call to `isFunctionProtoType()` would eventually call `getUnqualifiedDesugaredType()`, which loops indefinitely until we get a desugared type and a `ParsedType` will never finish desugaring. Fixes llvm#64713
1 parent bceec8e commit daced85

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ Bug Fixes in This Version
477477
instantiated in one module and whose definition is instantiated in another
478478
module may end up with members associated with the wrong declaration of the
479479
class, which can result in miscompiles in some cases.
480+
<<<<<<< HEAD
480481

481482
- Added a new diagnostic warning group
482483
``-Wdeprecated-redundant-constexpr-static-def``, under the existing
@@ -700,6 +701,11 @@ Bug Fixes in This Version
700701
(`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`)
701702
- Fix crash on nested templated class with template function call.
702703
(`#61159 <https://github.com/llvm/llvm-project/issues/61159>_`)
704+
- Fix crash on use of a variadic overloaded operator.
705+
(`#42535 <https://github.com/llvm/llvm-project/issues/42535>_`)
706+
- Fix a hang on valid C code passing a function type as an argument to
707+
``typeof`` to form a function declaration.
708+
(`#64713 <https://github.com/llvm/llvm-project/issues/64713>_`)
703709

704710
Bug Fixes to Compiler Builtins
705711
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9154,7 +9154,8 @@ static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
91549154
bool HasPrototype =
91559155
(D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) ||
91569156
(D.getDeclSpec().isTypeRep() &&
9157-
D.getDeclSpec().getRepAsType().get()->isFunctionProtoType()) ||
9157+
SemaRef.GetTypeFromParser(D.getDeclSpec().getRepAsType(), nullptr)
9158+
->isFunctionProtoType()) ||
91589159
(!R->getAsAdjusted<FunctionType>() && R->isFunctionProtoType());
91599160
assert(
91609161
(HasPrototype || !SemaRef.getLangOpts().requiresStrictPrototypes()) &&

clang/test/C/C2x/n2927.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ extern typeof(D) C; // C has type "double[2]"
9090
typeof(D) D = { 5, 8.9, 0.1, 99 }; // D is now completed to "double[4]"
9191
extern double E[4];
9292
extern typeof(D) E; // E has type "double[4]" from D’s completed type
93+
94+
// GH64713 -- this used to trigger an infinite loop when creating the function
95+
// declaration for F from the function designator specified by typeof.
96+
typeof(int(int)) F; // F has type "int(int)"

0 commit comments

Comments
 (0)