Skip to content

Fix #15072: Type aliases not simplified in templates - #8904

Open
ludviggunne wants to merge 4 commits into
cppcheck-opensource:mainfrom
ludviggunne:15072-template-typedefs
Open

ludviggunne wants to merge 4 commits into
cppcheck-opensource:mainfrom
ludviggunne:15072-template-typedefs

Conversation

@ludviggunne

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread test/testsimplifyusing.cpp
Comment thread lib/tokenize.cpp

// skip template definitions
if (Token::Match(tok1, "template < !!>")) {
Token *paramsEnd = tok1->next()->findClosingBracket();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does something like this work correctly?

using U = char;
template<typename T>
struct S {
	using U = T;
	U u;
};
S<int> s;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

##file tmp/example.cpp
2: struct S<int> ;
3:
|
6:
7: S<int> s@var1 ;
3: struct S<int> {
4:
5: int u@var2 ;
6: } ;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll add a test case.

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