Skip to content

Comments

[Clang][AST] Propagate error dependence for _Generic assoc types#6

Open
sdkrystian wants to merge 1 commit intocppalliance:mainfrom
sdkrystian:fix-176929
Open

[Clang][AST] Propagate error dependence for _Generic assoc types#6
sdkrystian wants to merge 1 commit intocppalliance:mainfrom
sdkrystian:fix-176929

Conversation

@sdkrystian
Copy link
Member

The following input crashes:

char *a = _Generic("", char (*)[f(x)]: "");

The crash is happens because a result-dependent _Generic ends up value-dependent without ExprDependence::Error, tripping the assertion in CheckForConstantInitializer in SemaDecl.cpp.

This patch propagates ExprDependence::Error from _Generic association types so result-dependent selections created during error recovery carry the error bit and avoid the constant-initializer assertion.

Fixes 176929 in upstream.

Copy link

@Endilll Endilll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, but I don't feel I know enough about the surrounding code to affirm that this is the right fix in the right place.

double __attribute__((overloadable)) test (double);
char testc(char);

int f(int);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this so far away from the actual test?
Also, is it really needed to reproduce the issue? https://godbolt.org/z/Ych9r74eo

int i = s.a;
}

char *a = _Generic("", char (*)[f(x)]: ""); // expected-error {{use of undeclared identifier 'x'}} ext-warning {{'_Generic' is a C11 extension}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to follow the example of other tests and put this into a function that is named after the issue number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants